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

Planning problems

Description
Problem name and type, featuresDifficulty
C‑1 Planning the production of bicycles: Production planning (single product) ***
modeling inventory balance; inline if, forall-do
C‑2 Production of drinking glasses: Multi-item production planning **
modeling stock balance constraints; inline if, index value 0
C‑3 Material requirement planning: Material requirement planning (MRP) **
working with index (sub)sets, dynamic initialization, finalize, create, as
C‑4 Planning the production of electronic components: Multi-item production planning **
modeling stock balance constraints; inline if
C‑5 Planning the production of fiberglass: Production planning with time-dependent production cost ***
representation of multi-period production as flow; encoding of arcs, exists, create, isodd, getlast, inline if
C‑6 Assignment of production batches to machines: Generalized assignment problem *


Further explanation of this example: 'Applications of optimization with Xpress-MP', Chapter 8: Production planning

mosel_app_3.zip[download all files]

Source Files

Data Files





c4compo.mos

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

   file c4compo.mos
   ````````````````
   Planning the production of electronic components
   
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Mar. 2002
*******************************************************!)

model "C-4 Electronic components"
 uses "mmxprs"

 declarations   
  NT = 6                                 ! Number of time periods (months)
  MONTHS = 1..NT
  PRODS = 1..4                           ! Set of components

  DEM: array(PRODS,MONTHS) of integer    ! Demand of components per month
  CPROD: array(PRODS) of integer         ! Production costs
  CSTOCK: array(PRODS) of real           ! Storage costs
  CADD,CRED: real                        ! Cost of additional/reduced prod.
  ISTOCK,FSTOCK: array(PRODS) of integer ! Initial and final stock levels

  produce: array(PRODS,MONTHS) of mpvar  ! Quantities produced per month
  store: array(PRODS,MONTHS) of mpvar    ! Stock levels at end of every month
  reduce: array(MONTHS) of mpvar         ! Reduction of production per month
  add: array(MONTHS) of mpvar            ! Increase of production per month
 end-declarations

 initializations from 'c4compo.dat'
  DEM CPROD CSTOCK CADD CRED ISTOCK FSTOCK
 end-initializations

! Objective: total cost of production, storage, and change of prod. level
 Cost:= sum(p in PRODS, t in MONTHS) (CPROD(p)*produce(p,t) + 
                                      CSTOCK(p)*store(p,t)) +
        sum(t in 2..NT) (CRED*reduce(t) + CADD*add(t))

! Stock balance constraints (satisfy demands)
 forall(p in PRODS, t in MONTHS)
  store(p,t) = if(t>1, store(p,t-1), ISTOCK(p)) + produce(p,t) - DEM(p,t)

! Changes to the level of production
 forall(t in 2..NT) 
  sum(p in PRODS) (produce(p,t) - produce(p,t-1)) = add(t) - reduce(t)

! Guarantee final stock levels
forall(p in PRODS) store(p,NT) >= FSTOCK(p)

! Solve the problem
 minimize(Cost)
 
! Solution printing
 declarations
  PNAME: array(PRODS) of string          ! Product names
 end-declarations 

 initializations from 'c4compo.dat'
  PNAME 
 end-initializations

 writeln("Total cost: ",getobjval)
 write(strfmt("Month",13))
 forall(t in MONTHS) write(strfmt(t,5))
 forall(p in PRODS) do
  write("\n", PNAME(p), ": Prod. ")
  forall(t in MONTHS) write(strfmt(getsol(produce(p,t)),5))
  write("\n", strfmt("Store ",14))
  forall(t in MONTHS) write(strfmt("("+getsol(store(p,t))+")",5))
 end-do
 write("\nTotal         ")
 forall(t in MONTHS) write(strfmt(sum(p in PRODS) getsol(produce(p,t)),5))
 writeln

end-model

Back to examples browserPrevious exampleNext example