GAMS/Convert 4.0 User Notes

advertisement
GAMS/Convert 4.0 User Notes
CONVERT developed by GAMS Corporation transforms a GAMS model
instance into a format used by other modeling and solutions systems.
CONVERT is designed to achieve three aims:
Permit users of GAMS to convert a confidential model into a GAMS
solvable scalar form with very little identifying its structure so it can
be given to a group for numerical investigation (i.e to have someone
else help with a solution problem while maintaining confidentiality).
Give a path to solving with other solvers that may not be available in
GAMS to test performance.
Give a way of sharing test problems.
Table of Contents
Translation Capabilities .............................................................................. 2
Scalar Model ............................................................................................... 2
GAMS usage............................................................................................... 3
GAMS code modification....................................................................... 3
Solver Options ........................................................................................ 4
Option file choice of output format and file names............................ 4
ALL................................................................................................. 4
AMPL ............................................................................................. 4
BARON .......................................................................................... 4
CPLEXMPS.................................................................................... 5
CPLEXLP ....................................................................................... 5
GAMS ............................................................................................. 5
LINGO ............................................................................................ 6
LGO ................................................................................................ 6
LGOIN ............................................................................................ 6
MINOPT ......................................................................................... 7
Output control option file choices ...................................................... 7
FILELIST........................................................................................ 7
HELP............................................................................................... 8
MEMO ............................................................................................ 8
Other option file choices..................................................................... 8
GmsInsert........................................................................................ 8
NlUgly ............................................................................................ 9
Match .............................................................................................. 9
ObjVar ............................................................................................ 9
Reform ............................................................................................ 9
Terminate ........................................................................................ 9
Examples..................................................................................................... 9
Translation Capabilities
Currently, CONVERT can translate GAMS models into the following
formats:
AMPL
BARON
CPLEXLP
CPLEXMPS
GAMS
LGO
LINGO
MINOPT
Models of the types LP, MIP, RMIP, NLP, MCP, MPEC, CNS, DNLP,
RMINLP and MINLP can be converted.
Scalar Model
The translator creates a "scalar model" which consists of
A model without sets or indexed parameters in the scalar models, that
is does not exploit the more advanced characteristics of any modeling
system and is easily transformable.
A model with a new set of individual variables depicting each variable
in the GAMS model ending up with potentially 3 variable classes for
the positive, integer, and binary variables each numbered sequentially
(i.e. all positive GAMS variables are mapped into n single variables
X1 - Xn thus if we have transport(i,j) and manufacture(k) we would
have a set of unindexed scalar variables X1, X2, ... with i*j+k cases.).
A model with individual equations depicting each variable in the
GAMS model (ie all GAMS equations are mapped into m constraints
E1, E2, ... Em thus if we have demand(j) and resources(r,k) we would
have a new equations E1, E2,... with j+r*k cases).
The symbolic form of these equations.
Bounds and starting point values.
A solve statement for the defined model.
GAMS usage
The use of Convert involves two needed modifications in the GAMS code
and a needed input file.
GAMS code modification
For Convert to run, one must specify it as the solver for the model type to be
converted. As a consequence one would include the command
option lp=convert;
if an LP model type was to be subjected to the convert process. This would
appear immediately before the solve statement. Convert can handle the
model types LP, MIP, RMIP, NLP, MCP, MPEC, CNS, DNLP, RMINLP
and MINLP.
Also in order to specify the target output format one must use an options file.
This is invoked ordinarily by entering the statement
modelname.optfile=1
where modelname is the name of the model used in the Solve and Model
statements. This can also be specified through GAMS customization
procedures or a command line entry as explained in the Customization and
Command line chapters of GAMS User Guide 2002. The name of the
option file is convert.opt although other names can be employed as
explained in the Option file chapter of GAMS User Guide 2002.
Solver Options
The Convert options file contains three fundamental types of content.
The first type identifies the one or more target output formats to which
to convert the model within the solve statement being executed.
The second type involves output choices.
The third involves a group of miscellaneous option items that control
translation procedures.
Note when an option file is absent Convert will automatically transform the
model to a GAMS input file in scalar format.
Option file choice of output format and file names
The main keywords in the option file choose the output format. Note while
we discuss these one at a time, more than one can be created.
ALL
Results in the transformation of the model into all the input formats listed
below. Default file names will be used.
AMPL
Results in the transformation of the model into the input format required for
the AMPL modeling system developed at Bell Laboratories. A discussion of
AMPL appears on http://www.ampl.com/cm/cs/what/ampl/.
The general form of the option file entry in this case is
AMPL
or
AMPL
filename
By default the AMPL output is placed on the file AMPL.mod but the user
can redirect that output by entering a file name.
BARON
Results in the transformation of the model into the input format required for
the BARON solver developed by N. Sahinidis and associates at the
University of Illinois- Urbana-Champaign. A discussion of BARON appears
on http://archimedes.scs.uiuc.edu/BARON/manuse.pdf and a more general
discussion of the whole area appears on
http://www.GAMSworld.org/global/index.htm.
The general form of the option file entry in this case is
BARON
or
BARON
filename
By default the BARON output is placed on the file GAMS.bar but the user
can redirect that output by entering a file name.
CPLEXMPS
CPLEXLP
Results in the transformation of the file into one of two input formats
required for the CPLEX modeling system developed by ILOG
(http://www.ilog.com/products/cplex/). The CPLEXMPS option creates a
MPS formatted input file. The CPLEXLP option creates a CPLEX LP
format file. Differences in these files is contrasted on
http://www.ilog.com/products/cplex/product/represent.cfm#filerep
The general form of the option file entry in this case is
CPLEXMPS
or
CPLEXMPS
filename
or
CPLEXLP
or
CPLEXLP
filename
By default the CPLEXMPS output is placed on the file CPLEX.mps and the
CPLEXLP output is placed on the file CPLEX.lp but the user can redirect
that output by entering file names.
GAMS
Results in the transformation of the model into a scalar version of the GAMS
model.
The general form of the option file entry in this case is
GAMS
or
GAMS
filename
By default the GAMS output is placed on the file GAMS.gms but the user
can redirect that output by entering a file name.
LINGO
Results in the transformation of the file into the input format required for the
LINGO modeling system developed by LINDO Systems. A discussion of
LINGO is on
http://www.lindo.com/cgi/frameset.cgi?leftLINGO.html;LINGOf.html.
The general form of the option file entry in this case is
LINGO
or
LINGO
filename
By default the LINGO output is placed on the file LINGO.lng but the user
can redirect that output by entering a file name.
LGO
LGOIN
Results in the transformation of the file into one of two input formats
required for the LGO modeling system developed by Pintér of Pintér
Consulting Services (PCS), and Dalhousie University. A discussion of LGO
is on http://is.dal.ca/~jdpinter/lgoide.htm. The LGO option creates a
Fortran subroutine. The LGOIN call creates an input file that is used by the
Fortran subroutine.
The general form of the option file entry in this case is
LGO
or
LGO
filename
or
LGOIN
or
LGOIN filename
By default the LGO output is placed on the file LGOF.for and the LGOIN
output is placed on the file LGO.in but the user can redirect that output by
entering file names.
MINOPT
Results in the transformation of the model into the input format required for
the MINOPT modeling system developed by Schweiger and Floudas at
Princeton University. A discussion of MINOPT is on
http://titan.princeton.edu/MINOPT/.
The general form of the option file entry in this case is
MINOPT
or
MINOPT
filename
By default the MINOPT output is placed on the file MINOPT.dat but the
user can redirect that output by entering a file name.
Output control option file choices
FILELIST
Causes a file to be generated that summarizes the files written by this run of
Convert. This is invoked with either the
FILELIST
or
FILELIST
filename
By default the output is placed on the file files.txt but the user can redirect
that output by entering a file name.
HELP
Causes the Log and Lst files to contain a list of all applicable options in
Convert. This is invoked with
HELP
MEMO
Causes a file to be generated that warnings and errors encountered during
run of Convert. This is invoked with either the
MEMO
or
MEMO
filename
By default the output is placed on the file memo.txt but the user can redirect
that output by entering a file name.
Other option file choices
These options are for internal use and debugging only and should not come
out with the “help” option.
GmsInsert
This option causes some user defined text to be placed before the solve in
the transformed text. This is invoked using
GmsInsert
or
GmsInsert
text
If text is not specified the default “$if NOT '%gams.u1%' == ''
$include '%gams.u1%'” is places. This allows to specify an include
file which e.g. contains a basis for the model (created by GAMSBAS). The
actual name of the include file is passed on through the user1 option:
GAMS myfile user1="mybasis.bas"
NlUgly
NlUgly doesn't fold certain NL expressions and maintains the order of
internal NL instructions but leaves ugly NL code.
Match
When converting an MCP or MPEC into AMPL format, GAMS provides a
complete variable/equation matching for identification of the complementary
relationships.
ObjVar
Causes a rename of the GAMS objective variable to be newname or objvar if
newname is not specified. This is invoked using
ObjVar
or
ObjVar
newname
Reform
AMPL and BARON require use of an objective function. To do this
Convert uses the objective variable defining equation as an objective
function if possible. Setting reform to 0 will introduce a dummy objective
function (min/max objvar).
Terminate
Terminate cause GAMS to terminate the entire GAMS job after making the
problem conversion.
Examples
convert.gms , convert.opt
We took the GAMS model library trnsport.gms model and subjected it to a
conversion calling it convert.gms. The source file portion around the solve
is
Model transport /all/ ;
option lp=convert;
transport.optfile=1;
file optionf /convert.opt/;
put optionf;
put 'help' /
put 'gams transportconv.gms' /
put 'ampl transportconv.apl' /
put 'baron transportconv.bar' /
put 'memo transportconv.txt' /
put 'filelist transportconvf.txt' /
putclose;
Solve transport using lp minimizing z ;
where the blue portion invokes the Convert solver and indicates the presence
of an option file. The red portion writes the option file that is called
convert.opt amd contains
help
gams transportconv.gms
ampl transportconv.apl
baron transportconv.bar
memo transportconv.txt
filelist transportconvf.txt
where filenames are explicitly defined for each output item. In turn the
GMS model that results (slightly reformatted to use less space) is
*
*
*
*
*
*
*
*
*
*
*
*
*
LP written by GAMS Convert at 03/05/02 06:41:59
Equation counts
Total
E
G
L
N
X
6
1
3
2
0
0
Variable counts
x
b
i
s1s
s2s
Total
cont binary integer
sos1
sos2
7
7
0
0
0
0
FX
0
0
0
0
0
0
Nonzero counts
Total
const
NL
DLL
19
19
0
0
Solve m using LP minimizing x7;
sc
scont
0
0
si
sint
0
0
Variables x1,x2,x3,x4,x5,x6,x7;
Positive Variables x1,x2,x3,x4,x5,x6;
Equations e1,e2,e3,e4,e5,e6;
e1.. - 0.225*x1 - 0.153*x2 - 0.162*x3 - 0.225*x4 - 0.162*x5 - 0.126*x6 + x7
=E= 0;
e2..
x1 + x2 + x3 =L= 350;
e3..
x4 + x5 + x6 =L= 600;
e4..
x1 + x4 =G= 325;
e5..
x2 + x5 =G= 300;
e6..
x3 + x6 =G= 275;
* set non default bounds
* set non default levels
* set non default marginals
Model m / all /;
m.limrow=0; m.limcol=0;
Solve m using LP minimizing x7;
where the red portion is the report from the conversion.
The AMPL output is similar and the model input part is (we suppress the
comment part)
var x1 >= 0;
var x2 >= 0;
var x3 >= 0;
var x4 >= 0;
var x5 >= 0;
var x6 >= 0;
minimize obj:
subject to
e2:
x1 +
e3:
x4 +
e4:
x1 +
e5:
x2 +
e6:
x3 +
x2
x5
x4
x5
x6
0.225*x1 + 0.153*x2 + 0.162*x3 + 0.225*x4 +
0.162*x5 + 0.126*x6;
+ x3 <= 350;
+ x6 <= 600;
>= 325;
>= 300;
>= 275;
we do not present the Baron input or demonstrate the others. Further
examples and discussion are accessible through
http://www.gamsworld.org/translate.htm.
The option file also causes a file list to be written containing the following
transportconv.txt
transportconv.bar
transportconv.apl
transportconv.gms
and a memo on procedure results
LP written by GAMS Convert at 03/05/02 06:41:59
Equation counts
Total
E
6
1
Variable counts
x
Total
cont
7
7
FX
0
0
Nonzero counts
Total
const
19
19
Baron
G
3
L
2
N
0
X
0
b
i
binary integer
0
0
0
0
s1s
sos1
0
0
s2s
sos2
0
0
NL
0
DLL
0
: transportconv.bar
sc
scont
0
0
si
sint
0
0
Ampl
Gams
: transportconv.apl
: transportconv.gms
Download