[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
5.2 Set data block
set name , record , … , record ; set name [ symbol , … , symbol ] , record , … , record ; |
- Where:
name is a symbolic name of the set;
symbol, …, symbol are subscripts which specify a particular member of the set (if the set is an array, i.e. a set of sets);
record, …, 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:
( s1 , s2 , … , sn )
where s1, s2, …, sn 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:
t1 , t2 , … , tn
where t1, t2, …, tn 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:
:
c1
c2
…
cn
:=
r1
a11
a12
…
a1n
r2
a21
a22
…
a2n
…
…
…
…
…
rm
am1
am2
…
amn
where r1, r2, …, rm are numbers and/or symbols which
correspond to rows of the matrix, c1, c2, …, cn are
numbers and/or symbols which correspond to columns of the matrix,
a11, a12, …, amn 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 aij of the matrix data block (where
1 <= i <= m,
1 <= j <= n) corresponds to 2-tuple
(ri, cj). If aij 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 aij 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:
(tr) :
c1
c2
…
cn
:=
r1
a11
a12
…
a1n
r2
a21
a22
…
a2n
…
…
…
…
…
rm
am1
am2
…
amn
(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 aij of the matrix corresponds to 2-tuple (cj, ri).
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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |