5.196. int_value_precede_chain
DESCRIPTION | LINKS | AUTOMATON |
- Origin
- Constraint
- Synonyms
, , .
- Arguments
- Restrictions
- Purpose
Assuming denotes the number of items of the collection, the following condition holds for every : When it is defined, the first occurrence of the value of the collection should be preceded by the first occurrence of the value of the collection.
- Example
-
The constraint holds since within the sequence 4, 0, 6, 1, 0:
The first occurrence of value 4 occurs before the first occurrence of value 0.
The first occurrence of value 0 occurs before the first occurrence of value 1.
- Typical
- Symmetry
An occurrence of a value of that does not occur in can be replaced by any other value that also does not occur in .
- Arg. properties
Contractible wrt. .
Suffix-contractible wrt. .
Aggregate: , .
- Usage
The constraint is useful for breaking symmetries in graph colouring problems. We set a constraint on all variables associated with the vertices of the graph to colour, where we state that the first occurrence of colour should be located before the first occurrence of colour within the sequence .
FigureΒ 5.196.1 illustrates the problem of colouring earth and mars from Thom Sulanke. PartΒ (A) of FigureΒ 5.196.1 provides a solution where the first occurrence of each value of , is located before the first occurrence of value . This is obtained by using the following constraints:
PartΒ (B) provides a symmetric solution where the value precedence constraints between the pairs of values , , , and are all violated (each violation is depicted by a dashed arc).
Figure 5.196.1. Using the constraint for breaking symmetries in graph colouring problems; there is an arc between the first occurrence of value in the sequence of variables , , , , , , , , , , , and the first occurrence of value (a plain arc if the corresponding value precedence constraint holds, a dashed arc otherwise)
- Remark
When we have more than one class of interchangeable values (i.e.,Β a partition of interchangeable values) we can use one constraint for breaking value symmetry in each class of interchangeable values. However it was shown inΒ [Walsh07] that enforcing arc-consistency for such a conjunction of constraints is NP-hard.
- Algorithm
The 2004 reformulationΒ [Beldiceanu04] associated with the automaton of the Automaton slot achieves arc-consistency since the corresponding constraint network is a Berge-acyclic constraint network. Later on, another formulation into a sequence of ternary sliding constraints was proposed byΒ [Walsh06]. It also achieves arc-consistency for the same reason.
- Systems
precede in Gecode, value_precede_chain in MiniZinc.
- See also
specialisation: Β ( of at least 2 replaced by of 2 ).
- Keywords
characteristic of a constraint: automaton, automaton without counters, reified automaton constraint.
constraint network structure: Berge-acyclic constraint network.
constraint type: order constraint.
symmetry: symmetry, indistinguishable values, value precedence.
- Automaton
FigureΒ 5.196.2 depicts the automaton associated with the constraint. Let and respectively denote the number of variables of the collection and the number of values of the collection. Let be the variable of the collection. Let denote the value of the collection.
Figure 5.196.2. Automaton of the constraint (state means that (1)Β each value was already encountered at least once, and that (2)Β value was not yet found)
Figure 5.196.3. Hypergraph of the reformulation corresponding to the automaton of the constraint (since all states of the automaton are accepting there is no restriction on the last variable )
We now show how to construct such an automaton systematically. For this purpose let us first introduce some notations:
Without loss of generality we assume that we have at least two values (i.e.,Β ).
Let be the set of values that can be potentially assigned to a variable of the collection, but which do not belong to the values of the collection (i.e.,Β .
The states and transitions of the automaton are respectively defined in the following way:
We have states labelled from which is the initial state. All states are accepting states.
We have the following three sets of transitions:
For all , a transition from to labelled by value . Each transition of this type will be triggered on the first occurrence of value within the variables of the collection.
For all and for all , a self loop on labelled by value . Such transitions encode the fact that we stay in the same state as long as we have a value that was already encountered.
If the set is not empty, then for all a self loop on labelled by the fact that we take a value not in (i.e.,Β a value in ). This models the fact that, encountering a value that does not belong to the set of values of the collection, leaves us in the same state.