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

Retrieving data from a Mosel model

Description
mmexset-cs: Using sets in Mosel (requires burglari.mos)
  • retrieve a set by its model name
  • get the set size
  • get first and last set element
  • get the name or index of a set element
mmexas-cs: Using arrays with index sets (requires trans.mos)
  • get indexing sets of an array
  • get array type
  • enumerate array entries in usual and transposed order
  • enumerate true array entries
mmexlst-cs: Using lists in Mosel (requires euler.mos and euler.dat)
  • retrieve a list by its model name
  • get the list size
  • enumerate the list elements
  • get value of list element
mmexrec-cs: Using records in Mosel (requires burglar_rec.mos and burglar_rec.dat)
  • retrieve an array of records (user type) by its model name
  • retrieve the record field information (field name, type, and number)
  • enumerate the array of records
  • for each array entry (record) get the value of all its fields
mmexprob-cs: Accessing problems and solution information with Mosel (requires blend2.mos)
  • export problem to a file (MPS or LP format)
  • get problem status
  • get objective function value
  • get primal/dual solution values, and constraint activity
Further explanation of this example: 'Mosel Library Reference .NET doc'

mmexdatacs.zip[download all files]

Source Files

Data Files





burglari.mos

(!*******************************************************
  * Mosel Example Problems                              *
  * ======================                              *
  *                                                     *
  * file burglari.mos                                   *
  * `````````````````                                   *
  * Example for the use of the Mosel language           *
  * (Burglar problem from the XPRESS-MP Tutorial)       *
  *                                                     *
  * (c) 2008 Fair Isaac Corporation                     *
  *     author: S. Heipcke, 2001                        *
  *******************************************************!)

model 'Burglar Problem' version 1.0.0

public declarations
 ITEMS = {"camera", "necklace", "vase", "picture", "tv", "video",
         "chest", "brick"}
 VALUE: array (ITEMS) of real           ! Value of items
 WEIGHT: array (ITEMS) of real          ! Weight of items
 WTMAX: real                            ! Max weight allowed for haul
 x: array(ITEMS) of mpvar               ! 1 if we take item i; 0 otherwise
end-declarations

 VALUE("camera")  := 15;  WEIGHT("camera")  :=  2
 VALUE("necklace"):=100;  WEIGHT("necklace"):= 20
 VALUE("vase")    := 90;  WEIGHT("vase")    := 20
 VALUE("picture") := 60;  WEIGHT("picture") := 30
 VALUE("tv")      := 40;  WEIGHT("tv")      := 40
 VALUE("video")   := 15;  WEIGHT("video")   := 30
 VALUE("chest")   := 10;  WEIGHT("chest")   := 60
 VALUE("brick")   :=  1;  WEIGHT("brick")   := 10

 WTMAX  := 102

 MaxVal:= sum(i in ITEMS) VALUE(i)*x(i)             ! Maximize the value
 WtMax:=  sum(i in ITEMS) WEIGHT(i)*x(i) <= WTMAX   ! Weight restriction

 forall(i in ITEMS) x(i) is_binary      ! All x are 0/1

end-model

Back to examples browserPrevious exampleNext example