Ord and Card

Top  Previous  Next

ORD and CARD are functions defined in the Conditionals chapter that allow knowledge of and special processing for the relative position of a set element within a set.  Namely, I may also wish to do particular things if I am on the first or last or other elements of a set.  The statement (sets.gms)

 

stock(t)$(ord(t) eq 1) = initial;

 

defines a constraint only for the first element of t.

The command

 

Carryout.lo(t)$(ord(t) eq card(t)) = final;

 

only operates for the last element of t.