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

Planning problems

Problem name and type, featuresDifficultyRelated examples
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 ** prodplan_graph.mos
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, automatic finalization, as
C‑4 Planning the production of electronic components: Multi-item production planning ** c2glass.mos
modeling stock balance constraints; inline if
C‑5 Planning the production of fiberglass: Production planning with time-dependent production cost *** transship_graph.mos
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 * assignment_graph.mos

Further explanation of this example: 'Applications of optimization with Xpress-MP', Chapter 8: Production planning[download all files]

Source Files

Data Files


   Mosel Example Problems

   file c1bike.mos
   Planning the production of bicycles

   A sales forecast shows the predicted bicycle demand for the
   upcoming year. There is a set production capacity per month
   but it can be increased with overtime (with additional costs).
   The company can store excess bikes at a small cost with no
   limit to quantity. How many bikes need to be produced and
   stored in the next year to meet the forecasted demand while
   minimizing total (production, overtime, storage) cost?

   This implementation using the inline 'if' function to condense
   the balance constraints since this varies for t=1 and t>1.
   Note that there is no slack built into the demand forecast so
   bike storage will be as low as possible to reduce total cost.
   This may not be practical if there is an unpredicted spike in

   (c) 2008-2022 Fair Isaac Corporation
       author: S. Heipcke, Mar. 2002, rev. Mar. 2022

model "C-1 Bicycle production"
 uses "mmxprs"

  TIMES = 1..12                  ! Range of time periods

  DEM: array(TIMES) of integer   ! Demand per months
  CNORM,COVER: integer           ! Prod. cost in normal / overtime hours
  CSTOCK: integer                ! Storage cost per bicycle
  CAP: integer                   ! Monthly capacity in normal working hours
  ISTOCK: integer                ! Initial stock

  pnorm:array(TIMES) of mpvar    ! No. of bicycles produced in normal hours
  pover:array(TIMES) of mpvar    ! No. of bicycles produced in overtime hours
  store:array(TIMES) of mpvar    ! No. of bicycles stored per month

 initializations from 'c1bike.dat'

! Objective: minimize production cost
 Cost:= sum(t in TIMES) (CNORM*pnorm(t) + COVER*pover(t) + CSTOCK*store(t))

! Satisfy the demand for every period
 forall(t in TIMES) 
  pnorm(t) + pover(t) + if(t>1, store(t-1), ISTOCK) = DEM(t) + store(t)

! Capacity limits on normal and overtime working hours per month
 forall(t in TIMES) do
  pnorm(t) <= CAP
  pover(t) <= 0.5*CAP

! Solve the problem
! Solution printing
  MONTHS: array(TIMES) of string  ! Names of months

 initializations from 'c1bike.dat'
 writeln("Total cost: ", getobjval)
 write("       ")
 forall(t in TIMES) write(strfmt(MONTHS(t),4))
 setparam("realfmt", "%4g")    ! Reserve 4 char.s for display of real numbers
 write("\nDemand ")
 forall(t in TIMES) write(DEM(t)/1000)
 write("\nNormal ")
 forall(t in TIMES) write(getsol(pnorm(t))/1000)
 write("\nAdd.   ")
 forall(t in TIMES) write(getsol(pover(t))/1000)
 write("\nStore  ")
 forall(t in TIMES) write(getsol(store(t))/1000)


Back to examples browserPrevious exampleNext example