Initializing help system before first use

Basic LP tasks: problem statement and solving; solution analysis


Type: Production planning
Rating: 1 (simple)
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.
File(s): chess.mos, chess2.mos


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

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

model Chess2                      ! Start a new model

uses "mmxprs"                     ! Load the optimizer library

declarations
 Allvars: set of mpvar            ! Set of all variables
 DescrV: array(Allvars) of string ! Descriptions of variables
 xs: mpvar                        ! Number of small chess sets to make
 xl: mpvar                        ! Number of large chess sets to make
 Allctrs: set of linctr           ! Set of all constraints
 DescrC: array(Allctrs) of string ! Descriptions of constraints
 Profit,mc_time,wood: linctr      ! Declaration of constraints: optional
end-declarations

! Define the variable and constraint descriptions. Since the arrays and 
! the indexing sets are dynamic they grow with each new variable 
! description added:
 DescrV(xs):= " Number of small chess sets"
 DescrV(xl):= " Number of large chess sets"

 DescrC(mc_time):= " Limit on available machine time"
 DescrC(wood):= " Limit on available wood"
 
 Profit:= 5*xs + 20*xl            ! Define the objective function

 mc_time:= 3*xs + 2*xl <= 400     ! Limit on available machine time
 wood:=      xs + 3*xl <= 200     ! Limit on available wood
  
 maximize(Profit)                 ! Solve the LP-problem

                                  ! Print out the solution
 writeln("Solution:\n Objective: ", getobjval)
 writeln(DescrV(xs), ":",xs.sol, ",", DescrV(xl), ":", xl.sol)
 writeln(" Constraint activity:")
 writeln(DescrC(mc_time), ":", mc_time.act, ",",
   DescrC(wood), ":", wood.act)

end-model

© 2001-2020 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.