RLPF Command

The RLPF command is used to read LP formatted models. The LP file format is an industry standard, and is useful for passing models from one solver or platform to another.

When LINGO reads an LP format 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 LP format file for this model is:

\ LP format example

Maximize

 objrow: 20x + 30y

Subject To

 row1: x <= 50

 row2: y <= 60

 row3: x + 2y <= 120

End

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

: rlpf c:\sample.lp

: look all

 

MODEL:

MAX= 20 * X + 30 * Y;

[ROW1] X <= 50;

[ROW2] Y <= 60;

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

END

 

:

Note: Unlike with MPS and MPI formats, LINGO does not currently support exporting/saving files in LP format.

When it comes to acceptable constraint and variable names, LP format is less restrictive than LINGO.  To compensate for this fact, LINGO attempts to patch names when reading an LP 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 the 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 names in an LP format file. To cancel the use of RC names, type:

: SET RCMPSN 0

As an example, we will once again read the same LP format 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.lp

: 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 LP format 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.