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

Ground transport

Description
Problem name and type, featuresDifficulty
E‑1 Car rental: Transport problem ***
data preprocessing, set operations, sqrt and ^2, if-then-elif
E‑2 Choosing the mode of transport: Minimum cost flow **
formulation with extra nodes for modes of transport; encoding of arcs, finalize, union of sets, nodes labeled with strings
E‑3 Depot location: Facility location problem ***
modeling flows as fractions, definition of model cuts
E‑4 Heating oil delivery: Vehicle routing problem (VRP) ****
elimination of inadmissible subtours, cuts; selection with `|', definition of model cuts
E‑5 Combining different modes of transport ***
modeling implications, weak and strong formulation of bounding constraints; triple indices
E‑6 Fleet planning for vans ***
maxlist, minlist, max, min


Further explanation of this example: 'Applications of optimization with Xpress-MP', Chapter 10: Ground transport

mosel_app_5.zip[download all files]

Source Files

Data Files





e3depot.mos

(!******************************************************
   Mosel Example Problems
   ======================

   file e3depot.mos
   ````````````````
   Depot location
   
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Mar. 2002
*******************************************************!)

model "E-3 Depot location"
 uses "mmxprs"

 declarations
  DEPOTS = 1..12                       ! Set of depots
  CUST = 1..12                         ! Set of customers

  COST: array(DEPOTS,CUST) of integer  ! Delivery cost
  CFIX: array(DEPOTS) of integer       ! Fix cost of depot construction
  CAP: array(DEPOTS) of integer        ! Depot capacity
  DEM: array(CUST) of integer          ! Demand by customers

  fflow: array(DEPOTS,CUST) of mpvar   ! Perc. of demand supplied from depot
  build: array(DEPOTS) of mpvar        ! 1 if depot built, 0 otherwise
 end-declarations

 initializations from 'e3depot.dat'
  COST CFIX CAP DEM
 end-initializations

! Objective: total cost
 TotCost:= sum(d in DEPOTS, c in CUST) COST(d,c)*fflow(d,c) +
            sum(d in DEPOTS) CFIX(d)*build(d)

! Satisfy demands
 forall(c in CUST) sum(d in DEPOTS) fflow(d,c) = 1
   
! Capacity limits at depots
 forall(d in DEPOTS) sum(c in CUST) DEM(c)*fflow(d,c) <= CAP(d)*build(d)

! Additional constraints:
! If there is any delivery from depot d, then this depot must be built
(!
 declarations
  modcut: array(DEPOTS,CUST) of linctr
 end-declarations

 forall(d in DEPOTS, c in CUST) do
  modcut(d,c):= DEM(c) * fflow(d,c) <= CAP(d) * build(d)
  setmodcut(modcut(d,c))
 end-do
!)

 forall(d in DEPOTS) build(d) is_binary
 forall(d in DEPOTS, c in CUST) fflow(d,c) <= 1

! Uncomment the following line to see the Optimizer log
! setparam("XPRS_VERBOSE",true)

! Solve the problem
 minimize(TotCost)
 
! Solution printing
 writeln("Total cost: ", getobjval)
 forall(d in DEPOTS, c in CUST)
  if(getsol(fflow(d,c))>0) then
   writeln(strfmt(d,2), " -> ", strfmt(c,2), ": ", 
           strfmt(getsol(fflow(d,c))*DEM(c),3) )
  end-if

end-model

Back to examples browserPrevious exampleNext example