MPS XLI (xli_MPS)

lp_solve supports the MPS format natively via API calls read_mps, read_freemps, read_MPS, read_freeMPS, write_mps, write_freemps, write_MPS, write_freeMPS, MPS_writefileex, read_basis, write_basis

This accoring to the following MPS format

Two issues are addressed in above document:

Objective constant

The objective can have a constant. This optional constant is specified in the RHS section. There are 2 interpretations of this constant. Some solvers see this as the constant that would be really in the RHS and when brought into the objective (LHS), it is negated. Other solvers, as lp_solve natively does, use the specified value in the MPS file as the value for the objective and don't negate it.
This XLI allows lp_solve to interprete the constant as the other solvers do, ie negate it.
This via the option -negobjconst

Integer/binary variables

A mixed integer program requires the specification of which variables are required to be integer. Markers are used to indicate the start and end of a group of integer variables. The start marker has its name in field 2, 'MARKER' in field 3, and 'INTORG' in field 5. The end marker has its name in field 2, 'MARKER' in field 3, and 'INTEND' in field 5. These markers are placed in the COLUMNS section. When there are BOUNDS on the variables, then these are used as lower and upper bound of these integer variables and there is no confusion possible. Even a lower bound of 0 is already enough. In that case, if there is no upper bound, infinite is used. However there is an interpretation problem if there are no bounds at all on these variables. Some solvers then use 0 as lower bound and 1 as upper bound. So the variables are treated as binary variables. That is the original IBM interpretation. Other solvers, like lp_solve by default, use the default bounds on variables in that case. That is 0 as lower bound and infinite as upper bound. When lp_solve writes an MPS file, it will write the default lower bound of 0 if there are no lower/upper bounds set on the variable. As such, there is no confusion. However when lp_solve reads an MPS file and there are no bounds on variables between INTORG/INTEND, by default it interpretes the variables as integer and not binary as some other solvers do. That could result in another solution than expected.
This XLI allows lp_solve to interprete these integer variables as binary as in the original ibm specification.
This via the option -ibm

Free format

This XLI also supports the free format via the option -free

Basis

read_basis and write_basis allow to read and write a basis in MPS format as described in MPS bas file format. This XLI also allows to read and write a basis in this format. This via the option -bas. This can be combined with option -free to read/write in a free format.

Reading and writing the basis with this XLI is a bit awkward. This because these operations must be done at a different moment than reading and writing of a model file.

Reading the basis must be done after reading the model, but before solve. The read routine of the XLI cannot be used for reading the basis because reading creates a new lp structure. Therefore, the write function of the XLI is (mis)used. With the lp_solve command line program, this can be done as follows:

lp_solve lpfile -wxli xli_MPS.dll basfile -wxliopt "-free"

Writing the basis must be done after solve. Therefore, the write function of the XLI is again used, but now with the results parameter on TRUE as if the results of a model must be written. This is also a bit of a misuse of the XLI, but it must be done to be sure that it is done after solve. With the lp_solve command line program, this can be done as follows:

lp_solve lpfile -wxlisol xli_MPS.dll basfile -wxlisolopt "-free"

Options summary

  -free          Read/write in free format.
  -ibm           Interprete integer variables as in the original ibm specifications
  -negobjconst   Negate the objective constant.
  -bas           Read/write a basis file