4.1 Set statement

set name alias domain , attrib , $\dots$ , attrib ;

Where:

name is the symbolic name of the set;

alias is an optional string literal which specifies the alias of the set;

domain is an optional indexing expression which specifies the subscript domain of the set;

attrib, $\dots$, attrib are optional attributes of the set. (Commae preceding attributes may be omitted.)

Optional attributes:

dimen n

specifies dimension of n-tuples, which the set consists of;

within expression

specifies a superset which restricts the set or all its members (elemental sets) to be within this superset;

:= expression

specifies an elemental set assigned to the set or its members;

default expression

specifies an elemental set assigned to the set or its members whenever no appropriate data are available in the data section.

Examples

set V;
set E within V cross V;
set step{s in 1..maxiter} dimen 2 := if s = 1 then E else step[s-1]
   union setof{k in V, (i,k) in step[s-1], (k,j) in step[s-1]}(i,j);
set A{i in I, j in J}, within B[i+1] cross C[j-1], within D diff E,
   default {('abc',123), (321,'cba')};

The set statement declares a set. If the subscript domain is not specified, the set is a simple set, otherwise it is an array of elemental sets.

The dimen attribute specifies dimension of n-tuples, which the set (if it is a simple set) or its members (if the set is an array of elemental sets) consist of, where n must be unsigned integer from 1 to 20. At most one dimen attribute can be specified. If the dimen attribute is not specified, dimension of n-tuples is implicitly determined by other attributes (for example, if there is a set expression that follows := or the keyword default, the dimension of n-tuples of the corresponding elemental set is used). If no dimension information is available, dimen 1 is assumed.

The within attribute specifies a set expression whose resultant value is a superset used to restrict the set (if it is a simple set) or its members (if the set is an array of elemental sets) to be within this superset. Arbitrary number of within attributes may be specified in the same set statement.

The assign (:=) attribute specifies a set expression used to evaluate elemental set(s) assigned to the set (if it is a simple set) or its members (if the set is an array of elemental sets). If the assign attribute is specified, the set is computable and therefore needs no data to be provided in the data section. If the assign attribute is not specified, the set must be provided with data in the data section. At most one assign or default attribute can be specified for the same set.

The default attribute specifies a set expression used to evaluate elemental set(s) assigned to the set (if it is a simple set) or its members (if the set is an array of elemental sets) whenever no appropriate data are available in the data section. If neither assign nor default attribute is specified, missing data will cause an error.