5.186. length_first_sequence
| DESCRIPTION | LINKS | AUTOMATON |
- Origin
- Constraint
- Arguments
- Restrictions
- Purpose
is the length of the maximum sequence of variables that take the same value that contains the first variable of the collection (or 0 if the collection is empty).
- Example
-
The constraint holds since the sequence associated with the first value of the collection spans over three consecutive variables.
- Symmetry
All occurrences of two distinct values of can be swapped; all occurrences of a value of can be renamed to any unused value.
- Reformulation
Without loss of generality let assume that the collection has more than one variable. By introducing 0-1 variables, the constraint can be expressed in term of reified constraints and one arithmetic constraint (i.e.,Β a constraint). We first introduce variables that are respectively set to 1 if and only if two given consecutive variables of the collection are equal:
Β Β Β ,
Β Β Β ,
Β Β Β
Β Β Β .
We then introduce variables that are respectively associated to the different sliding sequences starting on the first variable of the sequence . Variable is set to 1 if and only if :
Β Β Β ,
Β Β Β
Β Β Β
Β Β Β
Β Β Β .
Finally we state the following arithmetic constraint:
Β Β Β .
- See also
- Keywords
characteristic of a constraint: automaton, automaton with counters.
combinatorial object: sequence.
constraint network structure: sliding cyclic(1) constraint network(2).
- Automaton
FigureΒ 5.186.1 depicts the automaton associated with the constraint. To each pair of consecutive variables of the collection corresponds a signature variable . The following signature constraint links , and : .
Figure 5.186.1. Automaton of the constraint when

Figure 5.186.2. Hypergraph of the reformulation corresponding to the automaton of the constraint
