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).
Imports System.IO
Imports Mosel
' Example of working with models and accessing Mosel dynamic libraries
Module ExLib
Public Sub RunExLib(ByVal Log As TextWriter)
Dim mosel As XPRM
Dim models(2) As XPRMModel
' Initialise Mosel
mosel = XPRM.Init
' Set Mosel work directory to folder containing our example source code
mosel.WorkDir = Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly.Location).FullName
' Compile and Load the BIM files
models(0) = mosel.CompileAndLoad("Models/burglari.mos")
models(1) = mosel.CompileAndLoad("Models/chess2.mos")
models(2) = mosel.CompileAndLoad("Models/trans.mos")
Log.WriteLine("Models loaded")
' Display basic information about the models
Dim model As XPRMModel
For Each model In models
Log.WriteLine(" {0}: {1} ({2}, '{3}' size:{4})", _
model.Number, model.Name, model.SysComment, _
model.UserComment, model.Size)
Next
Log.WriteLine()
' Enumerate all loaded modules and display information
Log.WriteLine("Additional libraries loaded:")
Dim mo As XPRMModule
For Each mo In mosel.Modules
Log.WriteLine( _
" {0} (version {1}) used by {2} model(s)", _
mo.Name, mo.Version, mo.NumberOfReferences)
Next
End Sub
End Module