Purdue University
Purdue e-Pubs ECE Technical Reports
Electrical and Computer Engineering
12-1-1997
FASTER MUSE CSP ARC CONSISTENCY ALGORITHMS Mary P. Harper Purdue University School of Electrical and Computer Engineering
Christopher M. White Purdue University School of Electrical and Computer Engineering
Randall A. Helzerman Purdue University School of Electrical and Computer Engineering
Stephen A. Hockema Purdue University School of Electrical and Computer Engineering
Harper, Mary P.; White, Christopher M.; Helzerman, Randall A.; and Hockema, Stephen A., "FASTER MUSE CSP ARC CONSISTENCY ALGORITHMS" (1997). ECE Technical Reports. Paper 77. http://docs.lib.purdue.edu/ecetr/77
This document has been made available through Purdue e-Pubs, a service of the Purdue University Libraries. Please contact
[email protected] for additional information.
FASTER MUSE CSP ARC CONSISTENCY ALGORITHMS
TR-ECE 97-14 DECEMBER 1997
Faster
MUSE CSP Arc Consistency Algorithms* Mary P. Harper, Christopher M. White,
Randall A. Helzerman, and Stephen A. Hockema
School of Electrical and Computer Engineering
1285 Electrical Engineering Building Purdue University, West Lafayette, IN 47907
'This research was su p ported by a grant from the Intel Research Council and the National Science Foundation under Grant No. IRI-9704358.
Abstract MUSE CSP (Multiply SEgmented Constraint Satisfaction Problem) [5, 61 is an extension to the constraint satisfaction problem (CSP) which is especially useful for problems that segment into riultiple instances of CSP that share variables. In Belzerman and Harper [6], the concepts of MUSE node, arc, and path consistency were defined and algorithms for MUSE arc consistency, MUSE AC-1, and MUSE path consistency were developed. MUSE AC-1 is similar to the CSP arc consistency algorithm AC-4 [ l j ] . Recently, Bessikre developed a new algorithm, AC-6 [I], which has the same worst-case running time as AC-4 and is faster than AC-3 and AC-4 in practice. In this paper, we focus on developing two faster MUSE arc consistency algor~thms:MUSE AC-2 which directly applies Bessikre's method to improve upon MUSE AC-1, and MUSE AC-3, which uses our new "lazy" evaluation method for keeping track of the additional sets required by the MUSE approach. These new algorithms decrease the number of steps required to achieve arc ccnsistency in randomly generated MUSE CSP instances when compared to MUSE AC-1.
Keyvrords: Problem Solving, Constraint Satisfaction, MUSE arc consistency.
1
Introduction
Constraint satisfaction, with a rich history in Artificial Intelligence, provides a convenient way t o represent and solve certain types of problems. In general, these are problems t h a t can be solved by assigning mutually compa.tible values t o a predetermined number of variahlles under a set of constraints.. This approach has been used in a variety of disciplines including ma.chine vision, belief maintena.nce, temporal reasoning, graph theory, circuit design, diagnostic reasoning, and natural language processing. Constri~intDependency Grammar (CDG) parsing, as introduced by Maruya,ma [8, 9, 101, was framed as a constraint satisfaction problem (CSP); the parsing rules are the constraints and the solutions are t h e parses. Unfortunately, the C S P approach does not support t h e simultaneous analysis of sentences with multiple alternative lexical ca.tegories (e.g., can is a noun, verb, or modal) no]- multiple feature values (e.g., the as a determiner can modify nouns t h a t are third person singular or third person plural), nor the simultaneous parsing of sentences contained in a word graph produced by a speech recognizer. Hence, Harper and Helzerman [3] adapted the parsing algorithm i;o support the simultaneous parsing of alternative sentences resulting from lexical or feature ambiguity or from word segmentation ambiguity during speech recognition. From this work, t h e concepl, of a MUSE C S P (Multiply SEgmented Constraint Satisfaction PI-oblem) [ 5 , 61 was developed 1,o support t h e efficient simultaneous processing of multiple alternati~~re C S P problems. A MUSE ClSP is defined as follows: Definition 1 (MUSE CSP) N = { i ,j,. . .} is the set of nodes (or variables), with I N ) = n , C 2 N is a set of segments with 1x1= s, C = { a , 6,.. .) is the set of labels, with J L (= I , L Li = {altz E L and (i, a ) is admissible i n at least one se g ment}, R1 is a unary constraint, and ( i ,a ) is adinissible if R l (i, a ) , R2 is a binary constraint, (i,a ) - (j,b) is admissible if R2(i,a , j , b) T h e segments in C are the different sets of nodes representing C S P instances which are combined t o form a Iv[USE CSP. Since a MUSE C S P is represented as a directed acyclic graph, segments are defined as paths through the MUSE C S P from a special purpose s t a r t t o end node. Helzerman and Harper [6] also defined t h e concepts of MUSE node, arc, and path consistency and developed algorithms for MUSE arc consistency, MUSE AC-I, and h1USE path consistency, MUSE PC-1. These algorithms are similar t o the C S P arc consistency algorithm AC-4 [ l l ] and path consistency algorithm P'C-4 [2]. Although AC-4 has a worst-case running time of @(el2)(where e is t h e number of constraint arcs), AC-3 [7] with a worst-case running time of @(el3) often performs better than AC-4 in practice. Recently, Bessikre developed a new algorithm, AC-6 [I], which has t h e sarne worst-case running time as AC-4 and is faster than AC-3 and AC-4 in practice. In this paper, we focus on providing faster MUSE arc consistency algorithms by applying techniques similar t o those developed by Bessi kre. MUSE a,rc consistency, as the focus of this paper, is defined as follows:
Definition 2 (MUSE Arc Consistency) A n instance of MUSE CSP is said to be M U S E arc consistent if and only if,for every label a i n each domain Li there is at least one segment o whose nodes' domains contain at least one label b for which the binary constraint R2 holds, i.e.:
V ~ NE : V a ~ L , : 3 u E C : i E u A V j ' j u : j # i i 3 b E L:RZ(i,a,j,b) ~ When enforcing arc consistency in a CSP, a label a E L; can be eliminated from node i whenever any other domain L j has no labels that together with a satisfy the binary constraints. However, in a MUSE: CSP, before a label can be eliminated from a node, it must be no longer supported by the arcs of every segment in which it appears, as required by the above definition. Hence, there is more inforination that must be tracked in any NIUSE arc consistency algorithm. MUSE arc consistency is enforced by removing those labels in each L; that violate the conditions of Definition 2. MUSE AC-1 [6] builds and maintains several data structures defined in Figure 1, some that are similar to those used by AC-4 and some that are new (i.e., those below the double line in Figure l),t o allow it t o correctly perform this operation. As in AC-4, T\/IUSE AC-1 keeps track of how much support each label a E L; has from the labels in L j by counting the number that are compatible with a and storing that number in Counter[(i,j ) , a]. The algorithm also keeps track of the set of labels in L, that are compatible with a E L; as the set S[(i, j),a]. In AC-4, if Counter[(i, j),a] becomes zero, a can be immediately removed from L; because a could never appear in any solu1;ion. However, in the case of MUSE arc consistency, even though a doles not participate in a solution for any of the segments that contain i and j , there could be another :segment for which a would be perfectly legal. A label cannot become globally inadmissible until it is ~ncompatiblewith every segment. Hence, in MUSE CSP, if Counter[(i, j),a] is zero, the algorithm must record the
fact that a is illegal in the segment involving the variables i and j and propagate that information throughout the MUSE CSP. MUSE AC-1 uses the fact that the MUSE CSP is a DAG t o determine when labels become inadmissible either within a segment or globally. To do this, the algorithm uses four new sets: Prev-Suppc'rt, Next-Support, Local-Prev-Support, and Local-Next-Support, which are defined in Figure 1. For each variable i and j, j
# i,
and label n E L,, MUSE AC-1 keeps track of the
sets Prev-Support[(i, j),a] and Next-Support[(i, j),a]. Prev-Support[(i, j ) , a] keeps track of those variables that precede j and support a t least one label in L, and the label a in I.,; whereas, NextSupport[(i, j),a] tracks variables that follow j and meet the support criteria. If, during MUSE AC-1, either of these sets become empty, then a is no longer consistent with any segment involving the variables i and j. This segment information is very important for updating the sets that track the global admissibility of a label, which is monitored by the Local-Prev-Support and Local-NextSupport sets. For each variable i and each label a E L;, Local-Prev-Support(i, a) keeps track of the variables that precede i and support the label a E L;; whereas, Local-Nest-Support(i, a ) keeps track of those that follow i and support the label a. If either local set becomes empty, then a is no longer a palst of any MUSE arc consistent instance and should be eliminated frorn L; because it is
globally inadmissible. MUSE AC-1 uses the Counter array and S sets to keep track of the labels t,hat are supported in the MUSE CSP. If Counter[(i,j ) , a ] becomes 0, then [(i, j),a] is placed on .List (as in AC-4), indicating that a is inadmissible in all segments containing the variables i and j. When [ ( i , j ) ,a] is popped off of List during arc consistency, Counter[(j,i) , b] is decremented for all (j,b) E S[(i, j), a] (possibly resulting in [(j, i ) , b] being placed on List). The fact that a E L; is unsupported by the variable j is also used to determine whether other segments disallow a E
1:;.
Because of a's
loss of sup'port by the variable j, any variable k that precedes j in the DAG must determine whether j was its only successor supporting a E L;. In addition, any variable 1; that follows j in the DAG rnust determine whether j was its only predecessor supporting a E L , . This is done by determining whether Next-Support[(i, k), a] (if j was a successor) or Prev-Support[(i, k), a] (if j was a predecestor) becomes empty after
(2,
j) is removed from the set. If the set becomes empty, then
a is also inztdmissible in the segment involving i and k; if M[(i, k), a] # 1, then the tuple [(i, k), a] is placed on List and M[(i, k), a] is set to 1. Finally, if j directly precedes i in the MUSE DAG, then ( i , j ) is removed from Local-Prev-Support(i, a), and if j directly follows i, then (i, j ) is removed from Local-Next-Support(i, a). If either local set becomes empty, then a is removed from L; and additional tuples are stored on List t o clean up the Counters and DAG sets associated with the label a E L;.
+
The worst-case running time and space complexity of MUSE AC-1 is O(n2Z2 n31), where n is the numl~erof nodes in a MUSE CSP and 1 is the domain size. By comparison, the worst-case running time and space complexity for CSP arc consistency is O(n2Z2),assuming that there are n 2 constraint arcs. Note that for applications where 1 =
or C is a planar DAG (in terms of Prev-
7 ~ ,
Edge and Next-Edge, not E), the worst-case running times of the algorithms are the same order. Because MUSE AC-1 inherits AC-4's poor average-case performance, we can improve the averagecase running time of MUSE AC by using techniques similar t o those used by Bessikre t o develop AC-6. We first review Bessikre's AC-6 algorithm and then describe two new MUSE arc consistency algorithms: MUSE AC-2, which directly applies Bessikre's method t o improve upon MUSE AC-1, and MUSE AC-3, which, in addition t o Bessikre's method, uses our "lazy" evaluation method for keeping track of the Prev-Support, Next-Support, Local-Prev-Support, and Local-Next-Support sets.
To improve the average-case performance while maintaining the same worst-case time complexity of AC-4, Bessikre [I~]developed .4C-6, an algorithm conceptually similar t o AC-4 but which avoids much of the work always carried out by AC-4. AC-6 assumes that the labels in the domains are stored i n a d a t a structure that enforces an ordering on the labels and supports the following
1
Notation
I
E
All node pairs ( i , j ) such that there exists a path between i and j. If ( i , j ) E E, then ( j , i) E E.
Li
{aJa E L and (2, a ) is permitted by the constraints
I
R2(i,a,j,b)
1
COmterl(i, j).
1
Meaning
R2(i, a , j, b) = 1 indicates the admissibility of a E L; and b (5 L j given binary const~.aints.
I
The number of labels in Lj that are compatible with a E L; (used only by MUSE AC-1). {(j, b)(R2(i,a , j, b) = 1) (MUSE AC-1) or {(j, b)l(i, a ) with a being the smallest value in L; supporting (j,b)) (I\/IUSE !LC-2, MUSE AC-3).
!-
I
M[(i,j ) , a] = 1 indicates that the label a is not admissible for. (and has already been eliminated from) all segments containing i and j. The set of node pairs (a! j ) such that there exists a directed edge from i to j.
A queue of arc support to be deleted.
List
Next-Edge,
Prev-Edge,
1
The set of all node pairs (i, j ) such that there exists a directed edge (i, j ) E G. It also contains (i?end) if there is no x E N such that ( i , x ) E G. The set of all node pairs (j, a) such that there exists a direct'ed edge (j, i j E G. It also contains (start, i) if t,here is no x E N such that (2,i) E G.
Local-F'rev-Support(i, a)
A set initialized to {(i, x)l(i,x) E E A (x, i) E Prev-Edge,) U {(i, start)((start,i ) E Prev-Edge,). After arc consistency, if (i, j ) E Local-Prev-Support (i, a ) and j # start, a must be compatible with at least one of j's labels.
Local-Kext-Support,(i, a )
A set initialized to {(a, x ) ( ( i , x )E E A (i, x ) E Next-Edge,) U {(i! end)l(i, end) E Next-Edge,}. After arc consistency, if (i, j ) E Local-Next-Support(i, a ) and j # end, a must be compatible &ith at least one of j's labels.
Prev-'support[(i")l a]
A set initialized to {(i, x)l(i,x) E E A (x, j) E Prev-Edge,) u {(i, j)((i,j) E Prev-Edgej) U {(i, start))(start,j ) E Prev-Edge,}. After ilrc consistency, if (i, k) E Prev-Support[(i, j ) , a ] and k #start, then a E L, is compatible with at least one of j's and one of k's 1a.bels.
A set initialized to {(i, x)l(i,x) E E A ( j , x) E Next-Edge,) Next-'support[ii' j)'
U
{(a, j)l(j, a) E Next-Edge,) U {(a, end)l(j,end) E Next-Edge,). After arc consistency, if (i, k) E Next-Support[(i, j ) , a] and k # end, then a E L, is compatible with at least one of j's and one of k's labels.
Figure 1: D a t a structures and notation used by the MUSE CSP arc consistency algorithms.
p r o c e d u r e AC-6-initialize (){ 1. Last = 0; 2. f o r i E N d o 3. for a E L, d o { 4. S[i,a] := 0; 5. w[i,a] := 0 ; } 6. for ( i ,j ) E E d o 7. for a E L, d o { 8. b:= first(L,); nextsupport(i, j, a, b , emptysupport); 9. i f emptysupport t h e n { 10. rernove(a, L ; ) ; M[i, a] := 1; 11. 12. List := List U{(i, a ) } ; } 13. else S [ j ,b] := S [ j ,b ] ~ { (ai ),} ; ) }
Figure 2: The procedure t o initialize the AC-6 d a t a structures. p r o c e d u r e AC-6 (){ 1. AC-6-initialize(); 2. w h i l e List # 0 d o { 3. p o p ( j , b) f r o m List; 4. for (i.a ) E S[j,b]d o { 5. s [ j ,bl := S [ j ,bl-{(i, a)}; 6. i f M [ i , a ]= O t h e n { 7. c:=b; nextsupport(i, j, a, c , emptysupport); 8. i f emptysupport then { 9. rernove(a, L , ) ; 10. M [ i ,a] := 1 11. List := List U { ( i ,a ) } ; } 12. else s [ j ,cl := sli, cl u { ( ; , a ) } ;) } 1 }
Figure 3: The procedure AC-6. constant-time operations: 1. first(,',i) returns the smallest a E Li if Li 2. last(LCi)ret,urns the greatest a E Li if Li
# 0,else returns 0. # 0,else returns 0.
3. If a E ( L ; - l a s t ( L i ) ) ,n e x t ( a , Li) returns the smallest b E Li such that a < b. 4. remo.ve(a, L,) removes a from L;.
If a and b :Lre both elements of Li, then a
0