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

Basic LP tasks: problem statement and solving; solution analysis

Description
The first model (file chess.mos) is a small, introductory problem to modeling with Mosel that shows the basic features of the Mosel language:
  • formulation of a simple LP/IP problem
  • solving an optimization problem
  • solution printout
The second model (file chess2.mos) shows some more advanced features of Mosel, namely the data structures set and array:
  • formulating and solving a simple LP problem
  • defining a set of variables and an array of descriptions for the variables (to be used in the output printing)
Detailed solution information for MIP problems as may be required when performing sensitivity analysis, such as dual and reduced cost values (file chessfixg.mos) or ranging information for variables and constraints (file chessrng.mos), is not immediately available during or after the branch-and-bound search. The following procedure needs to be used to generate the sensitivity analysis data:
  1. Solve the MIP problem.
  2. Fix all discrete variables to their solution values.
  3. Re-solve the remaining LP problem.
  4. Retrieve the solution information.
Further explanation of this example: 'Mosel User Guide', Chapter 1 Getting started with Mosel and Section 8.1 Initializing sets, or the book 'Applications of optimization with Xpress-MP', Section 1.3 Solving the chess set problem.


Source Files
By clicking on a file name, a preview is opened at the bottom of this page.
chess.mos[download]
chess2.mos[download]
chessfixg.mos[download]
chessfixgcb.mos[download]
chessrng.mos[download]





chess.mos

(!*******************************************************
  * Mosel Example Problems                              *
  * ======================                              *
  *                                                     *
  * file chess.mos                                      *
  * ``````````````                                      *
  * Example for the use of the Mosel language           *
  * (Small LP-problem)                                  *
  *                                                     *
  * (c) 2008 Fair Isaac Corporation                     *
  *     author: Bob Daniel, 2001                        *
  *******************************************************!)

model Chess
uses  "mmxprs"                   ! we need the optimizer

declarations
 small, large: mpvar             ! the decision variables
end-declarations

 ! Now we have the constraints

 mc_time:=  3*small + 2*large <= 400 ! limit on available machine time
 wood:=       small + 3*large <= 200 ! limit on available wood

 maximize( 5*small + 20*large )      ! solve, defining the objective function

 writeln
 writeln("Here are the LP results")
 writeln("Objective value is ", getobjval)
 writeln("Make ", small.sol, " small sets, and ",
         large.sol, " large sets")

 small is_integer
 large is_integer

 maximize( 5*small + 20*large )      ! solve, defining the objective function

 writeln
 writeln("Here are the IP results")
 writeln("Objective value  is ", getobjval)
 writeln("Make ", small.sol, " small sets, and ",
         large.sol, " large sets")

end-model

Back to examples browserPrevious exampleNext example