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, featuresDifficultyRelated examples
E‑1 Car rental: Transport problem *** transport_graph.mos
data preprocessing, set operations, sqrt and ^2, if-then-elif
E‑2 Choosing the mode of transport: Minimum cost flow ** mincostflow_graph.mos
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 *** facilityloc_graph.mos
modeling flows as fractions, definition of model cuts
E‑4 Heating oil delivery: Vehicle routing problem (VRP) **** vrp_graph.mos
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
  
   A company is planning to open new locations to supply 
   its sales centers. Each new location has a fixed set-up
   cost. Each delivery from supply location to sales center
   has a distance dependent delivery cost. There are 12 possible
   new locations to supply 12 sales centers. Demand for sales 
   centers can be met by multiple supply locations. Which 
   locations should be opened to meet demand but also minimize
   total cost of set-up and delivery?

   The model formulation represents flows as fraction (percentage)
   of the demand (variables 'fflow'). It also shows how redundant
   constraints can be stated as model cuts (=additional constraints
   that do not form part of the problem matrix).

   (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 | getsol(fflow(d,c))>0) 
   writeln(strfmt(d,2), " -> ", strfmt(c,2), ": ", 
           strfmt(getsol(fflow(d,c))*DEM(c),3) )

end-model

Back to examples browserPrevious exampleNext example