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

Basic embedding tasks

Description
  • ugcomptmp.cs: Compiling a model into a BIM file saved in Mosel's temporary directory (requires burglar2.mos, burglar.dat)
  • ugrun.cs: Compiling a model into a BIM file, then load and run it (requires burglar2.bim, burglar.dat)
  • ugdefstream.cs: Redirecting the model output (requires burglar2.mos, burglar.dat)
  • ugarray.cs: Accessing modeling objects: sparse arrays (requires transport.mos, transprt.dat)
  • ugcb.cs: Retrieve model output via a callback into a custom TextWriter (requires burglar2.mos, burglar.dat)
  • ugcb2.cs: Retrieve model output via a callback into a string (requires burglar2.mos, burglar.dat)
  • ugparam.cs: Passing parameters to a Mosel model (requires prime.mos)
  • ugsol.java: Accessing modeling objects and solution information (requires burglar3.mos, burglar.dat)


Source Files

Data Files





transport.mos

(!******************************************************
   Mosel User Guide Example Problems
   ================================= 

   file transport.mos
   ``````````````````
   Using dynamic arrays.
   
   (c) 2008 Fair Isaac Corporation
       author: S.Heipcke, 2001, rev. June 2018
*******************************************************!)

model Transport
 uses "mmxprs"

 public declarations
  REGION: set of string                 ! Set of customer regions
  PLANT: set of string                  ! Set of plants

  DEMAND: array(REGION) of real         ! Demand at regions
  PLANTCAP: array(PLANT) of real        ! Production capacity at plants
  PLANTCOST: array(PLANT) of real       ! Unit production cost at plants
  TRANSCAP: dynamic array(PLANT,REGION) of real
                                        ! Capacity on each route plant->region
  DISTANCE: dynamic array(PLANT,REGION) of real
                                        ! Distance of each route plant->region
  FUELCOST: real                        ! Fuel cost per unit distance

  flow: dynamic array(PLANT,REGION) of mpvar    ! Flow on each route
 end-declarations
 
 initializations from 'transprt.dat'
  DEMAND
  [PLANTCAP,PLANTCOST] as 'PLANTDATA'
  [DISTANCE,TRANSCAP] as 'ROUTES'
  FUELCOST
 end-initializations
 
! Create the flow variables that exist
 forall(p in PLANT, r in REGION | exists(TRANSCAP(p,r)) ) create(flow(p,r))
 
! Objective: minimize total cost
 MinCost:= sum(p in PLANT, r in REGION | exists(flow(p,r))) 
            (FUELCOST * DISTANCE(p,r) + PLANTCOST(p)) * flow(p,r)
 
! Limits on plant capacity
 forall(p in PLANT) sum(r in REGION) flow(p,r) <= PLANTCAP(p)

! Satisfy all demands
 forall(r in REGION) sum(p in PLANT) flow(p,r) = DEMAND(r)
 
! Bounds on flows
 forall(p in PLANT, r in REGION | exists(flow(p,r))) 
  flow(p,r) <= TRANSCAP(p,r)
 
 minimize(MinCost)                       ! Solve the problem
 
end-model

Back to examples browserPrevious exampleNext example