Composite Tables

Multiple identifiers

A composite table is a bulk form of initialization, and is similar in structure to a table in a database. Using a composite table you can initialize simple sets, relations, parameters, and variables in a single statement. Composite tables always form a single block, and can only be used in text data files.

Format

The first line of a composite table contains column identifiers that define the index columns and the quantity columns. The subsequent lines contain data entries. Like in a tabular expression, entries in a composite table may be either blank or contain explicit numbers, quoted or unquoted set elements and quoted strings, depending on the type of the identifier associated with a column. Blank entries in the quantity columns are treated as “no assignment.”, while blank entries in the index columns are not allowed. All data entries must lie directly below their corresponding column identifier as in regular tables.

Indices must come first

The full index space is declared in the first group of column identifiers, and is comparable to the primary key in a database table. The remaining column identifiers declare various quantities that must share the identical index space. Note that, unlike in tabular expressions, index columns in a data entry row of a composite table cannot refer to tuples or ranges of elements, but only to single set elements.

Example

The following statement illustrates a valid example of a composite table. It initializes the relation Routes, as well as the parameters Distance and TransportCost, all of which are defined over the index space (i, j).

COMPOSITE TABLE
    i           j            Routes    Distance    TransportCost
!   ---------   ---------    ------    --------    -------------
    Amsterdam   Rotterdam      *            85        1.00
    Amsterdam   Antwerp        *           170        2.50
    Amsterdam   Berlin                     660       10.00
    Amsterdam   Paris          *           510        8.25
    Rotterdam   Antwerp        *           100        1.20
    Rotterdam   Berlin         *           700       10.00
    Rotterdam   Paris                      440        7.50
    Antwerp     Berlin         *           725       11.00
    Antwerp     Paris          *           340        5.00
    Berlin      Paris                     1050       17.50
;

Syntax

The detailed syntax of the composite table is given by the following diagram, where the symbol \n stands for the newline character.

composite-table:

image/svg+xmlCOMPOSITE TABLE \n composite-header \n composite-row \n ;

composite-header:

image/svg+xmlindex reference

composite-row:

image/svg+xmlelement constant