Tuples and subsets to restrict set coverage

Top  Previous  Next

In sums, minimums, maximums and products it is not always desirable to sum etc. over the all the members of a set.  One accomplishes this by adding a conditional as discussed immediately above or addressing over a multiple dimensional set (a tuple) or a subset.  Such addressing can take on a number of forms.

Examples:

(calculate.gms)

mA(i)$mysubset(i)=mr(i);

ma(mysubset(i))=mr(i);

mA(i) =mr(i) $mysubset(i);

mA(i) =sum(atuple(I,j),v(I,j));

v(i,j)$atuple(i,j)=3;

v(atuple(i,j))=3;

v(atuple)=3;

r=sum(mysubset,mr(mysubset));

r=sum(mysubset(i),mr(i));

r=sum(mysubset(i),mr(mysubset)+mr(i));

r=sum(atuple(I,j),v(I,j));

r=smin(i$mysubset(i),mr(i));

r=smax((I,j)$atuple(I,j),v(I,j));

r=smax(atuple(I,j),v(I,j));

Eq11(i)$mysubset(i).. zZ{I}=l=10*[3+2]**{34/(11+12)}+{11-1};

Eq12(mysubset).. zZ{mysubset}=l=10*[3+2]**{34/(11+12)}+{11-1};

Eq13(mysubset(i))..  zZ{I}=l=sum(atuple(I,j),ord(i)+ord(j));

Eq14(atuple(i,j))..  1=e= twovar(i,j) ;

Eq15(I,j)$atuple(i,j)..  1=e= twovar(i,j) ;

eq16(j).. 1=e=sum(atuple(I,j),v(I,j)*twovar(i,j));

Notes:

Additional discussion of these topics appears in the conditional and sets notes.
Equations with the conditionals on the left hand side operate significantly different from those with the conditional on the right hand side as discussed below.
Use of the tuple as the set summed over results in the component sets being varied as in sum(atuple(I,j),v(I,j)) where both I and j are varied.  But the only cases of I and j that are considered are those that are jointly in the tuple.
Use of the tuple in an equation defined over some of the sets in the tuple results in the component sets not in the equation definition being varied as in mA(i) =sum(atuple(I,j),v(I,j)) where the j case that are in the tuple associated with the particular I case that is being computed are varied.
Use of the subset and the superset name in the sum gives access to both in an equation as in r=sum(mysubset(i),mr(mysubset)+mr(i)); where both the sets I and mysubset are accessible.
When all items in a tuple are to be acted over one can use syntax like v(atuple)=3;  which will work even if v is defined over multiple sets as long as the tuple is defined over those same sets.