Set definition through Tables

Top  Previous  Next

One can define set elements for sets that have 2 or more dimensions through tables.  This is done using a set then a table command or a set table command where the table entries are numerical or yes/no.

Examples:

The following four definitions all have the same effect (sets.gms)

 

set     Linkedbyroad2(origins,destinations)  Places linked by  roadways

                           /"NEW York" .Portland, "New York" .Houston,

                             boston.portland, boston.Houston/;

 

set Table Linkedbyroad3(origins,destinations)  Places linked by  roadways

                   Portland London Houston

        "NEW York"   yes            yes

         boston      yes     No     yes;

 

set Linkedbyroad4(origins,destinations)  Places linked by  roadways;

Table   Linkedbyroad4(origins,destinations)  Places linked by  roadways

                   Portland London Houston

        "NEW York"   yes             yes

         boston      yes     No      yes;

 

set Table Linkedbyroad5(origins,destinations)  Places linked by  roadways

                   Portland London   Houston

        "NEW York"   3209              1429

         boston      3180     0        1520;

Notes:

One can

Define the set and elements in a tabular framework using the syntax Set Table.
Define the set first using a set command without elements specified that later go back to fill in the elements with a table command.
Define the set elements using the same convention as in the Data Entry chapter table command section (with entries aligned under column names) using either nonzero numeric entries to define active elements or yes/no.
Three or more dimensional items are defined as in the Data Entry chapter, table command section.