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, 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

mosel_app_3.zip[download all files]

Source Files

Data Files





c5fiber.mos

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

   file c5fiber.mos
   ````````````````
   Planning the production of fiberglass
 
   The next 6 weeks of fiberglass production needs to be
   planned. Capacity is limited and varies by week. Production
   and storage costs also change over time. Determine
   the plan that minimizes total cost of production and
   storage while meeting demand for the time period.

   This problem introduces a transshipment flow formulation.
   The demand and capacity data are represented as node weights
   and are combined into a single array 'WEIGHT'. 'ARC' defines
   the cost of flow between nodes. Note that since the array of
   variables 'flow' is dynamic, it must be created after the data is 
   read and only for node combinations where 'ARC' exists. Two new
   functions are introduced here: 'isodd' determines if an integer
   value is odd or even and 'getlast' returns the last entry of a
   range or a list.  

   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Mar. 2002, rev. Nov. 2017
*******************************************************!)

model "C-5 Fiberglass"
 uses "mmxprs"

 declarations   
  NODES: range                           ! Production and demand nodes
                                         ! odd numbers: production capacities
                                         ! even numbers: demands

  ARC: dynamic array(NODES,NODES) of real   ! Cost of flow on arcs
  WEIGHT: array(NODES) of integer           ! Node weights (capacities/demand)

  flow: dynamic array(NODES,NODES) of mpvar ! Flow on arcs
 end-declarations

 initializations from 'c5fiber.dat'
  ARC WEIGHT
 end-initializations

 forall(m,n in NODES | exists(ARC(m,n))) create(flow(m,n))

! Objective: total cost of production and storage
 Cost:= sum(m,n in NODES | exists(ARC(m,n))) ARC(m,n)*flow(m,n)

! Satisfy demands (flow balance constraints)
 forall(n in NODES | isodd(n)=FALSE)
  if(n>2, flow(n-2,n), 0) + flow(n-1,n) = 
   if(n<getlast(NODES), flow(n,n+2), 0) + WEIGHT(n)

! Production capacities
 forall(n in NODES | isodd(n)) flow(n,n+1) <= WEIGHT(n)

! Solve the problem
 minimize(Cost)
 
! Solution printing
 writeln("Total cost: ",getobjval)
 write("Week")
 forall(t in 1..integer(getlast(NODES)/2)) write(strfmt(t,5))
 write("\nProd.")
 forall(n in NODES | isodd(n)) 
  write(strfmt(getsol(sum(m in NODES) flow(n,m)),5))
 write("\nStock")
 forall(n in NODES | not(isodd(n))) 
  write(strfmt(getsol(sum(m in NODES) flow(n,m)),5))
 writeln

end-model

Back to examples browserPrevious exampleNext example