Thursday, April 15, 2010

mps –> GAMS

GAMS comes with a tool called mps2gms. With a large MPS file from a client I had some problems using this tool, and I spent some time to make it reproducible with a small example. The problem is related to a ranged equation:

NAME          Error
ROWS
N  obj
G  c1
E  c2
COLUMNS
    x1        obj                  1
    x1        c2                   1
    x2        c1                   1
    x2        c2                   1
RHS
    rhs       c1                  10
RANGES
    range     c1                   2
BOUNDS
FR bnd       x1
ENDATA

This model is like the following:

min x1
x1=−x2
10 ≤ x2 ≤ 12

The resulting GAMS model is complicated to look at with all data inside a GDX file. However when we run it against the CONVERT solver we can see the scalar GAMS version:

*  RMIP written by GAMS Convert at 04/15/10 19:04:26
*
*  Equation counts
*      Total        E        G        L        N        X        C
*          3        3        0        0        0        0        0
*
*  Variable counts
*                   x        b        i      s1s      s2s       sc       si
*      Total     cont   binary  integer     sos1     sos2    scont     sint
*          4        4        0        0        0        0        0        0
*  FX      0        0        0        0        0        0        0        0
*
*  Nonzero counts
*      Total    const       NL      DLL
*          6        6        0        0
*
*  Solve m using RMIP minimizing x1;


Variables  x1,x2,x3,x4;

Positive Variables  x3,x4;

Equations  e1,e2,e3;


e1..    x1 - x2 =E= 0;

e2..    x2 + x3 =E= 0;

e3..    x3 - x4 =E= 0;

* set non default bounds


* set non default levels


* set non default marginals


Model m / all /;

m.limrow=0; m.limcol=0;

Solve m using RMIP minimizing x1;

The constants 10 and 12 are not preserved and have disappeared from the model. I suspect that missing is x4.lo=10 and x4.up=12. (This is somewhat difficult to read as x1 and x4 are added to the model, and the mps columns x1 and x2 are renamed to GAMS variables x2 and x3). I have passed this on to GAMS for investigation so this can be fixed.

There was also another issue related to how the ranges section was read. In the end I used one of my own tools to quickly read in the mps file and write a GAMS file:

C:\projects\xxxxxx>\projects\lpsolve\lp2gams 2.mps
lp2gams.exe version 1.3
Erwin Kalvelagen, erwin@amsterdamoptimization.com

lp_solve version 5.5.0.11
Reading mps file 2.mps
Writing 2.gms
Rows: 5857   Columns: 4235   Nonzero elements: 19228
Done

C:\projects\xxxxx>

Update: the mps2gms issues are fixed for the next release.

1 comment:

  1. Hi,

    I want to create a LP/MPS file to read the file in CPLEX for my large scale supply chain model in GAMS. Is there anyone who can help me the detailed way as to how I can create a LP/MPS file in GAMS.

    Thanks.
    Maruf

    ReplyDelete