5.2 Set data block

set name , record , $\dots$ , record ;

set name [ symbol , $\dots$ , symbol ] , record , $\dots$ , record ;

Where:

name is a symbolic name of the set;

symbol, $\dots$, symbol are subscripts which specify a particular member of the set (if the set is an array, i.e. a set of sets);

record, $\dots$, record are data records.

Note:

Commae preceding data records may be omitted.

Data records:

:=

is a non-significant data record which may be used freely to improve readability;

( slice )

specifies a slice;

simple-data

specifies set data in the simple format;

: matrix-data

specifies set data in the matrix format;

(tr) : matrix-data

specifies set data in the transposed matrix format. (In this case the colon following the keyword (tr) may be omitted.)

Examples

set month := Jan Feb Mar Apr May Jun;
set month "Jan", "Feb", "Mar", "Apr", "May", "Jun";
set A[3,Mar] := (1,2) (2,3) (4,2) (3,1) (2,2) (4,4) (3,4);
set A[3,'Mar'] := 1 2 2 3 4 2 3 1 2 2 4 4 2 4;
set A[3,'Mar'] : 1 2 3 4 :=
               1 - + - -
               2 - + + -
               3 + - - +
               4 - + - + ;
set B := (1,2,3) (1,3,2) (2,3,1) (2,1,3) (1,2,2) (1,1,1) (2,1,1);
set B := (*,*,*) 1 2 3, 1 3 2, 2 3 1, 2 1 3, 1 2 2, 1 1 1, 2 1 1;
set B := (1,*,2) 3 2 (2,*,1) 3 1 (1,2,3) (2,1,3) (1,1,1);
set B := (1,*,*) : 1 2 3 :=
                 1 + - -
                 2 - + +
                 3 - + -
         (2,*,*) : 1 2 3 :=
                 1 + - +
                 2 - - -
                 3 + - - ;

(In these examples the set month is a simple set of singles, A is a 2-dimensional array of doubles, and B is a simple set of triples. Data blocks for the same set are equivalent in the sense that they specify the same data in different formats.)

The set data block is used to specify a complete elemental set, which is assigned to a set (if it is a simple set) or one of its members (if the set is an array of sets).5

Data blocks can be specified only for non-computable sets, i.e. sets which have no assign attribute in the corresponding set statements.

If the set is a simple set, only its symbolic name should be given in the header of the data block. Otherwise, if the set is a n-dimensional array, its symbolic name should be provided with a complete list of subscripts separated by commae and enclosed in square brackets to specify a particular member of the set array. The number of subscripts must be the same as the dimension of the set array, where each subscript must be a number or symbol.

The elemental set defined in the set data block is coded as a sequence of data records described below.6

Assign data record

The assign (:=) data record is a non-signficant element. It may be used for improving readability of data blocks.

Slice data record

The slice data record is a control record which specifies a slice of the elemental set defined in the data block. It has the following syntactic form:

( $s_1$ , $s_2$ , $\dots$ , $s_n$ )

where $s_1, s_2, \dots, s_n$ are components of the slice.

Each component of the slice can be a number or symbol or the asterisk (*). The number of components in the slice must be the same as the dimension of n-tuples in the elemental set to be defined. For instance, if the elemental set contains 4-tuples (quadruples), the slice must have four components. The number of asterisks in the slice is called slice dimension.

The effect of using slices is the following. If a m-dimensional slice (i.e. a slice which has $m$ asterisks) is specified in the data block, all subsequent data records must specifiy tuples of the dimension m. Whenever a $m$-tuple is encountered, each asterisk in the slice is replaced by corresponding components of the $m$-tuple that gives the resultant n-tuple, which is included in the elemental set to be defined. For example, if the slice (a,*,1,2,*) is in effect, and 2-tuple (3,b) is encountered in a subsequent data record, the resultant 5-tuple included in the elemental set is (a,3,1,2,b).

The slice that has no asterisks itself defines a complete n-tuple, which is included in the elemental set.

Being once specified the slice effects until either a new slice or the end of data block has been encountered. Note that if there is no slice specified in the data block, a dummy one, components of which are all asterisks, is assumed.

Simple data record

The simple data record defines one n-tuple in simple format and has the following syntactic form:

$t_1$ , $t_2$ , $\dots$ , $t_n$

where $t_1, t_2, \dots, t_n$ are components of the n-tuple. Each component can be a number or symbol. Commae between components are optional and may be omitted.

Matrix data record

The matrix data record defines several 2-tuples (doubles) in matrix format and has the following syntactic form:

$\matrix{ {\tt :} & c_1 & c_2 & \dots & c_n & {\tt :=} \cr r_1 & a_{11} & a_{12} & \dots & a_{1n} & \cr r_2 & a_{21} & a_{22} & \dots & a_{2n} & \cr \dots & \dots & \dots & \dots & \dots & \cr r_m & a_{m1} & a_{m2} & \dots & a_{mn} & \cr }$

where $r_1, r_2, \dots, r_m$ are numbers and/or symbols which correspond to rows of the matrix, $c_1, c_2$, $\dots, c_n$ are numbers and/or symbols which correspond to columns of the matrix, $a_{11}, a_{12}, \dots, a_{mn}$ are the matrix elements, which can be either the sign + or the sign -. (In this data record the delimiter : preceding the column list and the delimiter := following the column list cannot be omitted.)

Each element $a_{ij}$ of the matrix data block (where $1\leq i\leq m, 1\leq j\leq n$) corresponds to 2-tuple $(r_i, c_j)$. If $a_{ij}$ is the plus sign (+), the corresponding 2-tuple (or a longer n-tuple, if a slice is used) is included in the elemental set. Otherwise, if $a_{ij}$ is the minus sign (-) sign, the corresponding 2-tuple is not included in the elemental set.

Since the matrix data record defines 2-tuples, either the elemental set must consist of 2-tuples or the slice currently used must be 2-dimensional.

Transposed matrix data record

The transposed matrix data record has the following syntactic form:

$\matrix{ {\tt (tr)\ :} & c_1 & c_2 & \dots & c_n & {\tt :=} \cr r_1 & a_{11} & a_{12} & \dots & a_{1n} & \cr r_2 & a_{21} & a_{22} & \dots & a_{2n} & \cr \dots & \dots & \dots & \dots & \dots & \cr r_m & a_{m1} & a_{m2} & \dots & a_{mn} & \cr }$

(In this case the delimiter : following the keyword (tr) is optional and may be omitted.)

This data record is completely analogous to the matrix data record (see above) with the only exception that each element $a_{ij}$ of the matrix corresponds to 2-tuple $(c_j,r_i)$.

Being once specified the (tr) indicator effects on all subsequent data records until either a slice or the end of data block has been encountered.


Footnotes

(5)

There is another way to specify data for a simple set along with data for parameters. This feature is discussed in the next section.

(6)

Data record is simply a technical term. It does not mean that data records have any special formatting.