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.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
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 System.IO;
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();
      // Set Mosel work directory to folder containing our example source code
      mosel.WorkDir = Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location).FullName;
      // Load the BIM files
      mods[0] = mosel.CompileAndLoad("Models/burglari.mos");
      mods[1] = mosel.CompileAndLoad("Models/chess2.mos");
      mods[2] = mosel.CompileAndLoad("Models/trans.mos");
      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