Sets

Top  Previous  Next

Above we used the subscripts i , j, commodities and cc for addressing the variable, equation and data items. In GAMS subscripts are SETs.  In order to use any subscript one must declare an equivalent set.

The set declaration contains

the set name

a list of elements in the set (up to 63  characters long spaces etc allowed in quotes)

optional labels describing the whole set

optional labels defining individual set elements

 

The general format for a set statement is:

SET setnameoptional defining text
       /firstsetelementname    optional defining text

 secondsetelementname   optional defining text 

   ...  /;

Examples:

(sets.gms)

 SETs           j         /x1,x2,x3/

                 i         /r1 ,r2/;

 SET  PROCESS   PRODUCTION PROCESSES   /X1,X2,X3/;

 SET  Commodities Crop commodities   /

                 corn     in bushels

                 wheat    in metric tons

                 milk            in hundred pounds/        ;

 

More on sets appears in the Sets chapter.