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





d2ship.mos

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

   file d2ship.mos
   ```````````````
   Choice of wheat load for a ship
   
   A shipper has 7 clients that wish to ship wheat. Each has
   varying quantities of lots, size of lots, shipping price,
   and transport costs. How can the shipper maximize profit?
   
   Three incrementally defined problems are solved in series. 
   Each introduces a new constraint while still maximizing profit.
   Procedure "printsol" is used to print the different 
   solutions depending on which problem is solved.
      
   (c) 2008-2022 Fair Isaac Corporation
       author: S. Heipcke, Mar. 2002, rev. Mar. 2022
*******************************************************!)

model "D-2 Ship loading"
 uses "mmxprs"

 forward procedure printsol(num:integer)

 declarations   
  CLIENTS = 1..7                    ! Set of clients

  AVAIL: array(CLIENTS) of integer  ! Number of lots per client
  SIZE: array(CLIENTS) of integer   ! Lot sizes
  PRICE: array(CLIENTS) of integer  ! Prices charged to clients
  COST: array(CLIENTS) of integer   ! Cost per client
  PROF: array(CLIENTS) of integer   ! Profit per client
  CAP: integer                      ! Capacity of the ship
 
  loadqty: array(CLIENTS) of mpvar  ! Lots taken from clients
 end-declarations

 initializations from 'd2ship.dat'
  AVAIL SIZE PRICE COST CAP
 end-initializations

 forall(c in CLIENTS) PROF(c):= PRICE(c) - COST(c)*SIZE(c)

 Profit:= sum(c in CLIENTS) PROF(c)*loadqty(c)

! Limit on the capacity of the ship
 sum(c in CLIENTS) SIZE(c)*loadqty(c) <= CAP

! Problem 1: unlimited availability of lots at clients
 maximize(Profit)
 printsol(1)

! Problem 2: limits on availability of lots at clients
 forall(c in CLIENTS) loadqty(c) <= AVAIL(c)

 maximize(Profit)
 printsol(2)

! Problem 3: lots must be integer
 forall(c in CLIENTS) loadqty(c) is_integer

 maximize(Profit)
 printsol(3)
 
!-----------------------------------------------------------------

! Solution printing
 procedure printsol(num:integer)
  writeln("Problem ", num, ": profit: ", getobjval)
  forall(c in CLIENTS) 
   write( if(getsol(loadqty(c))>0 , " " + c + ":" + getsol(loadqty(c)), ""))
  writeln
 end-procedure
 
end-model

Back to examples browserPrevious exampleNext example