Leads and Lags: + / -

Top  Previous  Next

Some problems involve sets defined over time covering years or quarters or months.  Often when operating with such sets one may wish to define carryover relationships.  For example, suppose beginning storage in a quarter equals ending storage in a previous quarter.  These operators only work with ordered sets.

GAMS lead and lag features for set referencing are used as follows (dynindex.gms)

 

Stockbal(t).. endstock(t-1)=e=beginstock(t);

 

Where the -1 notation references the previous time period to the current one, or equivalently

 

Stockbal2(t).. endstock(t)=e=beginstock(t+1);

Notes:

The lead and lag can also use +2 to go two periods into the future or +someothernumber for other leads and –somenumber for lags.
When the case identified by t-1 ot t+1 etc does not exist the term is just skipped.  Thus in the stockbal example above no lag t-1 tem is defined for the first case of t and no t+1 case is defined in stockbal2 equation for the last set element in t.