Using subsets

Top  Previous  Next

There may be cases where one wishes to reference a priori known or calculated subsets.  In such case, one may define a subset, either explicitly or through calculation, then reference the item with respect to that subset.  Consider the following example. (sets.gms)

 

Set    thisI/i1*i10/;
Set    thisJ(thisI)/ i1,i3,i5/;
Parameter A(thisI)/i7 5, i2 9, i3 11/;

Set wherea(thisI);

Wherea(thisi)$a(thisi)=yes;

Parameter nzz(thisi);

nZz(thisi)=5;

nZz(wherea)=-1;

nZz(thisj)=12;

 

In this case, the blue colored statements operate over subsets of thisI with the wherea reference being over a calculated subset and the thisj reference being over an explicitly defined subset.