Initializing help system before first use

# Implementing a specific LP/MIP solver interface

The Mosel Native Interface (NI) defines a set of conventions that make it possible to extend the Mosel language with constants, subroutines, types, I/O drivers, and control parameters. The Mosel NI also publishes a special set of functionality that provides access to the matrix-based representation of optimization problems formulated using the Mosel types mpvar, linctr, mpproblem, that is, LP and MIP problems. These NI functions can be used for implementing interfaces to optimization solvers that are available in the form of a C/C++ library.

A minimal implementation of a solver module needs to do the following:

- Modeling functionality:
  - define subroutines to start an optimization run and retrieve solution values
  - provide access to solver parameters
  - if supported by the solver, provide support for handling multiple problems
- NI functionality:
  - implement a reset and an unload service
  - initialize the module and the required interface structures

## Example

The following Mosel model highlights the modelling features that are provided through the example solver module 'myxprs'.

    model "Problem solving and solution retrieval"
      uses "myxprs"                       ! Load the solver module

      declarations
        x,y: mpvar                        ! Some decision variables
        pb: mpproblem                     ! (Sub)problem
      end-declarations

      procedure printsol
        if getprobstat = MYXP_OPT then
          writeln("Solution: ", getobjval, ";", x.sol, ";", y.sol)
        else
          writeln("No solution found")
        end-if
      end-procedure

      Ctr1:= 3*x + 2*y <= 400
      Ctr2:= x + 3*y <= 310
      MyObj:= 5*x + 20*y

     ! Setting solver parameters
      setparam("myxp_verbose", true)      ! Display solver log
      setparam("myxp_timelimit", 10)      ! Set a time limit

     ! Solve the problem (includes matrix generation)
      maximize(MyObj)

     ! Retrieve a solver parameter
      writeln("Solver status: ", getparam("myxp_lpstatus"))
     ! Access solution information
      printsol

     ! Turn poblem into a MIP
      x is_integer; y is_integer

     ! Solve the modified problem
      maximize(MyObj)
      printsol

     ! **** Define and solve a (sub)problem ****
      with pb do
        3*x + 2*y <= 350
        x + 3*y <= 250
        maximize(5*x + 20*y)
        printsol
      end-do

    end-model

The underlying module implementation (C program) is discussed in detail in Chapter Implementing an LP/MIP solver interface of the Mosel NI User Guide, including some extensions such as the implementation of a solution callback and a matrix export subroutine. The complete source can be retrieved from http://examples.xpress.fico.com. The C program needs to be compiled into the library myxprs.dso using the makefile that is provided along with the Mosel module examples. The resulting DSO file needs to be on the search path for DSO (e.g. by including its location in the environment variable MOSEL_DSO) and the solver libraries have to be accessible and suitably licensed in order to run the example model.

Parent Topic Mosel Solver Interfaces

© 2001-2026 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.