RMPI Command

The RMPI command is used to read MPI (Math Programmming Interface) formatted models.  The MPI file format was developed by LINDO Systems as a portable format for storing arbitrary math programming models.

When LINGO reads an MPI file, it converts the formulation to an equivalent LINGO model.  As an example, consider the following, simple model:

ObjRow) Maximize 20X  + 30Y

Subject To:

  Row1) X < 50

  Row2) Y < 60

  Row3) X + 2Y < 120

The equivalent MPI file for this model is:

BEGINMODEL   SAMPLE      

! Number of Objective Functions:         1

! Number of Constraints        :         3

! Number of Variables          :         2

VARIABLES

!  Name                  Lower Bound        Initial Point          Upper Bound     Type

  X                               0              1.23457               1e+030        C

  Y                               0              1.23457               1e+030        C

OBJECTIVES

 OBJROW     MAXIMIZE

   EP_USRCOD            -101

   EP_PUSH_NUM       20

   EP_PUSH_VAR  X

   EP_MULTIPLY

   EP_PUSH_NUM       30

   EP_PUSH_VAR  Y

   EP_MULTIPLY

   EP_PLUS    

CONSTRAINTS

 ROW1    L        

   EP_USRCOD            -101

   EP_PUSH_VAR  X

   EP_PUSH_NUM       50

   EP_MINUS  

 ROW2    L        

   EP_USRCOD            -101

   EP_PUSH_VAR  Y

   EP_PUSH_NUM       60

   EP_MINUS  

 ROW3    L        

   EP_USRCOD            -101

   EP_PUSH_VAR  X

   EP_PUSH_NUM       2

   EP_PUSH_VAR  Y

   EP_MULTIPLY

   EP_PLUS    

   EP_PUSH_NUM       120

   EP_MINUS  

ENDMODEL

As an aside, one thing to notice about the MPI representation is that it is not a very compact method for storing a model-MPI is designed for portability, as opposed to efficiency.

In the following session, we read this MPI file into LINGO and then display the model with the LOOK command.  Note how the model is automatically converted from MPI format to native LINGO format:

: rmpi c:\sample.mpi

: look all

 

  1] TITLE  SAMPLE;

  2] [OBJROW] MAX = 20 * X + 30 * Y;

  3] [ROW1] X <= 50;

  4] [ROW2] Y <= 60;

  5] [ROW3] X + 2 * Y <= 120;

 

:

Should you wish to save the file again using MPI format rather than LINGO format, you may use the SMPI command.

Note:The MPI file format is intended primarily for exporting models to other applications or platforms.  The MPI format is purely scalar in nature—all set-based information is lost upon converting a LINGO model to MPI format.  Thus, when saving copies of a model on your own machine, you should always use the SAVE command in order to save models in native LINGO format in order to preserve your model in its entirety.

When it comes to acceptable constraint and variable names, MPI format is less restrictive than LINGO.  MPI allows for embedded blanks and other additional characters in names. To compensate for this fact, LINGO attempts to patch names when reading an MPI file so that all the incoming names are compatible with its syntax.  LINGO does this by substituting an underscore for any character in a name that is not admissible. In most cases, this will work out OK.  However, there is a chance for name collisions where two or more names get mapped into one.  For instance, the variable names X.1 and X%1 would both get mapped into the single LINGO name X_1. Of course, situations such as this entirely alter the structure of the model rendering it incorrect.

You will be warned whenever LINGO has to patch a name with the following error message:

[Error Code:  179]

 

The model translator had to patch names to make them compatible:

   var names patched:            1

   row names patched:            0

Name collisions may have occurred.

This message displays the number of variable and row names that were patched to get them to conform to LINGO syntax.

If name collisions are a problem, then LINGO has an option that will ensure that all names remain unique.  This option involves using RC format for names when translating non-native file formats.  RC format involves renaming each row (constraint) in a model to be Rn, where n is the row’s index.  Similarly, each column (variable) is renamed to Cn. In addition, LINGO renames the objective row to be ROBJ.  To switch to RC format for MPS names mode, you will need to use the SET command as follows:

: SET RCMPSN 1

This will cause LINGO to use RC naming conventions for all MPI reads and saves.  To cancel the use of RC names, type:

: SET RCMPSN 0

As an example, we will once again read the same MPI format model we read above, but this time we will switch to RC naming conventions.

: set rcmpsn 1

 

Parameter        Old Value     New Value

  RCMPSN             0             1

 

: rmpi c:\sample.mpi

: look all

 

  1] TITLE  SAMPLE;

  2] [ROBJ] MAX = 20 * C1 + 30 * C2;

  3] [R1] C1 <= 50;

  4] [R2] C2 <= 60;

  5] [R3] C1 + 2 * C2 <= 120;

Notice how the variable names now use RC format, guaranteeing that name collisions will not occur.

Another potential conflict is that MPI allows variable names to be duplicated as constraint names, and vice versa.  LINGO does not allow for this.  When you go to solve the model, you will either receive error message 28 (Invalid use of a row name), or error message 37 (Name already in use).  However, once again, you can switch to using RC format for names to avoid this conflict.