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

Further explanation of this example: 'Mosel Library Reference .NET doc'

mmexinfocs.zip[download all files]

Source Files

Data Files





mmexlib.cs

/********************************************************/
/*  Mosel Library Examples                              */
/*  ======================                              */
/*                                                      */
/*  file mmexlib.cs                                     */
/*  ```````````````                                     */
/*  Example for the use of the Mosel libraries          */
/*  (working with models and accessing the dynamic      */
/*  libraries loaded by Mosel)                          */
/*                                                      */
/*  (c) 2008 Fair Isaac Corporation                     */
/*      author: J.Farmer / S. Heipcke                   */
/********************************************************/

using System;
using Mosel;

namespace mmexlib {
  public class mmexlibClass {
    /// <summary>
    /// Main entry point for the application
    /// </summary>
    [STAThread]
    static void Main(string[] args)
    {
      XPRM mosel;
      XPRMModel[] mods = new XPRMModel[3];

      // Initialise Mosel
      mosel = XPRM.Init();
      // Load the BIM files
      mods[0] = mosel.LoadModel("Models/burglari.bim");
      mods[1] = mosel.LoadModel("Models/chess2.bim");
      mods[2] = mosel.LoadModel("Models/trans.bim");
      Console.WriteLine("Models loaded");

      // Display basic information about the models
      foreach (XPRMModel m in mods) {
        Console.WriteLine(
          "  {0}: {1} ({2}, `{3}' size:{4})",
          m.Number,
          m.Name,
          m.SysComment,
          m.UserComment,
          m.Size
        );
      }
      Console.WriteLine();

      // Enumerate all loaded modules and display information
      Console.WriteLine("Additional libraries loaded:");
      foreach (XPRMModule mo in mosel.Modules) {
        Console.WriteLine(
          "  {0} (version {1}) used by {2} model(s)",
          mo.Name,
          mo.Version,
          mo.NumberOfReferences
        );
      }
    }

  }
}


Back to examples browserPrevious exampleNext example