Adding a report

Top  Previous  Next

Now suppose I add a report.  Lets do this in a simple transportation model.  First, let me briefly design it.  Lets suppose for each destination I wish to know where the goods came from, how much the marginal cost of meeting demand is and what is the total shipment cost to that location.  I will do this in a rather quick and dirty fashion using a five dimensional parameter defined over unspecified set elements employing the universal set concept discussed below or in the Sets chapter.

I do this in the transportation model calcoutp.gms by computing a parameter called incoming.  There I

Define a parameter called incoming as a 5 dimensional entity with unspecified set elements.
Place the incoming shipment levels (transport.l(source,destinaton)) into that parameter with appropriate labeling.
Place the marginals from the demand rows demandbal.m(destinaton) into that parameter with appropriate labeling.
Compute a total cost of shipping by multiplying per unit cost times the volume shipped and summing over all incoming routes.
Compute total shipments from a place and total cost of shipping adding up the data already in the incoming parameter with appropriate labeling.
Display the result using the formatting options described below.

 

The added code to do this is

 

parameter incoming(*,*,*,*,*) incoming shipment report;

incoming(destinaton,"shipments","in cases","from",source)

 =transport.l(source,destinaton);

incoming(destinaton,"Marg Cost of","meeting needs"," ","Total")

 =demandbal.m(destinaton);

incoming(destinaton,"Cost of","shipping"," ","total")      =sum(source,

trancost(source,destinaton)*transport.l(source,destinaton));

incoming("total","shipments","in cases","from",source)

  =sum(destinaton,

     incoming(destinaton,"shipments","in cases","from",source));

incoming("Total","Cost of","shipping"," ","total")

  =sum(destinaton,

     incoming(destinaton,"Cost of","shipping"," ","total"));

option incoming:0:3:2;display incoming;

 

This results in the following report with the results color coded to the originating statement.

 

----     79 PARAMETER INCOMING         incoming  shipment report

 

                                           from        from

                                        Seattle    San Diego      Total

New York.Shipments   .in cases               50         275

New York.Cost of     .shipping                                    81250

New York.Marg Cost of.meeting needs                                 250

Chicago .Shipments   .in cases              300

Chicago .Cost of     .shipping                                    53400

Chicago .Marg Cost of.meeting needs                                 178

Topeka  .Shipments   .in cases                          275

Topeka  .Cost of     .shipping                                    41525

Topeka  .Marg Cost of.meeting needs                                 151

Total   .Shipments   .in cases              350         550

Total   .Cost of     .shipping                                   176175