First consider the set of tasks of the collection, where each task has a specific colour that may not be initially fixed. Then consider the intervals of the form , where is an integer. The constraint enforces that, for each interval previously defined, the total number of tasks, which both are assigned to and take their colour in , does not exceed the limit .
Figure 5.168.1 shows the solution associated with the example. The constraint holds since, for each interval, the number of tasks taking colour 4 does not exceed the limit 2.
Figure 5.168.1. Solution with the use of each interval
can be increased.
Items of are permutable.
Items of are permutable.
One and the same constant can be added to the attribute of all items of .
An occurrence of a value of that belongs to the -th interval, of size , can be replaced by any other value of the same interval.
An occurrence of a value of that belongs to (resp. does not belong to ) can be replaced by any other value in (resp. not in ).
This constraint was originally proposed for dealing with timetabling problems. In this context the different intervals are interpreted as morning and afternoon periods of different consecutive days. Each colour corresponds to a type of course (i.e., French, mathematics). There is a restriction on the maximum number of courses of a given type each morning as well as each afternoon.
If we want to only consider intervals that correspond to the morning or to the afternoon we could extend the constraint in the following way:
We introduce two extra parameters and that correspond to non-negative integers such that is strictly less than ,
We add the following condition to the arc constraint:
Now, if we want to express a constraint on the morning intervals, we set to 0 and to 2.
Let denote the index of the last possible interval where the tasks can be assigned: . The constraint can be expressed in term of a set of reified constraints and of arithmetic constraints (i.e., constraints).
For each task of the collection we create a 0-1 variable that will be set to 1 if and only if task takes a colour within the set of colours :
For each task and for each interval we create a 0-1 variable that will be set to 1 if and only if, both task takes a colour within the set of colours , and the origin of task is assigned within interval :
Finally, for each interval , we impose the sum to not exceed the maximum allowed capacity .
- See also
related: ( constraint replaced by ).
- Arc input(s)
- Arc generator
- Arc arity
- Arc constraint(s)
- Constraint(s) on sets
- Graph model
We use a bipartite graph where each class of vertices corresponds to the different tasks of the collection. There is an arc between two tasks if their origins belong to the same interval. Finally we enforce an constraint on each set of successors of the different vertices of the final graph. This put a restriction on the maximum number of tasks of for which the colour attribute takes its value in .
Parts (A) and (B) of Figure 5.168.2 respectively show the initial and final graph associated with the Example slot. Each connected component of the final graph corresponds to items that are all assigned to the same interval.
Figure 5.168.2. Initial and final graph of the constraint
Figure 5.168.3 depicts the automaton associated with the constraint. Let be the attribute of the item of the collection. To each pair corresponds a signature variable as well as the following signature constraint: .
Figure 5.168.3. Automaton of the constraint