FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browserPrevious example

Local authorities and public services

Problem name and type, featuresDifficultyRelated examples
J‑1 Water conveyance / water supply management: Maximum flow problem ** g1rely.mos
encoding of arcs, selection with `|', record data structure
J‑2 CCTV surveillance: Maximum vertex cover problem ** g6transmit.mos, d5cutsh.mos
encoding of network, exists
J‑3 Rigging elections: Partitioning problem **** partitioning_graph.mos
algorithm for data preprocessing; file inclusion, 3 nested/recursive procedures, working with sets, if-then, forall-do, exists, finalize
J‑4 Gritting roads: Directed Chinese postman problem ****
algorithm for finding Eulerian path/graph for printing; encoding of arcs, dynamic array, exists, 2 functions implementing Eulerian circuit algorithm, round, getsize, break, while-do, if-then-else, list handling
J‑5 Location of income tax offices: p-median problem ****
modeling an implication, all-pairs shortest path algorithm (Floyd-Warshall); dynamic array, exists, procedure for shortest path algorithm, forall-do, if-then, selection with `|'
J‑6 Efficiency of hospitals: Data Envelopment Analysis (DEA) ***
description of DEA method; loop over problem solving with complete re-definition of problem every time, naming and declaring constraints

Further explanation of this example: 'Applications of optimization with Xpress-MP', Chapter 15: Local authorities and public services[download all files]

Source Files

Data Files


   Mosel Example Problems

   file j1water.mos
   Water conveyance/water supply management

   A water transport network is provided. Nodes correspond
   to cities, reservoirs, and pumping stations. Arcs
   correspond to pipes. Capacities for each reservoir,
   demand for each city, and capacities for the pipe
   connections are given. How much water should flow through
   each pipe to maximize the flow in the network?

   A network transformation is presented to introduce fictitious
   source and sink nodes. A LP model based on the transport
   network representation is presented.

   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Mar. 2002

model "J-1 Water supply"
 uses "mmxprs"

  ARCS: range                       ! Set of arcs
  PIPE: array(ARCS,1..2) of integer ! Definition of arcs (= pipes)
  CAP: array(ARCS) of integer       ! Capacity of arcs
  SOURCE,SINK: integer              ! Number of source and sink nodes

 initializations from 'j1water.dat'

  flow: array(ARCS) of mpvar       ! Flow on arcs

! Objective: total flow
 TotalFlow:= sum(a in ARCS | PIPE(a,2)=SINK) flow(a)

! Flow balances in nodes
 forall(n in NODES | n<>SOURCE and n<>SINK) 
  sum(a in ARCS | PIPE(a,1)=n) flow(a) = sum(a in ARCS | PIPE(a,2)=n) flow(a)

! Capacity limits
 forall(a in ARCS) flow(a) <= CAP(a)

! Solve the problem
! Solution printing
 writeln("Total flow: ", getobjval)
 forall(a in ARCS) writeln(PIPE(a,1), " -> ", PIPE(a,2), ": ", getsol(flow(a)))

Back to examples browserPrevious example