3.7.105. Flow
A constraint for which there is a filtering algorithm based on an algorithm that finds a feasible flow in a graph. The graph is usually constructedSometimes it is also constructed from the reformulation of a global constraint in term of a conjunction of linear constraints. This is for instance the case for the and the global constraints. from the variables of the constraint as well as from their potential values. The usual game is to come up with a flow model such that there exists a one to one correspondence between feasible flows in the flow model and solutions to the constraint, so that detecting arcs that cannot carry any flow in any feasible flow will lead removing some values from the domains of some variables. The next sections provide standard flow models for the , the , the , the , the , the , and the constraints.
A.Β Flow models forΒ theΒ Β and theΒ Β constraints
FigureΒ 3.7.28 presents flow models for the and the constraints. Blue arcs represent feasible flows respectively corresponding to the solutions and , while red arcs correspond to arcs that cannot carry any flow if the constraint has a solution. TablesΒ 3.7.27 andΒ 3.7.27 respectively provide the initial domains of the variables we assume for the and constraints.
1 | 3 | 5 | |||
2 | 4 |
1 | 3 | 5 | |||
2 | 4 |
Figure 3.7.28. Flow models for the and the constraints described in TablesΒ 3.7.27 andΒ 3.7.27: in both cases a first layer consists of the variables of the constraint and a second layer corresponds to the values that can be assigned to the variables; each arc has a lower and upper capacity regarding the flow it can carry; all variables (with ) such that the minimum capacity of the arc from to is equal to 1 must be assigned distinct values.

Within the context of the constraint the assignments , and are forbidden since values 1 and 2 must already be assigned to variables and . Finally the assignments and are also forbidden since values 1, 2 and 3 must be assigned to variables , and .
Within the context of the constraint, the assignment does not matter at all since the position of within (i.e.,Β positionΒ 4) does not belong to the set of variables positions . We can only prune according to those variables that for sure should be assigned distinct values. Consequently and are forbidden since values 1 and 2 must already be assigned to and . Finally the assignment is also forbidden since values 1, 2 and 3 must be assigned to , and .
B.Β Flow models for the Β and the Β constraints
Figure 3.7.29. Flow models for the and the constraints described in TablesΒ 3.7.29 andΒ 3.7.29: in both cases a first layer consists of the variables of the constraint and a second layer corresponds to the values that can be assigned to the variables (in the second model, the loop node represents an anonymous value corresponding to assignments of the form ); each arc has a lower and upper capacity regarding the flow it can carry; arcs entering a node associated with a variable must carry a flow of 1 since each variable must be assigned a single value, while arcs exiting a node associated with a value have a capacity set accordingly the last argument of the constraint (i.e., the collection of values ).

1 | 5 | 1 | 5 | ||||
2 | 6 | 2 | |||||
3 | 7 | 3 | |||||
4 | 4 |
1 | 5 | loop | 4 | ||||
2 | 6 | 1 | 5 | ||||
3 | 7 | 2 | |||||
4 | 3 |
FigureΒ 3.7.29 presents flow models for the and the constraints. Blue arcs represent feasible flows respectively corresponding to the solutions and , while red arcs correspond to arcs that cannot carry any flow if the constraint has a solution:
Within the context of the constraint variables , , and take their values within the set . Since each value in can be used at most 2 times, variables different from , , , cannot be assigned a value in . Consequently, , and . Since value 3 is the only remaining value for variable , and since value 3 can be assigned to at most one variable, the assignments and are also forbidden.
-
On the one hand we should have exactly two assignments of the form (), since the first and second arguments of the constraint are both set to two. Since the two variables and are the only variables such that we must have and , i.e.Β and .
On the other hand, since we should have at least assignments of the form () and since only 5 variables (with ) can be assigned a value in with , these variables should not be assigned a value outside interval , i.e.Β and .
C.Β Flow models for the Β and theΒ Β constraints
FigureΒ 3.7.30 presents flow models for the and the constraints. Blue arcs represent feasible flows respectively corresponding to the solutions and , while red arcs correspond to arcs that cannot carry any flow if the constraint has a solution. Within the context of the constraint, the assignment is forbidden since . Consequently and, since is the only variable of that can be assigned value 2, the assignment is forbidden. Now since the assignment is also forbidden. Finally is forbidden since .
Figure 3.7.30. Flow models for the and the constraints described in TablesΒ 3.7.30 andΒ 3.7.30: in both cases a first layer consists of the variables of the first argument of both constraints, a second layer corresponds to the values that can be assigned to the variables and (i.e.,Β the first and second arguments), and a third layer consists of the variables of the second argument of both constraints; there is an arc from a variable (resp.Β ) to a value if, and only if, value can be assigned to variable (resp.Β ); each arc has a lower and upper capacity regarding the flow it can carry; since for both constraints each value assigned to a variable of the second argument must also correspond to a value assigned to a variable of the first argument the arcs exiting the must carry a flow of 1.

1 | 1 | ||
2 | 2 | ||
3 |
1 | 1 | ||
2 | 2 | ||
3 | 3 |
D.Β Flow model for the Β constraint
1 | 1 | 1 | 4 | ||||
2 | 2 | 2 | 5 | ||||
3 | 3 | 3 | 6 |
FigureΒ 3.7.31 presents a flow model for the constraint. Blue arcs represent the feasible flow corresponding to the solution , while red arcs correspond to arcs that cannot carry any flow if the constraint has a solution. The assignment is forbidden since . Consequently and, since is the only variable of that can be assigned value 2, the assignment is forbidden. Now since the assignment is also forbidden. The assignment is forbidden since . Finally , and are also forbidden since value 4 must be assigned to at least two variables.
Figure 3.7.31. Flow model for the constraint described in TableΒ 3.7.30: in both cases a first layer consists of the variables of the first argument of the constraint, a second (resp.Β third) layer corresponds to the values that can be assigned to the variables (resp.Β ), and a fourth layer consists of the variables of the second argument of the constraint; each arc has a lower and upper capacity regarding the flow it can carry; values are duplicated in two layers in order to model the minimum and maximum number of occurrences of each value; there is an arc from a variable (resp.Β ) to a value if, and only if, value can be assigned to variable (resp.Β ); since each variable (resp.Β ) must be assigned a value the arcs exiting (resp.Β entering ) must carry a flow of 1.
