1 chapter 8 advanced consistency methods yaling zheng csce 990-06: advanced constraint processing
Post on 22-Dec-2015
230 views
TRANSCRIPT
2
Outline: consistency methods Relational consistency (Section 8.1)
Relational arc-consistency Relational path-consistency Relational m-consistency Relational (i, m)-consistency
Directional relational-consistency (Section 8.2)
Global consistency (i.e., BT-free) Domain tightness (Section 8.3.1) Constraint tightness (Section 8.3.2)
Special types of networks Boolean theories (Section 8.4) Row convex constraints (Section 8.5) Linear inequalities (Section 8.6)
Arc-Consistency & Relational Arc-Consistency
Constraint network 1 is arc-consistent iff x is arc-consistent relative to y and y is arc-consistent relative to x.
How should we express constraint network 2 is consistent?
y
x
x<y
x
y
z
x+y =z
3
Constraint network 1
Constraint network 2
Arc-ConsistencyDx = { 1, 2 }
Dy = { 1, 2 }
Rxy : x<y
y is arc-consistent relative to x
Dy = { 2 }
X is arc-consistent relative to y
Dx = { 1 }Arc-consistency: y is arc-consistent relative to x iff for every value in Dy
there is a value in Dx such that Cxy is satisfied
Update domain using a binary relation
y
x
x<y
{ 1, 2 }
{ 1, 2 }
4
Relational Arc-Consistency
Dx = { 1, 2 }
Dy = { 1, 2 }
Dz = { -2, -1, 0, 1, 2, 3, 4, 5 }
Rxyz : x+y =z
Rxyz is relational arc-consistent relative to z Dz = { 2, 3, 4 }
x
y
Similarly, update domain using one relation
Except that relation is not binary, its arity > 2
Relational arc-consistency
z
{-2, -1, 0, 1, 2, 3, 4, 5}
{ 1, 2 }
{ 1, 2 }
5
Notes for Relational arc-consistency Relations not necessarily binary Three levels of relational arc-
consistency:1. A relation (e.g,Rxyzt ) is relational arc-
consistent relative to a variable x2. A relation (e.g, Rxyzt ) is relational arc-
consistent
3. A network is relational arc-consistent
6
7
Relational Arc-Consistency
Let R be a constraint network over a set of variables X = {x1 , x2 , , xn}, having domains D1 , , Dn
(A) is the set of all consistent instantiations of the subnetwork defined by A, which is a set of variables
Let Rs be a relation in R defined over a scope S, e.g. S = {x2, x3, x4}
8
Relational Arc-Consistency
Rs in R is relational-arc-consistent relative to a variable x S iff any consistent instantiation of the variables in S-{x} has an extension to a value in Dx that satisfies Rs . That is, iff
( S-{x} ) s-{x} (R Dx) A relation Rs in R is relational-arc-consistent if it is
relational arc-consistent relative to every variable in S
A network is relational-arc-consistent iff every relation in it is relational-arc-consistent
Example of Relational Arc-consistencyA network with Dx = Dy = Dz = {(a, b, c)}
one constraintRxyz = { (a, a, a), (a, b, c), (b, b, c), (d, a ,b)}
Question1. Is relation Rxyz relational arc-consistent relative to
{x}, {y}, {z} ?2. If we add a new constraint Ryz = {(a, a), (b, c)}, is
relation Rxyz relational arc-consistent relative to {x} ?
9
Example of Relational Arc-consistencyA network with
Dx[-2, 3] Dy[-5, 7] Rxyz:x+y=z Rztf:z+t=f
Question1. Is this network relational arc-consistent ?2. What constraints should we add to make this
network relational arc-consistent?HintConsider Rxyz should be relational-arc-consistent relative to x, y,
z
and relation Rztf should be relational-arc-consistent relative to z,
t, f 10
Solution to Example 8.1.3To make a network: Dx[-2, 3] Dy[-5, 7] Rxyz:x+y=z Rztf:z+t=f
relational arc-consistent,
Rxyz should be relational arc-consistent relative to x, y, z
yz yz (Rxyz Dx) Ryz : z – y [-2, 3]
xz xz (Rxyz Dy) Rxz : z – x [-5, 7]
yz xy (Rxyz Dz) Rxy : x + y [-7, 10] Dz [-7, 10]
Rztf should be relational arc-consistent relative to z, t, f tf tf (Rztf Dz) Rtf : f – t [-7, 10]
zf zf (Rztf Dt) zt zt (Rztf Df)
11
Path ConsistencyDx = { 0, 1, 2 }
Dy = { 0, 1, 2 }
Dz = { 0, 1, 2 }
Rxy : x< y Ryz : y< z
Rxz is path consistent relative to y
Rxz : x<z
x
y
z
Path of length 2 consistency (Dechter, pp. 72)
x, z (Rxz) is path consistent relative to y iff for every pair (ax , az) Rxz , there is a value ay Dy s.t. (ax , ay) Rxy and (ay , az) Ryz
Infer a new relation from 2 existing binary relations
<
<
<
12
Relational Path-Consistency
Dx [-2, 3]
Dy [-5, 7 ]
Rxyz: x + y = z
Rztf : z + t = f
Rxyz and Rztf is relational path-consistent to z
Rxytf : x+y+t=f
x
yz
t
f
Similarly, infer new relation from 2 existing relations
except that relations are not binary, their arity > 2
Relational path-consistency 13
14
Relational Path-Consistency
Let R be a constraint network over a set of variables X = {x1, …, xn} having domains D1, …, Dn ,
Let RS and RT be two constraints in R with A = (S T) – {x} (A) s-{x}(RS RT Dx)
15
Relational Path-Consistency
RS and RT are relational-path-consistent relative to a variable x S T iff any consistent instantiation of the variables in A has an extension to a value in Dx,( the domain of x) that satisfies Rs and RT simultaneously; that is,
iff (A) A(RS RT Dx) A pair of relations Rs and RT is relational-path-
consistent iff it is relational-path-consistent relative to every variable in S T
Example of Relational Path-ConsistencyA network with A network is relational-path-consistent iff every
pair of its relations is relational-path-consistentDx[-2, 3] Dy[-5, 7] Rxyz:x+y=z Rztf:z+t=f
Question1. Is relation Rxyz and Rztf relational-path-consistency
relative to z ?2. What constraints should we added to made Rxyz and
Rztf relational-path-consistency relative to z ?Hint:
xytf xytf(Rxyz Rztf Dz) Rxytf: x+y+t = f
16
17
Relational –m – consistency
Let R be a constraint network over a set of variables X = {x1, … ,xn} having domains D1, …, Dn
Let Rs1, Rs2,…Rsm be m distinct relations in R with Si X A = i=1
m Si – {x}
(x is a common variable among s1, … sm)
(A) A( i=1 mRsi Dx)
18
Relational –m – consistency
Rs1, …, Rsm are relational-m-consistent relative to a variable
x i=1m Si iff any consistent instantiation of the variables in
A has an extension to a value in Dx, the domain of x, that satisfies Rs1, …, Rsm simultaneously; that is iff
(A) A( i=1 m Rsi Dx) A set of relations {Rs1, … ,Rsm} is relational-m-consistent iff it
is relational-m-consistent relative to every variable in i=1 m Si A network is relational-m-consistent iff every set of m
relations is relational-m-consistent. A network is strongly relational-m-consistent iff it is
relational-i -consistent for every i m.
Example ofRelational-m -consistency
Consider the constraint network over the set of variables {x1 , x2 , x3 , x4 , x5} with Di = {a, b, c} , 1 i 5, and relations are:
R2,3,4,5 = {(a, a, a, a), (b, a, a, a), (a, b, a, a), (a, a, b, a), (a, a, a, b)}
R1,2,5 = {(b, a, b), (c, b, c), (b, a, c)}
Question: Which constraints should be added to make the constraint network strongly relational-2-consistent?
19
Solution to Example 8.1.7For the constraint network
over the set of variables {x1 , x2 , x3 , x4 , x5} with Di = {a, b, c} , 1 i 5, and relations are:
R2,3,4,5 = {(a, a, a, a), (b, a, a, a), (a, b, a, a), (a, a, b, a), (a, a, a, b)}
R1,2,5 = {(b, a, b), (c, b, c), (b, a, c)}
we should guarantee 1. R2,3,4,5 relational arc-consistent relative to x2 , x3 , x4 ,
x5
2. R1,2,5 relational arc-consistent relative to x1 , x2 , x5
3. R2,3,4,5 and R1,2,5 relational path-consistent relative to x2 , x5
20
Note for Relational-m - consistencyFor binary constraint, relational-m-consistency is
identical to variable-based i –consistency where i =m+1.(Dechter, pp. 77, i-consistency)
For general CSPs,
1.Given a set of constraints Rs1 ,…, Rsm, enforcing relational-m-consistency relative to a variable x can also be accomplished by enforcing r –consistency(r = |Si |) relative to x
(prepocessing is needed here)
2.Enforcing i -consistency may be accomplished by relational-m-consistency where m ranges from 1 to 2i.
21
22
Relational (i, m)- Consistency
A set of relations {Rs1 , …, Rsm} is relationally (i, m) -consistent iff for every subset of variables A of size i, A j=1
m Sj , any consistent assignment to A can be extended to an assignment to
i=1m Si – A that satisfies Rs1 , …, Rsm simultaneously.
A network is relationally (i, m) -consistent iff every set of m relations is relationally (i, m) –consistent
A network is strong relational (i, m) -consistent iff it is relational (j, m) -consistent for every j i.
Question: relational-m-consistency relational (m-1, m) consistency ?
23
Algorithm Relation consistency(R, i, m) (RC(i, m))
Input: a network (X,D,C)Output: a relational-(i,m)- consistent network R‘ , equivalent to R1. Repeat2. Q R3. for every m relations Rs1,…,Rsm Q and every
4. subset A of size i, A i=1m Si
5. RA RA A ( i=1m Rsi )
6. If is RA the empty relation
7. then exit and return the empty network8. endif9. endfor10. Until Q = R
24
Extended composition
The extended composition of relation Rs1, …, Rsm relative to a subset of variables A i=1
m Si , denoted by ECA(Rs1, …, Rsm), is defined by
ECA(Rs1, …, Rsm) = A( i=1m Rsi)
When the operator is applied to m relations, it is called extended m-composition.
If the projection is restricted to subsets of sizes i, it is called extended (i, m)-composition.
25
Two Practical relational-consistency algorithms
Generalized Arc-consistency (RC(1,1)) (a.k.a. domain propagation)if in relational-consistency algorithm,
line 5 is replaced with Dx x (Rs Dx )
Relational Arc-consistency (RC1)
if line 5 is replaced with Rs– {x} s-{x}(Rs Dx )
26
Directional-relational-consistency
Given a network R an ordering d=(x1,,xn )
R is m-directionally relationally consistent iff for every subset of constraints {Rs1 , , Rsm } where the latest
variable in any of the constraints’ scopes is Xl , and
for every A, A {x1 , , xl-1 },
every consistent assignment to A can be extended to Xl while simultaneously satisfying all the relevant constraints in
{Rs1, ,Rsm} .
Input: a constraint network R=(X,D,C), an ordering d=(x1,…,xn ) Output: An m-directional-consistent network, along d1. Build buckets.2. Looping over buckets from n downto 1 3. Simplify all relations in current bucket4. Instantiation if current bucket contains a unary constraint with xp=u then instantiate and propagate If no resulting relation is empty, then add them to appropriate bucket
else exit and return the empty network5. else (the general case) j min {number of relations in current bucket , m }
apply directional relation consistency If no resulting relation is empty, then add them to appropriate bucket
else exit and return the empty network9. Return all the buckets
Algorithm:Directional-Relational-Consistency (DRCm)
27
Example of DRC2
R{1,2,3,4,5} = {(H,O,S,E,S), (L,A,S,E,R), (S,H,E,E,T), (S,N,A,I,L), (S,T,E,E,R)}
R{3,6,9,12} = {(A,L,S,O), (E,A,R,N), (H,I,K,E), (I,R,O,N), (S,A,M,E)}
R{5,7,11} = {(E,A,T), (L,E,T), (R,U,N), (S,U,N), (T,E,N), (Y,E,S)}
R{8,9,10,11} = {(A,L,S,O), (E,A,R,N), (H,I,K,E), (I,R,O,N), (S,A,M,E)}
R{10,13} = {(B,E), (I,T), (N,O), (U,S)}
R{12,13} = {(B,E), (I,T), (N,O), (U,S)}
1 2 3 4 5
6 7
8 9 10
11
12
13
28
DRC2 for crossword puzzlewith d = (x13 , x12 , , x1)
Bucket(x1) R1,2,3,4,5
Bucket(x2) H2,3,4,5
Bucket(x3) R3,6,9,12 H3,4,5
Bucket(x4) H4,5,6,9,12
Bucket(x5) R5,7,11 H5,6,9,12
Bucket(x6) H6,7,9,11,12
Bucket(x7) H7,9,11,12
Bucket(x8) R8,9,10,11
Bucket(x9) H9,10,11 H9,11,12
Bucket(x10) R10,13 H10,11,12
Bucket(x11) empty relation exit
Bucket(x12)
Bucket(x13) 29
30
Complexity of directional relational consistency
Given a network R , the time complexity and size of the network generated by DRCm along ordering d is O(nm·(2mk2)(w*(d)+1) ) ,
where w*(d) is induced width along ordering d, and n is the number of variables(a.k.a. number of buckets)
Consequently, the time complexity of DRC2 is O( n (4k2) (w*(d)+1) )
The complexity of DRC1 is O(n · e2 · t2) where e is the number of input relations and t bounds the number of tuples in each relation.
The number of variables in any bucket is at most w*(d )+1
The number of relations in a bucket is
at most 2w*(d)+1
The number of subsets of size m is at
most 2(w*(d)+1)m
The number of subsets of size m in n
buckets is at most n 2(w*(d)+1)m
Proof of Complexity of DRCm
The number of tuples in each relation is at most kw*(d)+1
Complexity of each join operation
O(m k2(w*(d)+1))
DRCm complexity =
O(nm·(2mk2)(w*(d)+1) )
join operations over m relations(pair-wise join)
Join operation done for every subsets of m in n buckets
31
Facts:1.The number of relations in a bucket is at most e2. Complexity of simplication is O(e2t2)3. complexity of instantiation is O(t)4. complexity of “general case” is O(t)5. The iteration time is n
Proof of Complexity of DRC1
Complexity of DRC1
is O(n · e2 · t2)
32
Application of crossword puzzles
Note: whenever we apply adaptive-consistency to the crossword puzzle, at most two relations will ever reside in a single bucket, no matter what variable ordering is selected. For the crossword puzzles, then, adaptive-consistency(Decther, pp.113 ) coincides with DRC2 .
(Proposistion 8.2.5)1. Crossword puzzles can be made directional backtrack-
free by DRC2 (Decther, pp.113 , theorem 4.5.2 )
2. The complexity of DRC2 applied to crossword puzzles is
O( n·k 2(w*(d)+1) )
33
34
Domain and constraint tightness
Theorem 8.3.1A strong relational 2-consistent constraint
network over bi-valued domains is globally consistent.
Theorem 8.3.2 (domain tightness and local consistency)A strong relational k-consistent constraint
network R=(X, D, C) over domains with at most k values is globally consistent
Proof of Theorem 8.3.11. We can prove this theorem by proving that all instantation āi-1 = (a1 , , ai-1) (i>1)
to variable x1 , , xi-1 can be successfully extended to xi .
2. Assume that there is an instantation ēj-1 = (e1 , , ei-1 ) can not successfully be extended to ej .
Let denote A0 be the constraints violated by (ēj-1 , ej = 0)
A1 be the constraints violated by (ēj-1 , ej = 1)
3. Let’s pick R1 A0, R2 A0
4. If R1=R2 , which indicates in relation R1 , (x1 , , xj-1 ) can not be successfully extended to xi , contradicting that the network is relational 1-consistent.
5. If R1R2 , which also indicates (x1 , , xj-1 ) can not be successfully extended to xi , contradicting that the network is relational 2-consistent.
6. Thus our assumption is wrong. 7. So we can conclude: A strong relational 2-consistent network over bi-valued domains is
globally consistent.35
36
m-tight A constraint relation Rs of arity r is called
m-tight if, for any variable xi S and any instantiation ā of the remaining r1 variables in S {xi } , either there are at most m extensions of ā to xi that satisfy Rs , or there are exactly |Di | such extensions.
Note: Constraints having domains of size 2 are 1-tight.
Example of m-tight
X= (x1 , x2 , x3 , x4)
Di = {a, b, c} 1 i 4
Rs1 = {(a, a, a), (a, a, c), (a, b, c), (a, c, b), (b, a, c), (b, b, b), (b, c, a), (c, a, b), (c, b, a), (c, c, c)}
Rs2 = {(a, b), (b, a), (b, c), (c, a), (a, c)}
Rs3 = {(a, b), (a, c), (b, b), (c, a), (c, b)}
Where s1={x1 , x2 , x3 } s2={x2 , x4 } s3={x3 , x4 }
All the constraints are 2-tight.
37
38
Lemma 8.3.1 constraint-tightness and local consistency
Let Rs1 , … , Rsl be l relations that constrain a variable x ,
let d be the size of the domain of variable x , and
let ā be an instantiation of all of the variables except for x that are constrained by the l relations (i.e. , ā is an instantiation of the variables in (S1 … Sl ) – x .
If
1. Each relation is m-tight, for some 1m<d , and
2. For every subset of m+1 or fewer relations from {Rs1, …, Rsl }, there exists at least one extension of ā to x that satisfys each of the relations in the subset,
Then there exists at least one extension of ā to x that satisfies all l relations.
Proof of lemma 8.3.11.Let a1, a2 , … , ad be the d elements in the domain of x . We say
that a relation allows an element ai if the extension (ā, ai ) of ā to x satisfies the relation.
2.Assume to the contrary that an extension of ā to x that satisfies all therelations does not exist.
3.for each element ai in the domain of x there must exist at least one relation that does not allow ai . Let ci denote one of the relations that does not allow ai . By construction. The set c={c1, c2 , … , cd } is a set of relations for which there does not exist an extension of ā to x that satisfies each of the relations in the set (every candicate ai is ruled out since ci does not allow ai). For every possible value of m , this leads to a contradiction.
Case 1 (m = d 1): The contradiction is immediate as c={c1 , c2 , … , cd } is a set of
relations of size m+1 for which there does not exist an extension to x that satisfy every relation in the set. This contradicts condition (2).
39
Proof of lemma 8.3.1 (Cont.)
Case 2 (m = d 2): The nominal size of the set c={c1 , c2 , … , cd } is m+2 . We can prove there must
be a repetition in c .Assume to the contrary that ci cj for i j . Recall ci is a relation that does not allow
ai , i = 1, … , d and consider {c1 , c2 , … , cd -1}. This is a set of m+1 relations so by condition (2)
there must exist an ai that every relation in the set allows. The only possiblity is ad .
Consider {c1 , … , cd –2 , cd }. This is a set of m+1 relations so by condition (2) there must exist an ai that every relation in the set allows. The only possiblity is ad –1
Simliar …Continuing in this manner , we an show that relation c1 must allow ad , ad-1 , … a2 ;
that is , c1 must allow exactly m+1 extensions. This contradicts condition (1).
Therefore, our assumption is false. So we can conclude that it must be the case that ci = cj for some i j
40
Proof of lemma 8.3.1 (Cont.)
case 3 (m = d 3), … , case d 1 (m =1) :
The remaining cases are similar. In each case we argue that
(A) There are repetitions in the set c={c1, c2, … cd ),
(B) The true size of the set c is m +1,
(C) A contradiction is derived by appealing to condition (2)
Thus , there exists at least one extension of ā to x that satisfies all of the relations.
41
42
constraint-tightness and local consistency
A strongly relationally (m+1)-consistent constraint network that has m-tight constraints, is globally consistent.
ReferenceP.van Beek and R.Dechter. Constraint tightness and
looseness versus local and global consistency. Journal of the ACM(in press), in 1997
Proof of theorem 8.3.5Constraint-tightness and local consistency1.Let X = (x1 , , xk-1) be a set of k 1 variables, let ā be an
instantation of the variables in X that is consistent with the constraint network, and let Xk be an additional variable
2. Using lemma 8.3.1 we show that there exists an extension of ā to xk that is consistent with the constraint network.
3. Let Rs1 , … , Rsl be l relations which are all and only the relations which constraint only xk and a subset of variables from X . To be consistent with the constraint network, the extension of ā to xk must satisfy each of the l relations.
4. Now , condition (1) of Lemma 8.3.1 is satisfied since each of the l relations is m-tight.
5. Further, condition (2) of Lemma 8.3.1 is satisfied since, by definiton, the requirement of strong relational (m+1)-consistency ensures that for any subset of m+1 or fewer relations, there exists an extension of ā to xk that is consistent with the constraint network.
43