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

Loading and cutting problems

Description
Problem name and type, featuresDifficultyRelated examples
D‑1 Wagon load balancing: Nonpreemptive scheduling on parallel machines ****
heuristic solution requiring sorting algorithm, formulation of maximin objective; nested subroutines: function returning heuristic solution value and sorting procedure, ceil, getsize, if-then, break, exit, all loop types (forall-do, repeat-until, while-do), setparam, qsort, cutoff value, loading a MIP start solution
D‑2 Barge loading: Knapsack problem ** burglar1.mos, knapsack_graph.mos
incremental problem definition with 3 different objectives, procedure for solution printing
D‑3 Tank loading: Loading problem ***
2 objectives; data preprocessing, as, dynamic creation of variables, procedure for solution printing, if-then-else
D‑4 Backing up files: Bin-packing problem ** binpacking_graph.mos
2 versions of mathematical model, symmetry breaking; data preprocessing, ceil, range
D‑5 Cutting sheet metal: Covering problem * g6transmit.mos, j2bigbro.mos
D‑6 Cutting steel bars for desk legs: Cutting-stock problem ** cutstock_graph.mos
set operation(s) on range sets, set of integer (data as set contents)


Further explanation of this example: 'Applications of optimization with Xpress-MP', Chapter 9: Loading and cutting stock problems

mosel_app_4.zip[download all files]

Source Files

Data Files





d6cutbar.mos

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

   file d6cutbar.mos
   `````````````````
   Cutting of steel bars into school desk legs 
   (1-dimensional cutting patterns)

   A company produces school desks of various heights. The
   legs are all cut from steel bars of 1.5 or 2 meters. How
   should an order be produced to minimize the trim loss?

   Note that each length of steel bars has a unique set of
   patterns. The total set of patterns is the union of these
   two sets. This problem also uses a 'set of integer' which is
   more general than a 'range [of integer]'.

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

model "D-6 Cutting steel bars"
 uses "mmxprs"

 declarations
  PAT1 = 1..6; PAT2 = 7..12              ! Sets of cutting patterns
  PATTERNS = PAT1 + PAT2                 ! Set of all cutting patterns
  SIZES: set of integer                  ! Desk heights

  DEM: array(SIZES) of integer           ! Demands for the different heights
  CUT: array(PATTERNS,SIZES) of integer  ! Cutting patterns
  LEN: array(range) of integer           ! Lengths of original steel bars
  
  use: array(PATTERNS) of mpvar          ! Use of cutting patterns
 end-declarations
 
 initializations from 'd6cutbar.dat'
  DEM CUT LEN
 end-initializations

! Objective: total loss
 Loss:= sum(p in PAT1) LEN(1)*use(p) + sum(p in PAT2) LEN(2)*use(p) - 
         sum(s in SIZES) 4*DEM(s)*s

! Satisfy demands
 forall(s in SIZES) sum(p in PATTERNS) CUT(p,s)*use(p) >= 4*DEM(s)

 forall(p in PATTERNS) use(p) is_integer

! Solve the problem
 minimize(Loss)
 
! Solution printing
  writeln("Loss: ", getobjval, "cm")
  write("Short bars: ", getsol(sum(p in PAT1) use(p)))
  writeln(", long bars: ", getsol(sum(p in PAT2) use(p)))
  write("Cutting patterns used:")
  forall(p in PATTERNS)
   write( if(getsol(use(p)) > 0 , " " + p + ":" + getsol(use(p)), "") )
  write("\nNumbers of legs cut: ")
  forall(s in SIZES)
   write(s, ":", getsol(sum(p in PATTERNS) CUT(p,s)*use(p)), " ")
  writeln
      
end-model

Back to examples browserPrevious exampleNext example