Page 1 of 1

Convert Gams files to *.mpi or *.mps

Posted: Wed Apr 12, 2017 4:09 pm
by Masood
Hi,
Does anybody know how to convert the Gams file to *.mpi or *.mps? I have already studied the given information in this webpage: https://www.gams.com/latest/docs/solver ... index.html, but I found the information very confusing. I would be appreciate if anybody could provide me with some clear information about converting Gams files.

Thanks in advance,
Masood

Re: Convert Gams files to *.mpi or *.mps

Posted: Wed Apr 12, 2017 4:19 pm
by Fred
Hi Masood,

The example below is based on the well known transportation problem from the GAMS model library (https://www.gams.com/latest/gamslib_ml/ ... sport.html) and illustrates how to create an MPS file using Convert.

Code: Select all

  Sets
       i   canning plants   / seattle, san-diego /
       j   markets          / new-york, chicago, topeka / ;

  Parameters

       a(i)  capacity of plant i in cases
         /    seattle     350
              san-diego   600  /

       b(j)  demand at market j in cases
         /    new-york    325
              chicago     300
              topeka      275  / ;

  Table d(i,j)  distance in thousands of miles
                    new-york       chicago      topeka
      seattle          2.5           1.7          1.8
      san-diego        2.5           1.8          1.4  ;

  Scalar f  freight in dollars per case per thousand miles  /90/ ;

  Parameter c(i,j)  transport cost in thousands of dollars per case ;

            c(i,j) = f * d(i,j) / 1000 ;

  Variables
       x(i,j)  shipment quantities in cases
       z       total transportation costs in thousands of dollars ;

  Positive Variable x ;

  Equations
       cost        define objective function
       supply(i)   observe supply limit at plant i
       demand(j)   satisfy demand at market j ;

  cost ..        z  =e=  sum((i,j), c(i,j)*x(i,j)) ;

  supply(i) ..   sum(j, x(i,j))  =l=  a(i) ;

  demand(j) ..   sum(i, x(i,j))  =g=  b(j) ;

  Model transport /all/ ;

*** Modifications
* choose convert as solver
option lp = convert;
* write convert option file
$echo fixedMPS transport.mps > convert.opt
* instruct convert to look for a solver option file
transport.optfile = 1;

  Solve transport using lp minimizing z ;
I hope this helps!

Fred

Re: Convert Gams files to *.mpi or *.mps

Posted: Wed Apr 12, 2017 5:33 pm
by Masood
Hi Ferd,
I am really appreciate your help. I was looking for this piece of code for a couple of weeks. You made my day!!
Thanks again,
Masood

Re: Convert Gams files to *.mpi or *.mps

Posted: Fri Apr 28, 2017 4:49 pm
by Masood
Thank you yanzhiping!
Would you please let me know more about "cplex.o98" and "transport.optfile = 98"? Why we need to have "98" and "o98" instead of "1" and "opt"?

Re: Convert Gams files to *.mpi or *.mps

Posted: Wed Oct 21, 2020 9:45 am
by GraceM
Hi,

Could someone please assist me in converting a gams file to JuMP .jl format? I had used the solution answer as a guideline but it is not working. It is giving the error that JuMP is unknown yet gams convert tool does allow for conversion to this format.

Your assistance will be highly appreciated

Grace


Model transport / all /;

**modifications
option lp=convert;
$echo jump transport.jl > convert.opt
transport.optfile = 1;
solve transport using lp minimizing z;

Re: Convert Gams files to *.mpi or *.mps

Posted: Thu Oct 22, 2020 5:56 pm
by dirkse
Grace,

If you include the .log file from the run you'd make it easier to help you.

I can only guess now: perhaps you are not using the most recent GAMS version. The Jump output from convert is a fairly new feature.

-Steve