FRMPS and RMPS Commands

The FRMPS and RMPS commands are used to read MPS formatted models. The MPS file format is an industry standard format developed by IBM, and is useful for passing models from one solver or platform to another. FRMPS reads an MPS file in free format, while RMPS reads fixed format MPS files.

When LINGO reads an MPS 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

An equivalent MPS file for this model is:

NAME           SAMPLE

OBJSENSE

   MAX

ROWS

 N OBJROW

 L ROW1

 L ROW2

 L ROW3

COLUMNS

   X         ROW3         1.0000000

   X         OBJROW      20.0000000

   X         ROW1         1.0000000

   Y         OBJROW      30.0000000

   Y         ROW2         1.0000000

   Y         ROW3         2.0000000

RHS

   RHS       ROW1        50.0000000

   RHS       ROW2        60.0000000

   RHS       ROW3       120.0000000

ENDATA

As an aside, one thing to notice about the MPS representation is that it is not a very compact method for storing a model.

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

: rmps c:\sample.mps

: 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 MPS format rather than LINGO format, you may use the SMPS command.

When it comes to acceptable constraint and variable names, MPS format is less restrictive than LINGO. MPS allows for embedded blanks and other additional characters in names. To compensate for this fact, LINGO attempts to patch names when reading an MPS 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 encountered during MPS I/O. 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, you will need to use the SET command as follows:

: SET RCMPSN 1

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

: SET RCMPSN 0

As an example, we will once again read the same MPS 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

 

: rmps c:\sample.mps

: 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 MPS 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.