Using tuples

Top  Previous  Next

A tuple refers to a set defined over other sets.  The set may either be a one dimensional subset or a multidimensional set.  Tuples are useful in calculations and in imposing conditionals.

Examples:

(sets.gms)

One can replace a sum that would go over all cases of a set with one that only operates over a subset.  Namely in

 

mZ=sum(r(mi),mx(mi));

 

the index r(mi) only operates over those elements in mI that appear in the subset r.

 

Similarly in

 

mQ(i_am_a_tuple (mI,mj) =mx(mi)+my(mj);

 

the only the mi and mj cases which are operated over are those explicitly defined in the set named i_am_a_tuple.

 

Finally, note that when using a tuple on both sides of the equation that one does not need to explicitly enter the component sets as follows

 

mQ(i_am_a_tuple) =mQ(i_am_a_tuple )*1.5;

 

where mq is declared as mq(mi,mj) in sets.gms but so is i_am_a_tuple so the mi and mj can be left out of the replacement statement and the replacement will operate over all mi and mj cases in the tuple.