Preserving changed data

Top  Previous  Next

In the above example the management of the beef price was questionable.  In particular the beefprice is "static", as discussed in the chapter Calculating Items, and since GAMS lives for the moment, when a calculation is issued then all prior values are overwritten for calculated items and that value is retained from then on.  In this case the "repeated static" buildup and to manage thus we need to reset the data.  We do this by first saving then reestablishing the price vector before each change as is done in mancompc.gms

 

$include farmcomp.gms

$include farmrep.gms

parameter saveprice(alli) saved prices;

saveprice(alli)=price(alli);

set ordr /"Scenario setup","Scenario Results"/

set scenarios /base,beefp,beefcorn/

Parameter savsumm(ordr,*,alli,scenarios) Comparative Farm Summary;

savsumm("Scenario setup","price",primary,"base")=price(primary);

savsumm("Scenario Results",measures,alli,"base")=summary(alli,measures);

price(alli)=saveprice(alli);

price("beef")=0.70;

SOLVE FARM USING LP MAXIMIZING NETINCOME;

display price ;

$include farmrep.gms

savsumm("Scenario setup","price",primary,"beefp")=price(primary);

savsumm("Scenario Results",measures,alli,"beefp")=summary(alli,measures);

price(alli)=saveprice(alli);

price("corn")=2.70;

display price ;

SOLVE FARM USING LP MAXIMIZING NETINCOME;

$include farmrep.gms

savsumm("Scenario setup","price",primary,"beefcorn")=price(primary);

savsumm("Scenario Results",measures,alli,"beefcorn")=summary(alli,measures);

option savsumm:2:3:1;display savsumm;

 

which resets the data to base levels before each scenario.