Foundations of Artificial Intelligence
26. Constraint Satisfaction Problems: Path Consistency
Malte Helmert
University of Basel
April 19, 2021
Constraint Satisfaction Problems: Overview
Chapter overview: constraint satisfaction problems:
22.–23. Introduction 24.–26. Basic Algorithms
24. Backtracking 25. Arc Consistency 26. Path Consistency 27.–28. Problem Structure
Beyond Arc Consistency Path Consistency Summary
Beyond Arc Consistency
Beyond Arc Consistency: Path Consistency
idea of arc consistency:
For every assignment to a variable u
there must be a suitable assignment to every other variablev. If not: remove values ofu for which
no suitable “partner” assignment to v exists.
tighter unary constraintonu
This idea can be extended to three variables (path consistency):
For every joint assignment to variables u,v
there must be a suitable assignment to every third variablew. If not: remove pairs of values of u andv for which
no suitable “partner” assignment to w exists.
tighter binary constraintonu andv German: Pfadkonsistenz
Beyond Arc Consistency Path Consistency Summary
Beyond Arc Consistency: i -Consistency
general concept ofi-consistency fori ≥2:
For every joint assignment to variables v1, . . . ,vi−1
there must be a suitable assignment to every i-th variablevi. If not: remove value tuples of v1, . . . ,vi−1 for which
no suitable “partner” assignment for vi exists.
tighter (i−1)-ary constraintonv1, . . . ,vi−1
2-consistency = arc consistency 3-consistency = path consistency (*) We do not consider generali-consistency further as larger values thani = 3 are rarely used
and we restrict ourselves to binary constraints in this course.
(*)usual definitions of 3-consistency vs. path consistency differ
(*)
when ternary constraints are allowed
Path Consistency
Beyond Arc Consistency Path Consistency Summary
Path Consistency: Definition
Definition (path consistent)
LetC=hV,dom,(Ruv)i be a constraint network.
(a) Two different variablesu,v ∈V are path consistent with respect to a third variable w ∈V if
for all values du ∈dom(u),dv ∈dom(v) withhdu,dvi ∈Ruv
there is a value dw ∈dom(w) with hdu,dwi ∈Ruw and hdv,dwi ∈Rvw.
(b) The constraint network C ispath consistent if for any three variablesu,v,w,
the variables u andv are path consistent with respect tow.
Path Consistency: Remarks
remarks:
Even if the constraintRuv is trivial, path consistency can infer nontrivial constraints between u andv. name “path consistency”:
pathu →w →v leads to new information on u →v
w
u v
Beyond Arc Consistency Path Consistency Summary
Path Consistency: Example
red blue
v1
red blue
v2
red blue
v3
6= 6=
6=
arc consistent, but not path consistent
Processing Variable Triples: revise-3
analogous torevisefor arc consistency:
functionrevise-3(C,u,v,w):
hV,dom,(Ruv)i:=C for eachhdu,dvi ∈Ruv:
if there is nodw ∈dom(w) with hdu,dwi ∈Ruw andhdv,dwi ∈Rvw:
remove hdu,dvi fromRuv
input: constraint networkC and three variables u, v,w of C effect: u,v path consistent with respect tow.
All violating pairs are removed fromRuv.
time complexity: O(k3) wherek is maximal domain size
Beyond Arc Consistency Path Consistency Summary
Enforcing Path Consistency: PC-2
analogous toAC-3for arc consistency:
functionPC-2(C):
hV,dom,(Ruv)i:=C queue:=∅
for eachset of two variables{u,v}:
for each w ∈V \ {u,v}:
insert hu,v,wi into queue whilequeue6=∅:
remove any elementhu,v,wi fromqueue revise-3(C,u,v,w)
if Ruv changed in the call to revise-3:
for each w0∈V \ {u,v}:
insert hw0,u,vi into queue insert hw0,v,ui into queue
PC-2: Discussion
The comments for AC-3 hold analogously.
PC-2 enforces path consistency
proof idea: invariant of the whileloop:
if hu,v,wi∈/queue, then u,v path consistent with respect to w
time complexity O(n3k5) forn variables and maximal domain sizek (Why?)
Beyond Arc Consistency Path Consistency Summary
Summary
Summary
generalization of
arc consistency(considers pairsof variables) to path consistency(considers triplesof variables) andi-consistency (considersi-tuplesof variables) arc consistency tightens unary constraints
path consistency tightensbinary constraints i-consistency tightens(i−1)-aryconstraints higher levels of consistency more powerful but more expensive than arc consistency