5.376. stretch_path
DESCRIPTION | LINKS | GRAPH | AUTOMATON |
- Origin
- Constraint
- Usual name
- Arguments
- Restrictions
- Purpose
In order to define the meaning of the constraint, we first introduce the notions of stretch and span. Let be the number of variables of the collection . Let be consecutive variables of the collection of variables such that the following conditions apply:
All variables take a same value from the set of values of the attribute,
or is different from ,
or is different from .
We call such a set of variables a stretch. The span of the stretch is equal to , while the value of the stretch is . We now define the condition enforced by the constraint.
Each item of the collection enforces the minimum value as well as the maximum value for the span of a stretch of value over consecutive variables of the collection.
Note that:
Having an item with strictly greater than 0 does not mean that value should be assigned to one of the variables of collection . It rather means that, when value is used, all stretches of value must have a span that belong to interval .
A variable of the collection may be assigned a value that is not defined in the collection.
- Example
-
The constraint holds since the sequence contains four stretches , 3, , and respectively verifying the following conditions:
The span of the first stretch is located within interval (i.e.,Β the limit associated with value 6).
The span of the second stretch 3 is located within interval (i.e.,Β the limit associated with value 3).
The span of the third stretch is located within interval (i.e.,Β the limit associated with value 1).
The span of the fourth stretch is located within interval (i.e.,Β the limit associated with value 6).
- Typical
- Symmetries
Items of can be reversed.
Items of are permutable.
All occurrences of two distinct values in or can be swapped; all occurrences of a value in or can be renamed to any unused value.
- Usage
The articleΒ [Pesant01], which originally introduced the constraint, quotes rostering problems as typical examples of use of this constraint.
- Remark
We split the original constraint into the and the constraints that respectively use the and the arc generators. We also reorganise the parameters: the collection describes the attributes of each value that can be assigned to the variables of the constraint. Finally we skipped the pattern constraint that tells what values can follow a given value. A extension of this constraint (i.e.,Β stretch plus pattern), called , where one can specify for each value with a 0-1 variable, whether it should occur at least once or not at all, was proposed inΒ [HellstenPesantBeek04]. By reduction to Hamiltonian path it was shown that enforcing arc-consistency for is NP-hardΒ [HellstenPesantBeek04].
- Algorithm
A first filtering algorithm was described in the original article of G.Β PesantΒ [Pesant01]. A second filtering algorithm, based on dynamic programming, achieving arc-consistency is depicted in Β [Hellsten04], [HellstenPesantBeek04]. It also handles the fact that some values can be followed by only a given subset of values. An other alternative achieving arc-consistency is to use the automaton described in the Automaton slot.
- Systems
stretchPath in Choco, stretch in JaCoP.
- See also
common keyword: , Β (timetabling constraint), Β (timetabling constraint,sequence), Β (sequence), Β (sliding sequence constraint,timetabling constraint), Β (sliding sequence constraint), Β (sliding sequence constraint,timetabling constraint).
generalisation: Β ( replaced by ).
- Keywords
characteristic of a constraint: automaton, automaton without counters, reified automaton constraint.
combinatorial object: sequence.
constraint network structure: Berge-acyclic constraint network.
constraint type: timetabling constraint, sliding sequence constraint.
For all items of :
- Arc input(s)
- Arc generator
-
- Arc arity
- Arc constraint(s)
-
- Graph property(ies)
-
- Graph model
PartΒ (A) of FigureΒ 5.376.1 shows the initial graphs associated with values 1, 2, 3 and 6 of the Example slot. PartΒ (B) of FigureΒ 5.376.1 shows the corresponding final graphs associated with values 1, 3 and 6. Since value 2 is not assigned to any variable of the collection the final graph associated with value 2 is empty. The constraint holds since:
For value 1 we have one connected component for which the number of vertices 3 is greater than or equal to 2 and less than or equal to 4,
For value 2 we do not have any connected component,
For value 3 we have one connected component for which the number of vertices 1 is greater than or equal to 1 and less than or equal to 6,
For value 6 we have two connected components that both contain two vertices: this is greater than or equal to 2 and less than or equal to 2.
Figure 5.376.1. Initial and final graph of the constraint
(a) (b) During the presentation of this constraint at CP'2001 the following point was mentioned: it could be useful to allow domain variables for the minimum and the maximum values of a stretch. This could be achieved in the following way: the (respectively ) attribute would now be a domain variable that gives the size of the shortest (respectively longest) stretch. Finally within the Graph property(ies) slot we would replace (and ) by .
- Automaton
Let and respectively denote the quantities and . Furthermore, let , and , , respectively be shortcuts for the expressions , and . Without loss of generality, we assume that all the attributes of the items of the collection are at least equal to 1. The following automaton involving states only accepts solutions to the constraint. Automaton has the following states:
an initial state that is also an accepting state,
, a non-accepting state ,
, an accepting state .
Transitions of are defined in the following way:
, a transition from to labelled by condition ,
a transition from to labelled by condition ,
, a transition from to labelled by condition ,
, a transition from to labelled by condition ,
, a transition from to labelled by condition .
FigureΒ 5.376.2 depicts the automaton associated with the constraint of the Example slot. Transitions labels 0, 1, 2, 3 and 4 respectively correspond to the conditions , , , , (since values 1, 2, 3 and 6 respectively correspond to the values of the first, second, third and fourth item of the collection). The constraint holds since the corresponding sequence of visited states, , ends up in an accepting state (i.e.,Β accepting states are denoted graphically by a double circle in the figure).
Figure 5.376.2. Automaton of the constraint of the Example slot (states related to a same stretch have the same colour)