2.1.3. Filtering view
Once we know that a constraint for which not all variables are fixed yet is potentially feasible, the next question is to identify variable-value pairs of the form such that, if value is assigned to variable , the constraint has no solution. Since removing such values reduces a priori the search space, filtering is strongly supported by the implicit motto of constraint programming that the more you prune the better. Assuming that you already have a necessary and sufficient condition that can be evaluated in polynomial time for checking whether a constraint has at least one solution or not, you can directly reuse it for checking whether a value can be assigned or not to a variable. Since the number of variable-value pairs to check may be quadratic with respect to the total number of variables and values one usually prefers developing a dedicated filtering algorithm that is less costly than checking the feasibility condition on each variable-value pair.
For the constraint a first filtering algorithmΒ [Regin94] is based on a characterisation of the edges of the variable-value graph that belong to a maximum matching but not to all. A matching on a graph is a set of edges of the graph such that no two edges have a vertex in common; it is maximum if its number of edges is maximum. We first introduce a digraph that is associated with a matching that matches all variables of the constraint. The vertices of are defined as the variables and the values that can be assigned to the variables of the constraint. To each value that can be assigned to a variable corresponds an arc of from to . Finally, if value is matched to variable in the matching we add the reverse arc from to to the arcs of . Now a variable can be assigned a value if and only if and belong to the same strongly connected component of or if there is a path consisting of distinct vertices and arcs of that start with and ends up in an unmatched value with respect to matching , seeΒ [Thiel04].
Figure 2.1.1. Illustration of the filtering for with , , , , , , , with respect to the maximum matching defined by () and the corresponding digraph and its five strongly connected components s.c.c.Β (): 8 can be assigned to (blue arc) since the path ends up in an unmatched value, but 3 cannot be assigned to (red arc) since 3 and do not belong to the same strongly connected component and since there is no path from to the unique unmatched value 9.
Another filtering algorithm for based on Hall intervals just focuses on adjusting the minimum and maximum values of the variables. Given a set of domain variables, a Hall interval is an interval of values denoted by such that there are variables whose domains are contained in . A minimal Hall interval is a Hall interval that does not contain any Hall interval such that either or . Given a Hall interval and a variable whose domain is not included in but intersects , the idea is to adjust the minimum (respectively maximum) value of variable to the smallest (respectively largest) value that does not belong to . FigureΒ 2.1.2 illustrates this idea on the constraint with , , , , , , , , .
PartΒ (A) of FigureΒ 2.1.2 shows in light blue, in light pink and in light yellow the three minimal Hall intervals associated with the initial domains of variables .
corresponds to interval , which contains the domains of and .
corresponds to interval , which contains the domains of , and .
corresponds to interval , which contains the domains of and .
PartΒ (B) of FigureΒ 2.1.2 shows the first propagation step with respect to the Hall intervals , and . First note that variables and are the only variables whose domain is not included in a Hall interval. Consequently and are candidates for adjusting their minimum or maximum domain values.
Since the minimum value of , that is i.e. value 2, belongs to the Hall interval we adjust the minimum of to the smallest value that does not yet belong to any Hall interval, i.e. value 3.
Since the maximum value of , that is i.e. value 5, belongs to the Hall interval we adjust the maximum value of to the largest value that does not yet belong to any Hall interval, i.e. value 3.
Since the minimum value of , that is i.e. value 1, belongs to the Hall interval we adjust the minimum of to the smallest value that does not yet belong to any Hall interval, i.e. value 3.
Since the maximum value of , that is i.e. value 9, belongs to the Hall interval we adjust the maximum of to the largest value that does not yet belong to any Hall interval, that is i.e. value 7.
PartΒ (C) of FigureΒ 2.1.2 shows the second propagation step with respect to the new Hall interval . Now is the only variable whose domain is not included in a Hall interval so it is a candidate for adjusting its minimum or maximum domain value.
Since the minimum value of , i.e. value 3, belongs to the new Hall interval we adjust the minimum of to the smallest value that does not yet belong to any Hall interval, i.e. value 7.
Finally, partΒ (D) of FigureΒ 2.1.2 shows all the minimal Hall intervals after reaching the fix point of the filtering, where is a new minimal Hall interval.