
AI Magazine Volume 13 Number 1 (1992) (© AAAI) Articles Algorithms for Constraint- Satisfaction Problems: A Survey Vipin Kumar A large number of problems in AI and other areas of computer science can be viewed as special cases of the constraint-satisfaction problem. Some examples are machine vision, belief maintenance, scheduling, temporal reasoning, graph problems, floor plan design, the planning of genetic experiments, and the satisfiability problem. A number of different approaches have been devel- oped for solving these problems. Some of them use constraint propagation to simplify the original problem. Others use backtracking to directly search for possible solutions. Some are a combination of these two techniques. This article overviews many of these approaches in a tutorial fashion. 32 AI MAGAZINE Copyright ©1992, AAAI/$2.00 Articles A large number of problems in…computer science can be viewed as special cases of the constraint-satisfaction problem… A large number of problems in AI and other areas of computer science can be viewed as V V4 special cases of the constraint-satisfaction 1 problem (CSP) (Nadel 1990). Some examples V V are machine vision (Chakravarty 1979; Davis 2 3 and Rosenfeld 1981; Mackworth 1977b; Mon- tanari 1974; Hummel 1976), belief mainte- nance (Dechter 1987; Dechter and Pearl V4 1988b; Dhar and Croker 1990), scheduling V1 (Dhar and Ranganathan 1990; Fox 1987; Fox, V Sadeh, and Baykan 1989; Petrie et al. 1989; 3 Prosser 1989; Rit 1986), temporal reasoning V2 (Allen 1983, 1984; Dechter, Meiri, and Pearl 1991; Vilain and Kautz 1986; Tsang 1987), graph problems (McGregor 1979; Bruynooghe Figure 1. An Example Map-Coloring Problem and 1985), floor plan design (Eastman 1972), the Its Equivalent Constraint-Satisfaction Problem. planning of genetic experiments (Stefik 1981), the satisfiability problem (Zabih and McAllester 1988), circuit design (de Kleer and the end points of the arc. A unary constraint Sussman 1980), machine design and manu- is represented by an arc originating and ter- facturing (Frayman and Mittal 1987; Nadel minating at the same node. I often use the and Lin 1991; Navinchandra 1990), and diag- term CSP to refer to the equivalent constraint nostic reasoning (Geffner and Pearl 1987). graph and vice versa. The scope of this article is restricted to For example, the map-coloring problem can those constraint-satisfaction problems that be cast as CSP. In this problem, we need to can be stated as follows: We are given a set of color (from a set of colors) each region of the variables, a finite and discrete domain for map such that no two adjacent regions have each variable, and a set of constraints. Each the same color. Figure 1 shows an example constraint is defined over some subset of the map-coloring problem and its equivalent CSP. original set of variables and limits the combi- The map has four regions that are to be col- nations of values that the variables in this ored red, blue, or green. The equivalent CSP subset can take. The goal is to find one assign- has a variable for each of the four regions of ment to the variables such that the assign- the map. The domain of each variable is the ment satisfies all the constraints. In some given set of colors. For each pair of regions problems, the goal is to find all such assign- that are adjacent on the map, there is a binary ments. More general formulations of CSP can constraint between the corresponding vari- be found in Freuder (1989); Gu (1889); Mack- ables that disallows identical assignments to worth, Mulder, and Havens (1985); Mittal these two variables. and Frayman (1987); Mittal and Falkenhainer (1990); Freeman-Benson, Maloney, and Born- ing (1990); Navinchandra and Marks (1987); Backtracking: A Method for Shapiro and Haralick (1981); and Ricci (1990). Solving the Constraint- I further restrict the discussion to CSPs in Satisfaction Problem which each constraint is either unary or binary. I refer to such CSP as binary CSP. It is possible CSP can be solved using the generate-and-test to convert CSP with n-ary constraints to paradigm. In this paradigm, each possible another equivalent binary CSP (Rossi, Petrie, combination of the variables is systematically and Dhar 1989). Binary CSP can be depicted generated and then tested to see if it satisfies by a constraint graph in which each node all the constraints. The first combination that represents a variable, and each arc represents satisfies all the constraints is the solution. The a constraint between variables represented by number of combinations considered by this SPRING 1992 33 Articles method is the size of the Cartesian product of V all the variable domains. 3 A more efficient method uses the backtrack- green ing paradigm. In this method, variables are instantiated sequentially. As soon as all the V1 V2 variables relevant to a constraint are instanti- ated, the validity of the constraint is checked. red green blue blue green If a partial instantiation violates any of the constraints, backtracking is performed to the most recently instantiated variable that still Figure 2. A Constraint Graph for Some has alternatives available. Clearly, whenever a Map-Coloring Problems. partial instantiation violates a constraint, backtracking is able to eliminate a subspace from the Cartesian product of all variable domains. The backtracking method essential- Propagating Constraints ly performs a depth-first search (Kumar 1987) of the space of potential CSP solutions. Arc (Vi, Vj) is arc consistent if for every value Although backtracking is strictly better than x in the current domain of Vi, there is some the generate-and-test method, its run-time value y in the domain of Vj such that V1 = x complexity for most nontrivial problems is and Vj = y are permitted by the binary con- still exponential. One of the reasons for this straint between Vi and Vj . The concept of poor performance is that the backtracking arc consistency is directional; that is, if an arc paradigm suffers from thrashing (Gaschnig (Vi, Vj) is consistent, then it does not auto- 1979); that is, search in different parts of the matically mean that (Vj, Vi) is also consistent. space keeps failing for the same reasons. The Consider the constraint graph of another simplest cause of thrashing concerns the map-coloring problem given in figure 2. In unary predicates and is referred to as node this constraint graph, arc (V3,V2) is consistent inconsistency (Mackworth 1977a). If the domain because green is the only value in the domain Di of a variable Vi contains a value a that of V3, and for V3 = green, at least one assign- does not satisfy the unary constraint on Vi, ment for V2 exists that satisfies the constraint then the instantiation of Vi to a always results between V2 and V3. However, arc (V2, V3) is in an immediate failure. Another possible not consistent because for V2 = green, there is source of thrashing is illustrated by the fol- no value in the domain of V3 that is permitted lowing example: Suppose the variables are by the constraint between V2 and V3. instantiated in the order V1, V2, …,Vi, …, Vj, Clearly, an arc (Vi, Vj) can be made consis- …, VN. Suppose also that the binary con- tent by simply deleting those values from the straint between Vi and Vj is such that for Vi domain of Vi for which the previous condition = a, it disallows any value of Vj. In the back- is not true. (Deletions of such values do not track search tree, whenever Vi is instantiated eliminate any solution of original CSP.) The to a, the search will fail while instantiation is following algorithm, taken from Mackworth tried with Vj (because no value for Vj would (1977a), does precisely that. be found acceptable). This failure will be procedure REVISE(Vi, Vj); repeated for each possible combination that DELETE ← false; ε the variables Vk (i < k < j) can take. The cause for each x Di do ∈ of this kind of thrashing is referred to as a if there is no such vj Dj lack of arc consistency (Mackworth 1977a). such that (x, vj ) is consistent, Other drawbacks of simple backtracking are then discussed in Intelligent Backtracking and delete x from Di ; Truth Maintenance. DELETE ← true; Thrashing because of node inconsistency endif; can be eliminated by simply removing those endfor; values from the domains Di of each variable return DELETE; Vi that do not satisfy unary predicate Pi. end_REVISE Thrashing because of arc inconsistency can To make every arc of the constraint graph be avoided if each arc (Vi, Vj) of the constraint consistent, it is not sufficient to execute graph is made consistent before the search REVISE for each arc just once. Once REVISE starts. In the next section, I formally define reduces the domain of some variable Vi, then the notion of arc consistency and consider each previously revised arc (Vj, Vi) has to be algorithms for achieving it. revised again because some of the members 34 AI MAGAZINE Articles variation (called AC-3) of this algorithm that (a) V1 eliminates this drawback. This algorithm (given here) performs re-revision only for red, green not-same not-same those arcs that are possibly affected by a pre- V vious revision. The reader can verify that in 2 V3 not-same AC-3, after applying REVISE(V , V ), it is not red, green red, green k m necessary to add arc (Vm, Vk) to Q. The reason is that none of the elements deleted from the domain of Vk during the revision of arc (Vk,Vm) provided support for any value in the (b) V1 current domain of Vm. blue, green procedure AC-3 not-same not-same ← ε ≠ Q {(Vi, Vj) arcs(G), i j}; V 2 V3 while Q not empty not-same red, green red, green select and delete any arc (Vk, Vm) from Q; if (REVISE(Vk, Vm) then ← Q » {(Vi, Vk) such that (Vi, V ) ε arcs(G), i ≠ k, i ≠ m} (c) V k 1 endif; blue, green not-same + endwhile; (V = blue & V = red not-same 1 3 not allowed) end_AC V 2 V3 The well-known algorithm of Waltz (1975) not-same red, green red, green is a special case of this algorithm and is equiv- alent to another algorithm, AC-2, discussed in Mackworth (1977a).
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages13 Page
-
File Size-