Displaying data

Top  Previous  Next

One may display any GAMS parameter, set, variable attribute, equation attribute or model attribute as well as quoted text using the GAMS display statement.  Generally the display is of the format

 

DISPLAY ITEM1,ITEM2,ITEM3;

 

where the items are either

Quoted strings in single or double quotes such as

 Display 'here it is'"hello";

 

Parameter or set names without any referencing to setdependency.  Thus in dispord.gms while the parameter data is defined over 4 sets

 

 parameter data(index1,index2,index3,index4);

 

I simply say

 

 display data;

 

Variable, equation or model attributes with the item name and attribute desired specified

 

 Display x.l, eq.m;

 

Multiple items can be listed in a display statement separated by commas.

Notes:

Display will not print out items that are zero leaving blanks or skipping items where entire rows or columns are zero.
GAMS displays can be enhanced in terms of form, and content in several ways as discussed in the Improving Output via Report Writing chapter.  One way involves use of an option command of the following form

 OPTION ITEMNAME:DECIMAL:ROWitems:COLUMNitems

 

which will cause all subsequent displays of the named item to follow rules specified by three numbers following the colons which are

DECIMALnumber of decimal places to be included
ROWitemsnumber of indices displayed within rows
COLUMNitemsnumber of indices displayed within columns

 

 A display formatting sequence is introduced into the optimization example (goodoptalgebra.gms) as follows:

 option thisreport:2:1:2;

 display thisreport;

 

which says use 2 decimal places and produce a display with 1 item in the rows and 2 in the columns yielding

        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

 

A display of the same item with option this report:4:2:1; yields

                    Corn       Wheat   Available       Value

 

Land .Total                             100.0000

Land .Use by       50.0000     50.0000

Land .Marginal                                         52.0000

Labor.Total                               500.0000

Labor.Use by     300.0000   200.0000

Labor.Marginal                                          9.5000