Tuesday, October 18, 2011

MPS files

Yesterday we found out that Microsoft Solver Foundation is writing incorrect MPS files when the model has general integer variables without an upper bound. See: http://social.msdn.microsoft.com/Forums/en-US/solverfoundation/thread/7669081f-18ac-445b-850e-434bff80da38.

Right after I submitted an error report, the following e-mail arrived:

I trying to convert one problem on gmpl format to free mps format, both in attached, and the solve it.
Unfortunately, when solve the mps file I get an answer different from the answer that I get when solve using the gmpl file.

I was using the following commands:
$ glpsol --math exemp01.mod
$ glpsol --math exemp01.mod --check --wfreemps exemp01.mps
$ glpsol --freemps exemp01.mps

See: http://lists.gnu.org/archive/html/help-glpk/2011-10/msg00049.html

Lo and behold, this is exactly the same problem!

The problem is shown in the following MPS file (generated by Cplex, comments added by me):

NAME          gamsmodel
ROWS
N  obj
E  e1
L  e2
COLUMNS
    MARK0000  'MARKER'                 'INTORG'
    x         obj                            -1
    x         e2                              1
    MARK0001  'MARKER'                 'INTEND'
    z         obj                            -1
    z         e1                              1
RHS
    rhs       e2                            200
BOUNDS
* column x is a general integer variable
* it needs an LI card to make sure it is not
* interpreted as a binary variable
LI bnd       x         0
FR bnd       z
ENDATA

This LI card is missing from the GLPSOL and Solver Foundation generated files. The rule is: if no bounds are specified, an integer variable has default bounds 0 and 1. Obviously this will change the meaning of the model.

Note: In GAMS by default all integer variables have a finite upper bound, so no problem there. It is possible (with some effort) to create a model with +INF bounds on integer variables (using PF4=0 command line option). It turns out that with such a model, the tool CONVERT (this tool can write MPS files), produces an MPS file with the same error. Admittedly somewhat contrived, but not correct anyway.

2 comments:

  1. Have you checked translation of a constant in the objective too?
    lp_solve and I think glpsol
    do not change the sign for something like
    min: 10 + X ;
    to mps.
    But Coin clp ( presumably IBM standard )
    expects the constant as -10 in the mps file to give a matching objective value of the solution.
    lp_solve dealt with this in 5.5.0.15 (2009) with new options.

    - Changed the second parameter to read_mps, read_MPS, read_freemps and
    read_freeMPS from verbose to options.
    These routines now supports via this options parameter the native IBM
    interpretation of
    integer variables and allows to negate the objective constant.
    This is also supported by the lp_solve command line program via the -mps_ibm
    and -mps_negobjconst options.
    This is also supported by the IDE in the options tab.

    ReplyDelete
  2. No, I have not looked into that. MPS files have no standard facilities for maximization and for a constant term in the obj; these are well-known issues.

    I think the situation I described is somewhat different: there we see incorrect MPS files being generated.

    ReplyDelete