5.197. interval_and_count
DESCRIPTION | LINKS | GRAPH | AUTOMATON |
- Origin
- Constraint
- Arguments
- Restrictions
- Purpose
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 forces 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 .
- Example
-
Figureย 5.197.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.197.1. The solution to the Example slot with the use of each interval
- Typical
- Symmetries
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 ).
- Arg. properties
Contractible wrt. .
Contractible wrt. .
- Usage
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.
- Remark
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.
- Reformulation
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
assignment dimension removed: ย (assignment dimension corresponding to intervals is removed).
related: ย ( constraint replaced by ).
- Keywords
-
characteristic of a constraint: coloured, automaton, automaton with array of counters.
constraint type: timetabling constraint, resource constraint, temporal constraint.
- Arc input(s)
- Arc generator
-
- Arc arity
- Arc constraint(s)
- Sets
-
- 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.197.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.197.2. Initial and final graph of the constraint
(a) (b)
- Automaton
Figureย 5.197.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.197.3. Automaton of the constraint