Avoiding use of * in input data set specification

Top  Previous  Next

One can use an * to allow the universal set to be employed in an input data set position as done in the GAMS library code robert.gms as follows

 

Table  misc(*,r)  other data

            scrap  new

 max-stock    400  275

 storage-c     .5    2

 res-value     15   25

...

pd.. profit =e= sum(t, sum(p, c(p,t)*x(p,t))

              - sum(r,misc("storage-c",r)*s(r,t)))

              + sum(r,misc("res-value",r)*s(r,"4"));

 

This tells GAMS anything goes in the first index position of misc suppressing domain checking.  However, if we mistyped "res-value" as "res-val" GAMS compiles and executes without error but I have lost my data and perhaps created a garbage result as in Robert2.gms.

 

pd2.. profit =e= sum(t, sum(p, c(p,t)*x(p,t))

              - sum(r,misc("storage-c",r)*s(r,t)))

              + sum(r,misc("res-value",r)*s(r,"4"));

 

I can fix this by entering another set and altering the table definition

 

Set miscitem misc. input items

                         /res-value, .../;

          Table  misc(miscitem,r)  other data

 

where GAMS with the code in Robert2.gms now included in robert3.gms gives error messages for the misspelling.

So don't use * for set references in input data specifications.  I learned this at the school of hard knocks when a research associate used such an input strategy and had some small typing errors that caused important data to be ignored.