2.1.2. Compound data types

We provide the following compound data types:

  • πš•πš’πšœπš(T) corresponds to a list of elements of type T, where T is a basic or a compound data type.

  • πšŒπš˜πš•πš•πšŽπšŒπšπš’πš˜πš—(A 1 ,A 2 ,...,A n ) corresponds to a collection of ordered items, where each item consists of n>0 attributes A 1 ,A 2 ,...,A n . Each attribute is an expression of the form 𝚊-T, where 𝚊 is the name of the attribute and T the type of the attribute (a basic or a compound data type). All names of the attributes of a given collection should be distinct and different from the keyword πš”πšŽπš’, which corresponds to an implicitThis attribute is not explicitly defined. attribute. Its value is the position of an item within the collection. The first item of a collection is associated with position 1.

The following notations are used for instantiated arguments:

  • A list of elements e 1 ,e 2 ,...,e n is denoted [e 1 ,e 2 ,...,e n ].

  • A finite set of integers i 1 ,i 2 ,...,i n is denoted {i 1 ,i 2 ,...,i n }.

  • A multiset of integers i 1 ,i 2 ,...,i n is denoted {{i 1 ,i 2 ,...,i n }}.

  • A collection of n items, each item having m attributes, is denoted by

    〈𝚊 1 -v 11 ...𝚊 m -v 1m , 𝚊 1 -v 21 ...𝚊 m -v 2m , ... ,𝚊 1 -v n1 ...𝚊 m -v nm βŒͺ. Each item is separated from the previous item by a comma. When the items of the collection involve one single attribute 𝚊 1 , 〈v 11 ,v 21 ,...,v n1 βŒͺ can eventually be used as a shortcut for 〈𝚊 1 -v 11 , 𝚊 1 -v 21 , ... ,𝚊 1 -v n1 βŒͺ.

  • The i th item of a collection 𝚌 is denoted 𝚌[i].

  • The value of the attribute 𝚊 of the i th item of a collection 𝚌 is denoted 𝚌[i].𝚊. Note that, within an arithmetic expression, we can use the shortcut 𝚌[i] when the collection 𝚌 involves one single attribute.

  • The number of items of a collection 𝚌 is denoted |𝚌|.

EXAMPLE: Let us illustrate with four examples, the types one can create. These examples concern the creation of a collection of variables, a collection of tasks, a graph variableΒ [Dooms06] and a collection of orthotopes.An orthotope corresponds to the generalisation of a segment, a rectangle and a box to the n -dimensional case.

  • In the first example we define πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚ so that it corresponds to a collection of variables. πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚ is for instance used in the πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš constraint. The declaration πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚:πšŒπš˜πš•πš•πšŽπšŒπšπš’πš˜πš—(πšŸπšŠπš›-πšπšŸπšŠπš›) defines a collection of items, each of which having one attribute πšŸπšŠπš› that is a domain variable.

  • In the second example we define πšƒπ™°πš‚π™Ίπš‚ so that it corresponds to a collection of tasks, each task being defined by its origin, its duration, its end and its resource consumption. Such a collection is for instance used in the πšŒπšžπš–πšžπš•πšŠπšπš’πšŸπšŽ constraint. The declaration πšƒπ™°πš‚π™Ίπš‚:πšŒπš˜πš•πš•πšŽπšŒπšπš’πš˜πš—(πš˜πš›πš’πšπš’πš—-πšπšŸπšŠπš›,πšπšžπš›πšŠπšπš’πš˜πš—-πšπšŸπšŠπš›,πšŽπš—πš-πšπšŸπšŠπš›,πš‘πšŽπš’πšπš‘πš-πšπšŸπšŠπš›) defines a collection of items, each of which having the four attributes πš˜πš›πš’πšπš’πš—, πšπšžπš›πšŠπšπš’πš˜πš—, πšŽπš—πš and πš‘πšŽπš’πšπš‘πš which all are domain variables.

  • In the third example we define a graph as a collection of nodes π™½π™Ύπ™³π™΄πš‚, each node being defined by its index (i.e.,Β identifier) and its successors. Such a collection is for instance used in the 𝚍𝚊𝚐 constraint. The declaration π™½π™Ύπ™³π™΄πš‚:πšŒπš˜πš•πš•πšŽπšŒπšπš’πš˜πš—(πš’πš—πšπšŽπš‘-πš’πš—πš,𝚜𝚞𝚌𝚌-πšœπšŸπšŠπš›) defines a collection of items, each of which having the two attributes πš’πš—πšπšŽπš‘ and 𝚜𝚞𝚌𝚌 which respectively are integers and set variables.

  • In the last example we define π™Ύπšπšƒπ™·π™Ύπšƒπ™Ύπ™Ώπ™΄πš‚ so that is corresponds to a collection of orthotopes. Each orthotope is described by an attribute πš˜πš›πšπš‘. Unlike the previous examples, the type of this attribute does not correspond any more to a basic data type but rather to a collection of n items, where n is the number of dimensions of the orthotope.1 for a segment, 2 for a rectangle, 3 for a box, ... . This collection, named π™Ύπšπšƒπ™·π™Ύπšƒπ™Ύπ™Ώπ™΄, defines for a given dimension the origin, the size and the end of the object in this dimension. This leads to the two declarations:

    • π™Ύπšπšƒπ™·π™Ύπšƒπ™Ύπ™Ώπ™΄-πšŒπš˜πš•πš•πšŽπšŒπšπš’πš˜πš—(πš˜πš›πš’-πšπšŸπšŠπš›,πšœπš’πš£-πšπšŸπšŠπš›,πšŽπš—πš-πšπšŸπšŠπš›),

    • π™Ύπšπšƒπ™·π™Ύπšƒπ™Ύπ™Ώπ™΄πš‚-πšŒπš˜πš•πš•πšŽπšŒπšπš’πš˜πš—(πš˜πš›πšπš‘-π™Ύπšπšƒπ™·π™Ύπšƒπ™Ύπ™Ώπ™΄).

    π™Ύπšπšƒπ™·π™Ύπšƒπ™Ύπ™Ώπ™΄πš‚ is for instance used in the πšπš’πšπšπš— constraint.