Table

Top  Previous  Next

TABLE format is used to enter items that are dependent on two or more sets.

The general format is

 

Table itemname(setone, settwo ... ) optional explanatory text

                  set_2_element_1   set_2_element_2

set_1_element_1     value_11           value_12

set_1_element_2     value_21           value_22;

 

More than two set dimensions can be entered as shown below.

Examples:

(tables.gms)

TABLE a(i,j) crop data

            corn  wheat cotton

    land      1     1      1

    labor     6     4      8      ;

 

Table RESOURUSE(RESOURCE,PROCESS) RESOURCE USAGE

             Makechair Maketable Makelamp

 plantcap        3        2        1.1   

 salecontrct     1                 1    ;

 

Table fivedim(i,j,k,l,m) fivedimensional

                 l1.m1  l2.m2

        i1.j1.k2   11    13

        i2.j1.k11   6    -3

+                 l3.m1   l2.m7

        i1.j1.k2    1      3

        i10.j1.k4   7      9;

 

Table avariant1(i,j,state) crop data

            cn.al wt.al cn.al cr.in wt.in cn.in

    land     1      1    1     1     1     1

    labor    6      4    8     5     7     2;

 

Table avariant2(i,j,state) crop data

                   al  in

    land.corn      1    1

    labor.corn     6    5

    land.wheat     1    1

    labor.wheat    4    7

    land.cotton    1    1

    labor.cotton   8    2;

Notes:

Item names, explanatory text and the contained set element names must obey the item naming rules presented in the Rules for Item Names, Element names and Explanatory Text chapter.
Labels and long explanatory names should be used where possible as argued in the Writing Models and Good Modeling Practices chapter.
Table statements must contain at least one data element.  Ordinarily, if data are to be defined by subsequent replacement (=) statement calculations or assignments it is usually better to define that item with a parameter statement.
Items in tables must be defined with respect to at least 2 sets and can be defined over up to 20 sets.  Thus one item name may be associated with numerous individual numerical values for elements of the parameter, each associated with a specific simultaneous collection of set elements for each of the named sets.
Tables are a specific input entry format for the general GAMS parameter class of items that also encompasses scalars.
When more than two dimensional items are entered in Tables then the notation is set1elementname.set2elementname.set3elementname etc with periods(.) setting off the element names in the associated sets. Multiple orders can be used as illustrated in avariant1 and avariant2 above.
Alignment is important. Each numerical entry must occur somewhere below one and only one column name in the Table.
All elements that are not given explicit values or have blanks under them are implicitly assigned to equal zero.
Multiple entries can occur within one table command using notation such as

  Table ta(i,j)

               J1      j2*j4

     (i1,i5)   3         1

    (i6*i11)   5         8;

 

The referenced set elements must appear in the set the named parameter is defined over.
Data for an element can only defined once in a table statement
Tables that become too wide can be split and continued with a + (plus).
Tables can also be used to define elements of sets as discussed in the sets chapter.