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





e5combine.mos

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

   file e5combine.mos
   ``````````````````
   Combining different modes of transport
   
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Mar. 2002
*******************************************************!)

model "E-5 Combined transport"
 uses "mmxprs"

 declarations
  NL = 4
  LEGS = 1..NL                          ! Legs of the transport
  MODES: set of string                  ! Modes of transport

  CTRANS: array(MODES,LEGS) of integer  ! Transport cost
  CCHG: array(MODES,MODES) of integer   ! Cost of changing mode of transport
 end-declarations

 initializations from 'e5combine.dat'
  CTRANS CCHG
 end-initializations

 finalize(MODES)

 declarations
  use: array(MODES,LEGS) of mpvar        ! 1 if a mode is used, 0 otherwise
  change: array(MODES,MODES,1..NL-1) of mpvar  ! 1 if change from mode m to n
                                               ! at end of leg, 0 otherwise
 end-declarations

! Objective: total cost
 Cost:= sum(m in MODES, l in LEGS) CTRANS(m,l)*use(m,l) +
         sum(m,n in MODES,l in 1..NL-1) CCHG(m,n)*change(m,n,l)

! One mode of transport per leg
 forall(l in LEGS) sum(m in MODES) use(m,l) = 1
 
! Change or maintain mode of transport between every pair of legs
 forall(l in 1..NL-1) sum(m,n in MODES) change(m,n,l) = 1

! Relation between modes used and changes
 forall(m,n in MODES,l in 1..NL-1) use(m,l) + use(n,l+1) >= 2*change(m,n,l)

 forall(m in MODES, l in LEGS) use(m,l) is_binary
 forall(m,n in MODES,l in 1..NL-1) change(m,n,l) is_binary
 
! Solve the problem
 minimize(Cost)
 
! Solution printing
 writeln("Total cost: ", getobjval)
 forall(l in LEGS) do
  write("  ",l, "-", l+1,": ")
  forall(m in MODES) write(if(getsol(use(m,l))>0 , m, ""))
 end-do 
 writeln

end-model

Back to examples browserPrevious exampleNext example