2.2.3. Restrictions
When defining the arguments of a global constraint, it is often the case that one needs to express additional conditions that refine the type declarations of its arguments. For this purpose we provide restrictions that allow for specifying these additional conditions. Each restriction has a name and a set of arguments and is described by the following items:
A small paragraph first describes the effect of the restriction,
An example points to a constraint using the restriction,
Finally, a ground instance, preceded by the symbol , which satisfies the restriction is given. Similarly, a ground instance, preceded by the symbol , which violates the restriction is proposed. In this latter case, a bold font may be used for pointing to the source of the problem.
Currently the list of restrictions is:
is an argument of type ,
is a non-empty list of distinct atoms.
This restriction forces to be one of the atoms specified in the list .
is an argument of type ,
is an attribute of type or of type of the collection denoted by ,
When is an attribute of type , is a non-empty list of distinct integers; otherwise, when is an attribute of type , is a non-empty list of distinct atoms.
This restriction forces for all items of the collection , the attribute to take its value within the list .
is an argument of type ,
is an attribute of type or of type of the collection denoted by ,
is an argument of type ,
is an attribute of type of the collection denoted by .
Let denote the set of values assigned to the attributes of the items of the collection . This restriction forces the following condition: for all items of the collection , the attribute takes its value in the set .
is an argument of type ,
is an attribute of type or , or a list (possibly empty) of distinct attributes of type or of the collection denoted by .
For all pairs of distinct items of the collection this restriction forces that there be at least one attribute specified by with two distinct values. When is the empty list all items of the collection should be distinct.
is an argument of type ,
is an attribute of type or a list of distinct attributes of type of the collection denoted by .
Let and respectively denote the number of items of the collection , and the number of attributes of . For item of the collection let denote the tuple of values where is the value of attribute of of item of . The restriction forces a strict lexicographical ordering on the tuples .
is an argument of type ,
is an attribute of the collection denoted by . This attribute should be of type .
This restriction forces for each pair of consecutive items , that the number of items of the collection is greater than or equal to the number of items of the collection .
is an argument of type ,
is an attribute or a list of distinct attributes of the collection denoted by .
This restriction forces that all attributes denoted by be explicitly used within all items of the collection .
EXAMPLE: An example of use of such restriction can be found in the constraint: forces that all items of the collection mention the attribute.
The restriction is usually systematically used for every attribute of a collection. It is not used when some attributes may be implicitly defined according to other attributes. In this context, we use the restriction, which we now introduce.
is a positive integer,
is an argument of type ,
is a non-empty list of distinct attributes of the collection denoted by . The length of this list should be strictly greater than .
This restriction forces that at least attributes of the list be explicitly used within all items of the collection .
EXAMPLE: An example of use of such restriction can be found in the constraint:
forces that all items of the collection mention at least two attributes from the list of attributes . In this context, this stems from the equality . This allows for retrieving the third attribute from the values of the two others.
is an argument of type ,
is an attribute of the collection denoted by . This attribute should be of type .
This restriction forces that all collections denoted by have the same number of items.
EXAMPLE: An example of use of such restriction can be found in the constraint corresponds to the third item of the example presented at page 2.2.2.: forces all the items of the collection to be constituted from the same number of items (of type ). From a practical point of view, this forces the constraint to take as its argument a set of points, a set of rectangles, ... , a set of orthotopes.
-
is a term. A term is an expression that can be evaluated to one or possibly several integer values. The expressions we allow for a term are defined in the next paragraph.
is one of the following comparison operators , , , , , .
is a term.
Let and be the values respectively associated with and with . The restriction forces to hold for every and every .
A term is one of the following expressions:
, where is an integer. The corresponding value is .
, where is an argument of type . The value of is the number of items of the collection denoted by .
: denotes the value assigned to the attribute of the first item of the collection denoted by . It is equal to 0 if the collection is empty.
: denotes the value assigned to the attribute of the last item of the collection denoted by . It is equal to 0 if the collection is empty.
, : denotes the sum of the values assigned to the attribute of the collection denoted by , it is equal to 0 if the collection is empty; where is a list of collections attributes, each of them of the form (with ), is the sum of the values assigned to the attributes of the collections denoted by ().
, : denotes the difference between the maximum value and the minimum value plus one of the values assigned to the attribute of the collection denoted by , it is equal to 0 if the collection is empty; where is a list of collections attributes, each of them of the form (with ), is the difference between the maximum value and the minimum value plus one of the values assigned to the attributes of the collections denoted by ().
, : denotes the minimum over the values assigned to the attribute of the collection denoted by , it is equal to 0 if the collection is empty; where is a list of collections attributes, each of them of the form (with ), is the minimum over the values assigned to the attributes of the collections denoted by ().
, : denotes the maximum over the values assigned to the attribute of the collection denoted by , it is equal to 0 if the collection is empty; where is a list of collections attributes, each of them of the form (with ), is the maximum over the values assigned to the attributes of the collections denoted by ().
, : denotes the number of distinct values over the values assigned to the attribute of the collection denoted by , it is equal to 0 if the collection is empty; where is a list of collections attributes, each of them of the form (with ), is the number of distinct values over the values assigned to the attributes of the collections denoted by ().
, : denotes the product of the values assigned to the attribute of the collection denoted by , it is equal to 1 if the collection is empty; where is a list of collections attributes, each of them of the form (with ), is the product of the values assigned to the attributes of the collections denoted by ().
, : , where is a pure functional dependency constraint of the form (e.g. , , ) that computes a value from a collection of variables , and where is a collection with attribute denotes the of the values assigned to the attribute of the collection denoted by , it is equal to 0 if the collection is empty; where is a list of collections attributes, each of them of the form (with ), is the of the values assigned to the attributes of the collections denoted by ().
, where is an argument of type . The value of is the value of the corresponding argument.
, where is an argument of type . The value of will be the value assigned to variable .Restrictions are defined on the ground instance of a global constraint.
, where is an argument of type or . The values denoted by are all the values of the corresponding set.
, where is an argument of type and an attribute of of type or . The values denoted by are all the values corresponding to attribute for the different items of . When designates a domain variable we consider the value assigned to that variable.
, where is an argument of type and an attribute of of type or . The values denoted by are all the values belonging to the sets corresponding to attribute for the different items of . When designates a set variable we consider the values that finally belong to that set.
or , where and are terms. Let and denote the sets of values respectively associated with the terms and . Let , and , denote the minimum and maximum values of and . The value associated with is , while the value associated with is .
, where and are terms and one of the operators , , or . denotes an integer division, a division in which the fractional part is discarded. Let and denote the sets of values respectively associated with the terms and . The set of values associated with is .
- We can use a disjunction between two restrictions.
Finally, we can also use a constraint of the catalogue for expressing a restriction as long as that constraint is not defined according to the constraint under consideration. The constraint should have a graph-based or an automaton-based description so that its meaning is explicitly defined.