FICO
FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browser

Working with models, data and dynamic libraries in Mosel

Description
ExSet.vb: 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
ExAs.vb: 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
ExProb.vb: 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
ExLib.vb: Working with models and accessing dynamic libraries in Mosel
  • load and unload BIM models
  • run a model in Mosel
  • display information about loaded models
  • display information about additional libraries required by the loaded models
DispMod.vb: Display the contents of a model; the information is read from a bim file
  • display run-time parameters, requirements, symbols, package/module dependencies, annotations
DispDso.vb: Display the contents of a module
  • display constants, types, control paramters, subroutines, I/O drivers
ExDrvs*.cb.: Use I/O drivers to handle Mosel output with a callback function, compile a model from memory to memory, load a bim file from memory, initialise arrays in the Model program from .NET objects and retrieve information from the model through memory.
  • ExDrvsCallback.vb: using 'dotnet:' I/O driver for data exchange via callbacks
  • ExDrvsRaw.vb: using 'dotnetraw:' I/O driver for data exchange in memory
  • ExDrvsStream.vb: using 'dotnetstream:' I/O driver working with streams for data exchange in memory
These .vb files can be run from the VB.NET project Mosel-VB.NET.vbproj (required auxiliary files: frmMain.vb, frmMain.resx, OptimizerLog.vb).

mmexdatavb.zip[download all files]

Source Files

Data Files





blend2.mos

(!*******************************************************
  * Mosel Example Problems                              *
  * ======================                              *
  *                                                     *
  * file blend2.mos                                     *
  * ```````````````                                     *
  * Example for the use of the Mosel language           *
  * (Blending problem from XPRESS-MP User Guide)        *
  *                                                     *
  * Data given in the model.                            *
  *                                                     *
  * (c) 2008 Fair Isaac Corporation                     *
  *     author: S. Heipcke, 2001                        *
  *******************************************************!)

model Blend                    ! Start a new model

uses "mmxprs"                  ! Load the optimizer library

public declarations
 ROres = 1..2                  ! Range of Ores
 REV = 125                     ! Unit revenue of product
 MINGRADE = 4                  ! Min permitted grade of product
 MAXGRADE = 5                  ! Max permitted grade of product
 COST: array(ROres) of real    ! Unit cost of ores
 AVAIL: array(ROres) of real   ! Availability of ores
 GRADE: array(ROres) of real   ! Grade of ores (measured per unit of mass)

 x: array(ROres) of mpvar      ! Quantities of ores used
 LoGrade: linctr
end-declarations

 COST  :: [85.00, 93.00]
 AVAIL :: [60.00, 45.00]
 GRADE :: [2.1, 6.3]
                               ! Objective: maximize total profit
 Profit:= sum(o in ROres) (REV-COST(o))* x(o)  

                               ! Lower and upper bounds on ore quality
 LoGrade:= sum(o in ROres) (GRADE(o)-MINGRADE) * x(o) >= 0
 UpGrade:= sum(o in ROres) (MAXGRADE-GRADE(o)) * x(o) >= 0 

                               ! Set upper bounds on variables
 forall(o in ROres) x(o) <= AVAIL(o)

 maximize(Profit)              ! Solve the LP-problem
end-model

Back to examples browser