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 .  New features
within this release are discussed in the last newsletter at .  The software can be downloaded from but is only useful if you have a current license file.


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 in the sets, calculations and conditionals chapters.


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 .

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 Braunschweig, Germany during May 12-14, 2004. Immediately thereafter I teach Basic GAMS in Washington D.C. May 17-20, 2004. An Advanced class is not planned until late 2004 or early 2005.  Further information and other courses are listed on

This newsletter is not a GAMS Corporation product but it is distributed with their cooperation.

February 18, 2004