Variable specification - suppression

Top  Previous  Next

(transbad.gms vs. transfix.gms)

Cases can exist where unneeded variables are being defined.  Creation of an unnecessary variable requires extra execution time.  For example, in a transport model, I may only want variables that are defined over routes with nonzero transportation cost.

 

TCOST =E= SUM((PLANT,MARKET)$cost(plant,market)

          , SHIPMENTS(PLANT,MARKET)*COST(PLANT,MARKET));

fsSUPPLYEQ(PLANT)$supply(plant)..

  SUM(MARKET $cost(plant,market), SHIPMENTS(PLANT, MARKET))=L=SUPPLY(PLANT);

fsDEMANDEQ(MARKET)$demand(market)..

  SUM(PLANT$cost(plant,market),  SHIPMENTS(PLANT, MARKET))=G=DEMAND(MARKET);

 

In general, speed can often be helped by using tuples, subsets or conditionals to reduce attention in variable inclusion across .. equations only to relevant cases.