Adding a scenario

Top  Previous  Next

Now let me illustrate the full extent to which the above approach is automated by adding a new scenario.  This is done through two modifications.  First we expand the set of named scenarios to include the new one.  Second we add data for the new scenario (comparenew.gms).

 

set scenarios /base,beefp,beefcorn,new/

table scenprice(primary,scenarios)  price alterations by scenario

                base    beefp   beefcorn  new

corn                               2.70

soybeans                                  4.32

beef                     0.70                 ;

 

The rest of the code is unchanged.  Note we did not have to add a solve or report writing or anything else.  That is all handled by the LOOP and one just has to add data to add to the scenarios.

In doing such an analysis cases certainly arise where a new scenario requires that other data items like resource endowments be changed.  In such a case, and one needs to alter the code so that with respect to the other data item the code saves, resets to base levels and alters to reflect the scenario.  For example if our new scenario also involved alteration of the data item available in the cropland category making 30% more available, we could add code like the following (compareother.gms)

 

table scenavailable(alli,scenarios)  price alterations by scenario

                base    beefp   beefcorn  new

cropland                                  1.3;

*step 2 save data

parameter savprice(primary) saved primary commodity prices;

savprice(primary)=price(primary);

parameter saveavailable (alli);

saveavailable (alli)= available (alli);

loop(scenarios,

*step 3 reestablish data to base level

    price(primary)=savprice(primary);

    available (alli)=saveavailable (alli);

*step 4 change data to levels needed in scenario

    price(primary)$scenprice(primary,scenarios)=scenprice(primary,scenarios);

    available(alli)$scenavailable(alli,scenarios)=

       available(alli)*scenavailable(alli,scenarios);

    display price,available;