FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browserNext example

Introductory examples

Problem name and type, featuresDifficulty
approx Approximation: Piecewise linear approximation **
SOS-2, Special Ordered Sets, piecewise linear approximation of a nonlinear function
burglar MIP modeling: Knapsack problem: 'Burglar' *
simple MIP model with binary variables, data input from text data file, array initialization, numerical indices, string indices, record data structure
chess LP modeling: Production planning: 'Chess' problem *
simple LP model, solution output, primal solution values, slack values, activity values, dual solution values
pricebrai All item discount pricing: Piecewise linear function ***
SOS-1, Special Ordered Sets, piecewise linear function, approximation of non-continuous function, step function
pricebrinc Incremental pricebreaks: Piecewise linear function ***
SOS-2, Special Ordered Sets, piecewise linear function, step function

Further explanation of this example: 'Applications of optimization with Xpress-MP', Introductory examples (Chapters 1 to 5) of the book 'Applications of optimization with Xpress-MP'[download all files]

Source Files

Data Files


   Mosel Example Problems

   file pricebrai.mos
   Modeling price breaks:
   All item discount pricing   

   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Sep. 2006

model "All item discount"
 uses "mmxprs"
  NB = 3                                ! Number of price bands
  BREAKS = 1..NB
  COST: array(BREAKS) of real           ! Cost per unit
  x: array(BREAKS) of mpvar             ! Number of items bought at a price
  b: array(BREAKS) of mpvar             ! Indicators of price bands
  B: array(0..NB) of real               ! Break points of cost function
 DEM:= 150                              ! Demand
 B:: [0, 50, 120, 200]
 COST:: [ 1, 0.7, 0.5]
 forall(i in BREAKS) b(i) is_binary

(! Alternatively
 sum(i in BREAKS) B(i)*b(i) is_sos1

! Objective: total price
 TotalCost:= sum(i in BREAKS) COST(i)*x(i)  

! Meet the demand
 sum(i in BREAKS) x(i) = DEM 

! Lower and upper bounds on quantities
 forall(i in BREAKS) do
  B(i-1)*b(i) <= x(i);  x(i) <= B(i)*b(i)

! The quantity bought lies in exactly one interval
 sum(i in BREAKS) b(i) = 1

! Solve the problem

! Solution printing
 writeln("Objective: ", getobjval, 
         " (price per unit: ", getobjval/DEM, ")")
 forall(i in BREAKS) 
  writeln("x(", i, "): ", getsol(x(i)), " (price per unit: ", COST(i), ")")


Back to examples browserNext example