Report writing

Top  Previous  Next

GAMS permits one to do calculations using solution information to improve the information content of the output.  This exercise is commonly called report writing.  Information relative to the variable, equation and model solution is passed to GAMS from solvers. These data can be used in report writing computations.

In GAMS the solution level for a variable is Variablename.L while it is Equationname.L for an equation.  The dual or shadow price information for an equation is addressed as Equationname.M  and the reduced cost for a variable is Equationname.M.  The numerical values of these parameters are generally undefined until a solve is performed and retains the value from the most recent solve from then on.  In the algebraic version of the equilibrium model (econequilalg.gms) I introduce the following report writing sequence

 

set qitem /Demand, Supply, "Market Clearing"/;

set item /Quantity,Price/

parameter myreport(qitem,item,commodities);

myreport("Demand","Quantity",commodities)= Qd.l(commodities);

myreport("Supply","Quantity",commodities)= Qs.l(commodities);

myreport("Market Clearing","Price",commodities)= p.l(commodities);

display myreport;

 

which saves the supply and demand quantities along with the market clearing price.  The resultant report is generated with a display statement and is

 

----     39 PARAMETER myreport

                               Corn       Wheat

 

Supply         .Quantity       1.711       8.156

Demand         .Quantity       1.711       8.156

Market Clearing.Price          2.671       4.618

 

where I have color coded the originating statements and resultant output.

A report writing sequence is also introduced into the optimization example (goodoptalgebra.gms) as follows

 

set item  /Total,"Use by",Marginal/;

set qitem /Available,Corn,Wheat,Cotton,Value/;

parameter Thisreport(resources,item,qitem) Report on resources;

Thisreport(resources,"Total","Available")=endowments(resources);

Thisreport(resources,"Use by",qitem)=

    sum(products$sameas(products,qitem),

        resourceusage(resources,products) *production.l(products));

Thisreport(resources,"Marginal","Value")=

         available.m(resources);

option thisreport:2:1:2;

display thisreport;

 

where both equation marginals (shadow prices) and variable levels are included in the report writing calculations.  This yields the report

 

            Total      Use by      Use by    Marginal

        Available        Corn       Wheat       Value

 

Land       100.00       50.00       50.00       52.00

Labor      500.00      300.00      200.00        9.50

 

where I have color coded the originating statements and resultant output.

The report wring topic is extensively discussed in the Improving Output via Report Writing chapter with a more advanced discussion also appearing in the Output via Put Commands chapter.