Tabular Expressionsļƒ

Tables for initialization

For multidimensional quantities the table format often provides the most natural structure for data entry because elements are repeated less often. Tables can be used in text data files and in the InitialData attribute inside the declaration of an identifier.

Two-dimensional views

A table is a two-dimensional view of a multidimensional quantity. The index tuple of the quantity is split into two parts: row identifiers and column identifiers. Indices may not be permuted.

Example

The following example illustrates a simple example of the table format.

Distance(i,j) := DATA TABLE
                Rotterdam    Antwerp    Berlin    Paris
!               ---------    -------    ------    -----
    Amsterdam       85          170       660      510
    Rotterdam                   100       700      440
    Antwerp                               725      340
    Berlin                                        1050
;

The first line of a table (after the keyword DATA TABLE) contains the column identifiers. Each subsequent line contains a row identifier followed by the table entries.

Multidimensional entries

Row and column identifiers may be set elements, tuples of elements, or tuples containing element ranges. As a result, multidimensional identifiers can still be captured within the two-dimensional framework of a table.

Proper spacing

Column identifiers must be separated by at least one space. AIMMS keeps track of the column width by maintaining the first and last position used by each column identifier. Any entry must intersect only one column and is understood to be part of that column. AIMMS will reject any entry that intersects two columns, or falls between them.

Continuation of tables with +

Even though the table format is a convenient way to enter data, the number of columns is always restricted by the width of a line. However, by placing a + on a new line you can continue a table by repeating the table format. Row identifiers and column identifiers can be repeated in each block separated by the + sign, but must be unique within a block.

Example

The following table illustrates a valid example of table continuation, equivalent with the previous example.

Distance(i,j) := DATA TABLE
                Rotterdam    Antwerp
!               ---------    -------
    Amsterdam       85          170
    Rotterdam                   100
+
                Berlin    Paris
!               ------    -----
    Amsterdam     660      510
    Rotterdam     700      440
    Antwerp       725      340
    Berlin                1050
;

Data and membership tables

Tables can be used for the initialization of both parameters and sets. When used for parameter initialization, table entries are either blank or contain explicit numbers, quoted or unquoted set elements and quoted strings. Entries in tables used for set initialization are either blank or contain a * denoting membership.

Syntax

The detailed syntax of a table constant is given by the following diagram, where the symbol ā€œ\(\backslash\)nā€ stands for the newline character.

table:

image/svg+xmlDATA TABLE \n table-header \n table-row \n +

table-header:

image/svg+xmlelement-tuple

table-row:

image/svg+xmlelement-tuple constant *