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

Introductory examples

Description
Problem name and type, featuresDifficulty
approx Approximation: Piecewise linear approximation **
SOS-2, Special Ordered Sets, piecewise linear approximation of a nonlinear function, pwlin
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, pwlin
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'

mosel_app_intro.zip[download all files]

Source Files

Data Files





chess2.mos

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

   file chess2.mos
   ```````````````
   Production of chess boards   
  
   A small company manufactures two different sizes of boxwood
   chess sets. The small set requires 3 lathehours and 1 kg 
   of boxwood. The large set requires 2 lathehours and 3 kg 
   of boxwood. There are 160 lathe-hours and 200 kg available  
   per week. Each large (resp. small) chess set produced and 
   sold yields a profit of $20 (resp. $5). How many sets of 
   each kind should be made each week to maximize total profit?
  
   Analyzing the problem solution further, 'getact' returns 
   the constraint activities, 'getdual' their dual values 
   (shadow prices), and 'getrcost' returns the reduced costs 
   of the decision variables.

   (c) 2008 Fair Isaac Corporation
       author: R.C. Daniel, Jul. 2002
*******************************************************!)

model "Chess 2"
 uses "mmxprs"
 
 declarations
  xs, xl: mpvar                   ! Decision variables: produced quantities
 end-declarations

 Profit:=  5*xs + 20*xl           ! Objective function
 Boxwood:= 1*xs + 3*xl <=  200    ! kg of boxwood
 Lathe:=   3*xs + 2*xl <=  160    ! Lathehours
 
 maximize(Profit)                 ! Solve the problem

 writeln("LP Solution:")          ! Solution printing
 writeln(" Objective: ", getobjval)
 writeln("Make ", getsol(xs), " small sets")
 writeln("Make ", getsol(xl), " large sets")

 writeln("Activities/Dual Values")
 writeln(" Lathe: ", getact(Lathe)," / ", getdual(Lathe))
 writeln(" Boxwood: ", getact(Boxwood)," / ", getdual(Boxwood))

 writeln("Reduced Costs")
 writeln(" xs: ", getrcost(xs))
 writeln(" xl: ", getrcost(xl))
end-model

Back to examples browserNext example