Tuesday, July 1, 2008

Converting MathProg (and AMPL) models to GAMS

The tool glpk2gams can convert models written in MathProg (subset of AMPL) so we can quickly assess how GAMS solvers perform on such a model.

If the model only has a .mod file, you can just use a single argument:

D:\glpk\glpk2gams\Debug>glpk2gams.exe diet.mod
Glpk Model filename: diet.mod
Gams filename: diet.gms

Reading model section from diet.mod...
Reading data section from diet.mod...
99 lines were read
Generating nb...
Generating cost...
Model has been successfully generated

Rows : 10 Columns : 20 Nonzero elements : 179
Writing diet.gms

D:\glpk\glpk2gams\Debug>



If the model also has a .dat file, you need to give all three command line arguments:

L:\glpk>glpk2gams egypt2.mod egypt2.gms egypt2.dat
Glpk Model filename: egypt2.mod
Gams filename: egypt2.gms
Data filename: egypt2.dat

Reading model section from egypt2.mod...
egypt2.mod:264: warning: unexpected end of file; missing end statement inserted
264 lines were read
Reading data section from egypt2.dat...
egypt2.dat:276: warning: unexpected end of file; missing end statement inserted
276 lines were read
Generating Psi...
Generating mbd...
Generating mbdb...
Generating mb...
Generating cc...
Generating ap...
Generating al...
Generating ai...
Model has been successfully generated

Rows : 285 Columns : 351 Nonzero elements : 1336
Writing egypt2.gms

L:\glpk>


It is generating scalar GAMS code, so this is not suited to convert models that have to be maintained in GAMS.

2 comments:

  1. Is glpk2gams part of the gams distribution? I didn't see one in mine. It does not seem to be part of glpk either. Is it a third party software? Where do I get it?
    Thanks,

    ReplyDelete
  2. This tool is not available publicly.

    ReplyDelete