Sunday, June 22, 2008

LPsolve to GAMS conversion

Some clients want to see how GAMS LP/MIP solvers perform vis-a-vis LPsolve. To this effect I created a small tool to convert LPsolve models to GAMS. Then you can run the GAMS model against any of the LP/MIP solvers available with GAMS.

An example of use is reproduced below:
D:\lpsolve\LP_SOL~1.11_>type lp.lp
max: -x1 + 2 x2;
C1: 2x1 + x2 < 5;
-4 x1 + 4 x2 <5;

int x2,x1;


D:\lpsolve\LP_SOL~1.11_>lp2gams lp.lp
lp2gams.exe version 1.0
Erwin Kalvelagen, erwin@amsterdamoptimization.com

lp_solve version 5.5.0.11
Reading lp.lp
Rows: 2 Columns: 2 Nonzero elements: 4
Writing lp.gms
Done

D:\lpsolve\LP_SOL~1.11_>type lp.gms
* Produced by lp2gams.exe version 1.0
* Erwin Kalvelagen, erwin@amsterdamoptimization.com
*
* Lp file: lp.lp
* Rows: 2 Columns: 2 Nonzero elements: 4

free variable gamsobjvar;
integer variable x1;
integer variable x2;

equation R0;
equation C1;
equation R2;

R0.. gamsobjvar =e= - x1 + 2 * x2;
C1.. + 2 * x1 + x2 =l= 5;
R2.. - 4 * x1 + 4 * x2 =l= 5;

option optcr=0;
model gamsmodel /all/;
solve gamsmodel using mip maximizing gamsobjvar;

D:\lpsolve\LP_SOL~1.11_>

No comments:

Post a Comment