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

Working with models and accessing dynamic libraries in Mosel

Description
ExLib.vb: 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
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
Note that these examples require the provided mos files to be pre-compiled.

These .vb files can be run from the VB.NET project Mosel-VB.NET.vbproj (required auxiliary files: AssemblyInfo.vb, frmMain.vb, frmMain.resx, OptimizerLog.vb).

mmexinfovb.zip[download all files]

Source Files

Data Files





ExLib.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
        ' Load the BIM files
        models(0) = mosel.LoadModel("Models/burglari.bim")
        models(1) = mosel.LoadModel("Models/chess2.bim")
        models(2) = mosel.LoadModel("Models/trans.bim")
        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

Back to examples browserPrevious exampleNext example