Mosel library examples
This directory contains examples that show how to use the Mosel
model compiler and run time libraries.
|
| C |
|
|
| Compiling a model file into a BIM file: Model compilation
|
| |
|
| Type: |
Programming |
| Rating: |
1 (simple) |
| Description: |
This example shows how to compile a model file into a BIM file using the compiler library. |
| File(s): |
mmexcomp.c |
| Data file(s): |
burglari.mos |
|
|
| Retrieving data from a Mosel model: Accessing sets, arrays, lists, records; retrieving solution information
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
mmexset.c: Using sets in Mosel (requires burglari.bim)
- 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
mmexarr.c: Using arrays in Mosel (requires trans.bim)
- compare index tuples
- retrieve an array by its model name
- get array size and number of dimensions
- get indices of first and last array entries
- get (value of) array entries
- check whether an index tuple lies in the range of an array
mmexas.c: Using arrays with index sets (requires trans.bim)
- get indexing sets of an array
- get array type
- enumerate array entries in usual and transposed order
- enumerate true array entries
mmexlst.c: 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.c: 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.c: Accessing problems and solution information with Mosel
(requires blend2.bim)
- export problem to a file (MPS or LP format)
- get problem status
- get objective function value
- get primal/dual solution values, and constraint activity
Note that these examples require the provided mos files to be pre-compiled.
|
| File(s): |
mmexset.c, mmexarr.c, mmexas.c, mmexlst.c, mmexrec.c, mmexprob.c |
| Data file(s): |
burglari.mos, trans.mos, euler.mos, euler.dat, burglar_rec.mos, burglar_rec.dat, blend2.mos |
|
|
| Working with models and accessing dynamic libraries in Mosel: Display information and contents of models and libraries
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
mmexlib.c: Working with models and accessing dynamic libraries in Mosel
(requires burglari.bim, chess2.bim, trans.bim)
- 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
mmdispmod.c: Display the contents of a model; the information is read from a bim file
- display run-time parameters, requirements, symbols, package/module dependencies, annotations
mmdispdso.c: Display the contents of a module
- display constants, types, control paramters, subroutines, I/O drivers
Note that these examples require the provided mos files to be pre-compiled.
|
| File(s): |
mmexlib.c, mmdispmod.c, mmdispdso.c |
| Data file(s): |
burglari.mos, chess2.mos, trans.mos |
|
|
| Interrupting a running model using Ctrl-C: Stopping a model run
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Demonstrates how to interrupt a running model with Ctrl-C.
The C program requires the mos file to be pre-compiled.
|
| File(s): |
mmexctc.c |
| Data file(s): |
toolong.mos |
|
|
| Data input/output via I/O drivers: Compilation to/from memory; data input/output in memory; redirect output using the 'cb' driver
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
- mmexdrvs.c: 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 C data
and retrieve information from the model
through memory.
- mmexcbdrv.c: Use the 'cb' I/O driver to handle Mosel output and
provide initial data to the model.
|
| File(s): |
mmexdrvs.c, mmexcbdrv.c |
|
|
| Implementing a source coverage testing tool: Using the debugger interface
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
This example program uses the debugger interface to create a source coverage testing
tool: the program executes the given model and reports
whether all statements have been executed and, for each
procedure or function, how many times it has been called.
|
| File(s): |
mmcover.c |
|
|
|
| Java |
|
|
| Retrieving data from a Mosel model: Accessing sets, arrays, lists, records; retrieving solution information
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
mmexset.java: Using sets in Mosel (requires burglari.bim)
- 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.java: Using arrays with index sets (requires trans.bim)
- get indexing sets of an array
- get array type
- enumerate array entries in usual and transposed order
- enumerate true array entries
mmexlst.java: 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.java: 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.java: Accessing problems and solution information with Mosel
(requires blend2.bim)
- export problem to a file (MPS or LP format)
- get problem status
- get objective function value
- get primal/dual solution values, and constraint activity
Note that these examples require the provided mos files to be pre-compiled.
|
| File(s): |
mmexset.java, mmexas.java, mmexlst.java, mmexrec.java, mmexprob.java |
| Data file(s): |
burglari.mos, trans.mos, euler.mos, euler.dat, burglar_rec.mos, burglar_rec.dat, blend2.mos |
|
|
| Working with models and accessing dynamic libraries in Mosel: Display information and contents of models and libraries
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
mmexlib.java: Working with models and accessing dynamic libraries in Mosel
(requires burglari.bim, chess2.bim, trans.bim)
- 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
mmdispmod.java: Display the contents of a model; the information is read from a bim file
- display run-time parameters, requirements, symbols, package/module dependencies, annotations
mmdispdso.java: Display the contents of a module
- display constants, types, control paramters, subroutines, I/O drivers
Note that these examples require the provided mos files to be pre-compiled.
|
| File(s): |
mmexlib.java, mmdispmod.java, mmdispdso.java |
| Data file(s): |
burglari.mos, chess2.mos, trans.mos |
|
|
| Data input/output via I/O drivers: Compilation to/from memory; data input/output in memory; redirect output using the 'java' driver
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
- mmexdrvs.java: 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
Java objects and retrieve information from the model
through memory.
- mmexcbdrv.java: Use the 'java' I/O driver to handle Mosel output and
provide initial data to the model.
|
| File(s): |
mmexdrvs.java, mmexcbdrv.java |
|
|
| Implementing a source coverage testing tool: Using the debugger interface
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
This example program uses the debugger interface to create a source coverage testing
tool: the program executes the given model and reports
whether all statements have been executed and, for each
procedure or function, how many times it has been called.
|
| File(s): |
mmcover.java |
|
|
|
| C# (Windows/Linux only) |
|
|
| Retrieving data from a Mosel model: Accessing sets, arrays, lists, records; retrieving solution information
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| 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
|
| File(s): |
mmexset.cs, mmexset.csproj, mmexas.cs, mmexas.csproj, mmexlst.cs, mmexlst.csproj, mmexrec.cs, mmexrec.csproj, mmexprob.cs, mmexprob.csproj |
| Data file(s): |
burglari.mos, trans.mos, euler.mos, euler.dat, burglar_rec.mos, burglar_rec.dat, blend2.mos |
|
|
| Working with models and accessing dynamic libraries in Mosel: Display information and contents of models and libraries
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
mmexlib-cs: Working with models and accessing dynamic libraries in Mosel
(requires burglari.mos, chess2.mos, trans.mos)
- 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
mmdispmod-cs: Display the contents of a model; the information is read from a bim file
- display run-time parameters, requirements, symbols, package/module dependencies, annotations
mmdispdso-cs: Display the contents of a module
- display constants, types, control paramters, subroutines, I/O drivers
|
| File(s): |
mmexlib.cs, mmexlib.csproj, mmdispmod.cs, mmdispmod.csproj, mmdispdso.cs, mmdispdso.csproj |
| Data file(s): |
burglari.mos, chess2.mos, trans.mos |
|
|
| Data input/output via I/O drivers: Compilation to/from memory; data input/output in memory
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
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.
- mmexdrvs_cbinit-cs: using 'dotnet:' I/O driver for data exchange via callbacks
- mmexdrvs_raw-cs: using 'dotnetraw:' I/O driver for data exchange in memory
- mmexdrvs_stream-cs: using 'dotnet:' I/O driver with streams for data exchange in memory
|
| File(s): |
mmexdrvs_cbinit.cs, mmexdrvs_cbinit.csproj, mmexdrvs_raw.cs, mmexdrvs_raw.csproj, mmexdrvs_stream.cs, mmexdrvs_stream.csproj |
|
|
|
| VB.NET (Windows only) |
|
|
| Working with models, data and dynamic libraries in Mosel: Accessing sets and arrays; retrieving solution information; displaying information and contents of models and libraries; Compilation
to/from memory; data input/output in memory
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| 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).
|
| File(s): |
ExSet.vb, ExAs.vb, ExProb.vb, ExLib.vb, DispMod.vb, DispDso.vb, ExDrvsCallback.vb, ExDrvsRaw.vb, ExDrvsStream.vb, OptimizerLog.vb, frmMain.vb, frmMain.resx, Mosel-VB.NET.vbproj |
| Data file(s): |
burglari.mos, trans.mos, blend2.mos, chess2.mos |
|
|
|
|
|