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





c2glass.mos

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

   file c2glass.mos
   ````````````````
   Planning the production of glasses
   
   A French company produces 6 types of drinking glasses.
   Each product has varying production cost, storage cost, 
   initial stock, and storage space requirements. The time it
   take a work and machine to create each batch of glasses 
   also varies. How much of each type of glasses should be 
   produced in each period so that the total (production and 
   storage) cost be minimized?
   
   A balance constraint is necessary to define the glasses 
   stored from one period to the next. Note that the production 
   variable cannot be named 'prod' and the set of products 
   cannot be named 'PROD' as 'prod' is a reserved word since 
   it is a keyword of Mosel.
   
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Mar. 2002
*******************************************************!)

model "C-2 Glass production"
 uses "mmxprs", "mmsystem"

 declarations   
  NT = 12                              ! Number of weeks in planning period
  WEEKS = 1..NT 
  PRODS = 1.. 6                        ! Set of products

  CAPW,CAPM: integer                   ! Capacity of workers and machines
  CAPS: integer                        ! Storage capacity
  DEM: array(PRODS,WEEKS) of integer   ! Demand per product and per week
  CPROD: array(PRODS) of integer       ! Production cost per product
  CSTOCK: array(PRODS) of integer      ! Storage cost per product
  ISTOCK: array(PRODS) of integer      ! Initial stock levels
  FSTOCK: array(PRODS) of integer      ! Min. final stock levels
  TIMEW,TIMEM: array(PRODS) of integer ! Worker and machine time per unit
  SPACE: array(PRODS) of integer       ! Storage space required by products
  
  produce: array(PRODS,WEEKS) of mpvar ! Production of products per week
  store: array(PRODS,WEEKS) of mpvar   ! Amount stored at end of week
 end-declarations

 initializations from 'c2glass.dat'
  CAPW CAPM CAPS DEM CSTOCK CPROD ISTOCK FSTOCK TIMEW TIMEM SPACE
 end-initializations

! Objective: sum of production and storage costs
 Cost:= 
  sum(p in PRODS, t in WEEKS) (CPROD(p)*produce(p,t) + CSTOCK(p)*store(p,t))

! Stock balances
 forall(p in PRODS, t in WEEKS)
  store(p,t) = if(t>1, store(p,t-1), ISTOCK(p)) + produce(p,t) - DEM(p,t)

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

! Capacity constraints
 forall(t in WEEKS) do
  sum(p in PRODS) TIMEW(p)*produce(p,t) <= CAPW     ! Workers
  sum(p in PRODS) TIMEM(p)*produce(p,t) <= CAPM     ! Machines
  sum(p in PRODS) SPACE(p)*store(p,t)   <= CAPS     ! Storage
 end-do

! Solve the problem
 minimize(Cost)
 
! Solution printing
 writeln("Total cost: ",getobjval)
 writeln("Production plan:")
 write("     Week")
 forall(t in WEEKS) write(textfmt(t,7))
 writeln
 forall(p in PRODS) do
  write(p,": Prod. ")
  forall(t in WEEKS) write(textfmt(getsol(produce(p,t)),7))
  writeln
  write("   Store ")
  forall(t in WEEKS) write(textfmt("("+getsol(store(p,t))+")",7))
  writeln
 end-do

 writeln("\nCapacities used:")
 writeln(formattext("Week%8s%9s%7s","Workers","Machines","Space"))
 forall(t in WEEKS) 
  writeln(formattext("%2d%8g%10.2f%9.2f", t,
   getsol(sum(p in PRODS) TIMEW(p)*produce(p,t)),
   getsol(sum(p in PRODS) TIMEM(p)*produce(p,t)),
   getsol(sum(p in PRODS) SPACE(p)*store(p,t))) ) 
	   
end-model

Back to examples browserPrevious exampleNext example