GAMS Newsletter No. 15
Bruce McCarl
GAMS 21.3 release
GAMS Corporation has recently released version 21.3 and shortly thereafter an
update for GDX. Version 21.3 expands some language capabilities. Release
notes are on the GAMS web site at http://www.gams.com/docs/release/release.htm#21.3
. New features
within this release are discussed in the last newsletter at http://www.gams.com/mccarl/newsletter/news14.pdf
. The software can be downloaded from http://www.gams.com/download/ but is
only useful if you have a current license file.
Tuples
Often the conditionals required in a model are complex and are used in a
repetitive manner. It is sometimes simpler to establish a tuple that encapsulates the conditionals and only use that tuple instead of the complex set of conditionals. In the
model below the logical condition after the $ below that appears repetitively
can be replaced with the tuple making the model
visually simpler plus potentially easier to maintain.
TCOSTEQ.. TCOST=E=SUM((PLANT,MARKET)$(
supply(plant) and demand(market)
and distance(plant,market))
,SHIPMENTS(PLANT,MARKET)* COST(PLANT,MARKET));
SUPPLYEQ(PLANT).. SUM(MARKET)$( supply(plant) and
demand(market)
and distance(plant,market))
,SHIPMENTS(PLANT, MARKET)) =L= SUPPLY(PLANT);
DEMANDEQ(MARKET).. SUM(PLANT)$( supply(plant) and
demand(market)
and distance(plant,market))
,SHIPMENTS(PLANT, MARKET)) =G= DEMAND(MARKET);
where the alternative with the tuple is
set thistuple(plant,market)
thistuple expressing conditional;
thistuple(plant,market)$(supply(plant)
and demand(market)
and distance(plant,market)) =yes;
TCOSTEQ2.. TCOST =E= SUM(thistuple(plant,market)
,SHIPMENTS(PLANT,MARKET)* COST(PLANT,MARKET));
SUPPLYEQ2(PLANT).. SUM(thistuple(plant,market)
,SHIPMENTS(PLANT, MARKET)) =L= SUPPLY(PLANT);
DEMANDEQ2(MARKET).. SUM(thistuple(plant,market)
,SHIPMENTS(PLANT, MARKET)) =G= DEMAND(MARKET);
More on tuples appears in the McCarl
Users Guide 2003 accessible through the IDE or accessible at http://www.gams.com/dd/docs/bigdocs/gams2002/
in the sets, calculations and conditionals chapters.
OSL
IBM has stopped marketing OSL and with this planned future development and
maintenance. GAMS Development will continue to keep OSL updated to the
extent possible. In addition GAMS has worked out an OSL trade in agreement
permitting migration to CPLEX, MOSEK, XA and XPRESS. For details see http://www.gams.com/solvers/solvers.htm#OSL
.
A new option
A new option command exists which allows one to
rapidly count the number of elements in a particular slice of a
parameter. Suppose we have Q(I,J,K) and want to
know how many elements exist for a set element I across all combinations of the
subscripts J and K. This can be done using the option command
set i /1*3/
j /1*3/
k /1*3/;
Parameter Q(I,J,K) / 1.1.1 1,
1.2.3 3, 2.1.1 4/ ;
Parameter Elementcount(I) ;
option elementcount<
Q ;
display elementcount;
Whereupon the elementcount parameter would contain a
count of the number of nonzero elements in Q associated with each element of
the set I. Similarly one could develop a count of the number of nonzero
entries within Q for each pairing of the elements J and K across all values of
the subscript I. by inserting
Parameter Elcount(J,K) ;
option elcount< Q ;
display elcount
File casing
Some users work on machines where the casing of file names is an issue. GAMS has introduced an option that allows automatic
manipulation of all file names. By default file names are passed
maintaining the casing as typed in the command. This can be overridden with the
GAMS command line parameter FILECASE=n, where
n=0 means to retain original casing (default)
n=1 uppercase the filename, and
n=2 will lowercase the filename.
Courses offered
I teach an Applied GAMS and Agricultural Modeling course in
This newsletter is not a GAMS Corporation product but it is distributed with
their cooperation.