Subsets

Top  Previous  Next

One can define subsets containing part of the elements of another set using a set statement.  The general format is

 

 SET        subsetname(setname)  optional explanatory text

                            /  Elementname1  optional explanatory text

                               Elementname2 optional explanatory text/;

 

where most of the contents are as discussed under set declaration above.  The new elements are

 

Subsetnamewhich names this subset.
Setnamewhich names the "super" set that this one is a subset of.

Examples:

(sets.gms)

Set    Superset/r1,r2,r4*r15, r25/
       Subset(superset)/r1,r25/;
Set    allitems/Corn,wheat,water,land/
       Crop(allitems)/Corn,wheat/
       Resources(allitems)/water,land/;

Notes:

The named elements of the subset must be elements of the superset.
The subset does not need to contain all elements of the superset.
The subset may be defined with explicit or calculated elements as discussed below.