• No results found

Search Algorithms for Agents

4.2 Constraint Satisfaction

4.2.2 Filtering Algorithm

In the filtering algorithm [36], each process communicates its domain to its neighbors and then removes values that cannot satisfy constraints from its domain. More specifically, a process xi performs the following procedure revise (xi, xj)

for each neighboring process xj.

procedure revise (xi, xj)

for all do

if there is no value

Image-

0301 such that vj is consistent with vi

then delete vi from Di; end if; end do;

If some value of the domain is removed by performing the procedure revise, process xi sends the new domain to

neighboring processes. If xi receives a new domain from a neighboring process xj, the procedure revise (xi, xj) is

performed again. The execution order of these processes is arbitrary.

We show an example of an algorithm execution in Figure 4.5. The example problem is a smaller version of the 8-queens problem (3-queens problem). There are three variables x1, x2, x3, whose domains are {1,2,3}. Obviously, this problem is over-constrained and has no solution. After exchanging the domains (Figure 4.5 (a)), X1 performs revise (x1, x2) and removes 2 from its domain (if x1 = 2, none of x2's values satisfies the constraint with x1). Similarly, x2 performs revise (x2.

x3), x3 performs revise (x3, x2), and each process removes 2 from its domain. After exchanging the new domains (Figure 4.5 (b)), x1 performs revise (x1, x3), and removes I and 3 from its domain. The domain of x1 then becomes an empty set, so the process discovers that this problem has no solution.

By applying the filtering algorithm, if a domain of some variable becomes an empty set, the problem is over-constrained and has no solution. Also, if each domain has a unique value, then the combination of the remaining values becomes a solution. On the other hand, if there exist multiple values for some variable, we cannot tell whether the problem has a solution or not, and further trial-and-error search is required to find a solution.

are red or blue, this problem is over-constrained. However, in the filtering algorithm, no process can remove a value from its domain. Furthermore, in the 8-queens problem (which has many solutions), no process can remove a value from its domain by using the filtering algorithm.

Since the filtering algorithm cannot solve a problem in general, it should be considered a preprocessing procedure that is invoked before the application of other search methods. Even though the filtering algorithm alone cannot solve a

problem, reducing the domains of variables for the following search procedure is worthwhile.

Page 171

Figure 4.5

Figure 4.6

Example that the filtering algorithm cannot solve.

Page 172 4.2.3 Hyper-Resolution-Based Consistency Algorithm

The filtering algorithm is one example of a general class of algorithms called consistency algorithms. Consistency algorithms can be classified by the notion of k-consistency [9]. A CSP is k-consistent iff the following condition is satisfied.

• Given any instantiation of any k-1 variables satisfying all the constraints among those variables, it is possible to find an instantiation of any kth variable such that these k variable values satisfy all the constraints among them.

The filtering algorithm achieves 2-consistency (also called arc-consistency), i.e., any variable value has at least one consistent value of another variable. A k-consistency algorithm transforms a given problem into an equivalent (having the same solutions as the original problem) k-consistent problem. If the problem is k-consistent and j-consistent for all j

< k, the problem is called strongly k-consistent. If there are n variables in a CSP and the CSP is strongly n-consistent, then a solution can be obtained immediately without any trial-and-error exploration, since for any instantiation of k - 1 variables, we can always find at least one consistent value for k-th variables.

In the following, we describe a consistency algorithm using the the hyper-resolution rule [6]. In this algorithm, all constraints are represented as a nogood, which is a prohibited combination of variable values. For example, in Figure 4.6, a constraint between xl and x2 can be represented as two nogoods {x1 = red, x2 = red} and {x1 = blue, x2 = blue}. A new nogood is generated from several existing nogoods by using the hyper-resolution rule. For example, in Figure 4.6, there are nogoods such as {xl = red, x2 = red} and {x1 = blue, x3 = blue}. Furthermore, since the domain of xl is {red,

blue}, (x1 = red) (x1 = blue) holds. The hyper-resolution rule combines nogoods and the condition that a variable takes one value from its domain, and generates a new nogood, e.g., {x2 = red, x3 = blue}.

The meaning of this nogood is as follows. If x2 is red, xl cannot be red. Also, if x3 is blue, x1 cannot be blue. Since x1 is either red or blue, if x2 is red and x3 is blue, there is no possible value for xl. Therefore, this combination cannot satisfy all constraints.

Page 173 In the hyper-resolution-based consistency algorithm, each process represents its constraints as nogoods. The process then generates new nogoods by combining the information about its domain and existing nogoods using the hyper-resolution rule. A newly obtained nogood is communicated to related processes. If a new nogood is communicated, the process tries to generate further new nogoods using the communicated nogood.

For example, in Figure 4.6, assume xl generates a new nogood {x2 = red, x3 = blue} using nogood {x1 = red, x2 = red} and nogood {xl = blue, x3 = blue}. This nogood is communicated to x2 and x3. x2 generates a new nogood {x3 = blue} using this communicated nogood and nogood {x2 = blue, x3 = blue}. Similarly, xl generates a new nogood {x2 = blue, x3 = red} from {xl = blue, x2 = blue} and {x1 = red, x3 = red}. x2 generates a new nogood {x3 = red} using this nogood and nogood {x2 = red, x3 = red}. Then, x3 can generate {} from nogood{x3 = blue} and {x3 = red}, which is an empty set. Recall that a nogood is a combination of variable values that is prohibited. Therefore, a superset of a nogood cannot be a solution. Since any set is a superset of an empty set, if an empty set becomes a nogood, the problem is over-constrained and has no solution.

The hyper-resolution rule can generate a very large number of nogoods. If we restrict the application of the rules so that only nogoods whose lengths (the length of a nogood is the number of variables that constitute the nogood) are less than k are produced, the problem becomes strongly k-consistent.