You are on page 1of 1

82 Problem reduction

constraint are ordered. In other words, if Cx,y is a constraint in the problem, then
both x→y and y→x are put into Q. AC-1 examines every x→y in Q, and deletes
from Dx all those values which do not satisfy Cx,y. If any value is removed, all the
constraints will be examined again. AC-1 calls the procedure Revise_Domain,
which is shown below:

PROCEDURE Revise_Domain(x→y, (Z, D, C)):


/* side effect: Dx in the calling procedure may be reduced*/
BEGIN
Deleted ← False;
FOR each a ∈ Dx DO
IF there exists no b ∈ Dy such that satisfies((<x,a><y,b>), Cx,y)
THEN
BEGIN
Dx ← Dx − {a};
Deleted ← True;
END
return(Deleted)
END /* of Revise_Domain */

Revise_Domain(x→y, (Z, D, C)) deletes all the values from the domain of x which
do not have compatible values in the domain of y. The domain of y will not be
changed by Revise_Domain(x→y, (Z, D, C)). The boolean value Deleted which is
returned by Revise_Domain indicates whether or not a value has been deleted.

The post-condition of the procedure AC-1 is more than AC. In fact, it achieves NC
and AC (i.e. AC-1 achieves strong 2-consistency).

When there are e edges in the constraint graph, the queue Q in AC-1 will have 2e
elements. The REPEAT loop in AC-1 will terminate only when no value is deleted
from any domain. In the worst case one element is deleted in each iteration of the
REPEAT loop. If a is the maximum number of elements in the domains and n is the
number of variables, then there are at most na elements to be deleted, and conse-
quently the REPEAT loop will terminate in no more than na iterations. Each itera-
tion requires in the worst case 2e calls to Revise_Domain. Each Revise_Domain
call examines a2 pairs of labels. Therefore, the worst case time complexity of AC-1
is O(a3ne). To represent a CSP, we need O(na) space to store the possible labels and
O(e) space to store the constraints. So the space complexity of AC-1 is O(e + na). If
constraints are represented by sets of compound labels, then in the worst case one
needs O(n2a2) space to store the constraints.

You might also like