430 likes | 658 Views
Path Consistency for 1- General CSPs 2- STPs. Peter Schlette Wesley Botham CSCE990 Advanced CP, Fall 2009. Outline. General CSPs Review of Path Consistency & PC Algorithms Path Consistency Algorithms PC-1, PC-2, DPC, PPC, PC-8, PC-2001 STPs Review of Triangulated Graphs
E N D
Path Consistency for 1- General CSPs 2- STPs Peter Schlette Wesley Botham CSCE990 Advanced CP, Fall 2009
Outline • General CSPs • Review of Path Consistency & PC Algorithms • Path Consistency Algorithms • PC-1, PC-2, DPC, PPC, PC-8, PC-2001 • STPs • Review of Triangulated Graphs • Path Consistency on STPs • Floyd-Warshall, Bellman-Ford, STP, P3C, Prop-STP
Path Consistency: Properties • A CSP is path consistent iff it is strongly 3-consistent [van Beek & Dechter, JACM95] • Domains are filtered by arc consistency • Consistent solutions over 2 variables can be extended to every 3rd variable • PC algorithms typically iterate over triplets of variables • End variables in triplets need not be distinct • In STP, variables domains are not relevant, thus PC algorithms on STPs enforce only 3-consistency • A given algorithm • Must determine that a CSP is path consistent or not • May or may not filter the constraints as much as possible (e.g., DPC)
List of Algorithms Discussed • PC-1 [Mackworth 77, , Dechter Fig 3.10] • PC-2 [Mackworth 77, Dechter Fig 3.11] • DPC [Dechter & Pearl 89, Dechter Fig. 4.9] • PPC [Bliek & Sam-Haroud 99] • PC-8 [Chmeiss & Jégou 98] • PC-2001 [Bessière et al. 05]
Path Consistency: Algorithms • They all stop when a relation/domain is empty; omitted for clarity • Queue • Does is it have one? • Edges (e.g., PPC) • Triplets of variables (e.g., PC-2) • Tuples of ‘vv-pair, variable’ (e.g., PC-8 & PC-2001) • Properties • Determines strong 3-consistency? • What is the time and space complexity? • Requires additional data structures to remember supports? • Graph: Complete? Chordal? • What is the practical performance (i.e., phase transition)?
PC-1 [Mackworth 77] 1 Repeat until quiescence2 Fori,j,k variables 3 Rij Rij Rik Rkj • Has 4 nested loops, iterates over vertices, needs no queue • Updates every edge & every domain (i=j) • Uses composition and intersection • Determines strong 3-consistency (when i=j) • Time complexity is O(n5d5) • One sweep costs O(n3d3) • Number of sweeps O(n2d2) • Space: no queue, no additional data structure, complete graph
PC-2 [Mackworth 77] k • Has 1 loop over a queue of triplets of variables • When an edge (domain) is updated, only triplets with an ‘external’ 3rd node are added to queue • Allows i=j, thus determines strong 3-consistency. • Dechter Fig 3.11 specifies i<j in which case domains are not updated • Theoretically & practically faster than PC-1 (queue) • Time complexity is O(n3d5) • Space: Queue size is O(n3), no additional data structures, complete graph 1 Q { (i,j,k) | i j, i k, j k}2 While Q is not empty3 For (i,j,k) from Q4 Rij Rij Rik Rjk 5 IfRijchanged, Q Q U { (m,i,j), (m,j,i) | m i, m j } i j m m
PC-1 vs. PC-2 [Botham & Schlette] n=16, a=16, d=30% PC-1 PC-2
PPC [Bliek & Sam-Haroud 99] Q ← E UntilQ is empty do edge ← DEQUEUE(Q) for every triplet i,j,k related to edge Rij← Rij ∩ (Rik Rkj) if Rij was changed then EnQueue((i,j), Q) • First triangulates the graph • Keeps Q, a queue of edges • For an edge in Q • Pops edge from Q, retrieves all triplets where edge appears • In each triplet, updates each edge • Each updated edge is added to Q • Does not specify whether or not domains are filtered (some should be for soundness)
PPC [Bliek & Sam-Haroud 99] • Triangulated graph is usually sparser than complete graph • For triplet (i,j,k) allows i=j, algorithm is sound (not clear in paper) • Enforces • Strong path-consistency • Weaker filtering than PC-2 • Time: O(ed2), degree of graph • Space: queue O(e) for storing triplets, no additional data structure, chordal graph • Weakness: if 2 or more edges of a given triplet are in Q • All three edges are updated once for each edge • May do redundant work (fixed in STP) vn v2 v1 i j
DPC [Dechter Fig 4.9, Dechter & Pearl 89] k-6 • Given an ordering for the variables • From bottom to top, enforces directional arc-consistency (DAC) • From bottom to top, for every variable, updates the edge between every two of its parents • Properties • Moralizes the graph, determines strong directional path consistency relative to ordering • Time O(min(t.d3,n3d3)) • Space: No queue, no additional data structures, chordal graph 1 Fork=ndownto 1do 2 Fori =1 to kRevise(i, Rik) 3 Fori,jki,k connected & j,k connected 4 Rij Rij Rik Rjk k-4 k-2 k
DPC: Constraint revision [Dechter Fig 3.9] i 1 For each (a,b) Rij 2 IfnocDkis s.t. (a,c)Rik & (a,b)Rjk 3 Remove (a,b) from Rij j k • Does not operate on matrices in reality (,) • Iterates over • Tuples in constraints (i.e., (a,b) Rij) and • Values in domain (i.e., cDk) • Not yet tested against PC-1, PC-2, PPC
PC-8 [Chmeiss & Jégou 98] Initialize Q ← fori,j,k=1 to n (i<j,k≠i,k≠j)for (a,b)RijUpdate((i,a),(j,b),k) PC-8 Initialize While Q do Pop((i,a),k), Q) Propagate((i,a),k) UPDATE if WITHOUTSUPPORT((i,a),(j,b),k) REMOVE (a,b) from Rij, (b,a) from Rij Q ← Q U {((i,a,)j),((j,b),i)} Propagate forj=1 to n (j≠i,j≠k)forbDj and (a,b)Rij Update((i,a),(j,b),k)
PC-8 Analysis [Chmeiss & Jégou 98] • Queue: a list of (vvp, var) = ((var,val),var) • Determines strong PC-property (if you allow i=j) • Achieves ‘full’ filtering • Time complexity • Initialization: O(n3d3) • Propagate is called O(n2d2) times, each call costs O(nd2) • PC-8: Initialization + (n2d2) Propagate = O(n3d4) • Space • Queue O(n2d), data structure Status-PC: O(n2d) • Graph is complete
PC-8 vs. PC-2 [Botham & Schlette] n=16, a=16, d=30% PC-2 PC-8
PC-2001 [Bessière+ 05] PC-2001 1 Initialize(Q)2 While Q 3 Pop((i,a),k) from Q4 RevisePath((i,a),j) Initialize(Q) 1 Fori,j,k variables2 For each (a,b) Rij3 If (a,b) has no support c in Dk4 Remove (a,b) from Rij5 Q Q U {((i,a),j), ((j,b),i)} 6 Else 7 Last((i,a),(j,b),k) the first support of (a,b) Dk
PC-2001 [Bessière+ 05] RevisePath((i,a),k,Q) 1 For each j k2 For each bDj | (a,b) Rij3 support Last((i,a),(j,b),k) 4 Whilesupport is nil or was deleted 5 support next value in Dk 6 If no supports exist7 Remove (a,b) from Rij8 Q Q U {((i,a),j), ((j,b),i)} 9 Else 10 Last((i,a),(j,b),k) support • Records supporting values to improve time complexity (at the cost of space overhead)
PC-2001 Analysis [Bessière+ 05] • Queue: same as PC-8, list of (vvp,var) • Achieves the same properties as PC-1, PC-2, PC-8 • Time: O(n3d3) • Space • Queue: O(n2d) • Data structure: Last structure dominates O(n3d2) • Graph complete • Compared to PC-8, PC-2001 • Is easier to understand and implement • Has lower time complexity • Is faster in general in experiments • Has worse space complexity
PC-2001 vs. PC-2, PC-8[Botham & Schlette] n=16, a=16, d=30% PC-2 PC-8 PC-2001
Summary of PC Algorithms for General CSPs • Comparisons: CPU time, #CC for preprocessing
Outline • General CSPs • Review of Path Consistency & PC Algorithms • Path Consistency Algorithms • PC-1, PC-2, DPC, PPC, PC-8, PC-2001 • STPs • Review of Triangulated Graphs • Path Consistency on STPs • Floyd-Warshall, Bellman-Ford, STP, P3C, Prop-STP
Triangulated Graphs: Motivation • [Bliek & Sam-Haroud 99] showed that PPC • Operates on triangulated graphs • Determines the property of strong path consistency • When constraints are convex, PPC also yields minimal CSP • [Xu & Choueiry 03] studied STP • In STP constraints are convex • Proposed STP, which adapts PPC to STPs w/o updating domains (‘weak’ path consistency) • May do fewer updates than PPC: queue of edges versus queue of triangles • [Planken et al. 08] studied STP • Showed that STP is O(t2), t is the number of triangles • Proposed P3C, for STP, that is O(t)
Vertex elimination • Vertex elimination operation: When removing a vertex, connect all neighbors if they are not already connected • Fill edges: are the edges added when eliminating a vertex • Simplicial vertex • Vertex whose neighbors are all connected (form a clique) • Eliminating a simplicial vertex does not add any edges • Perfect elimination ordering: • There is always a simplicial vertex to be eliminated. • All nodes can be eliminated w/o adding any fill edges
Triangulated Graphs • A graph is triangulated iff it has a perfect elimination order • The width of the triangulated graph is equal to the size of its largest clique -1. Why? • Finding the width is tractable, thus max. clique on triangulated graph is tractable (usually, NP-hard) • Using the reverse of the perfect elimination ordering of a triangulated graph yields • A moralized graph • The induced width of this ordering is equal to the width of the triangulated graph, why? • Moralizing an arbitrary ordering of a graph yields a triangulated graph. Why?
Outline • General CSPs • Review of Path Consistency & PC Algorithms • Path Consistency Algorithms • PC-1, PC-2, DPC, PPC, PC-8, PC-2001 • STPs • Review of Triangulated Graphs • Path Consistency on STPs • Floyd-Warshall, Bellman-Ford, STP, Prop-STP,P3C (Prop-STP is not discussed for lack of time)
Floyd-Warshall for STP [CLR] • Basic STP solver, three nested loops • Initialization: builds the distance graph • Rij = [a,b] gives eijb and eji-a • When edge does not exist, add infinite distance (complete graph) • Time (n3), Space: No queue but O(n2) new edges FloydWarshall Fork1 ton Fori 1 ton Forj 1 ton w(eij) Min(w(eij),w(eik)+w(ekj))
Bellman-Ford for STP [CLR] d[s] 0for each vertex i other than source (is) d[i] Repeat n-1 times for each edge eijif d[i] + w(eij) < d[j] then d[j] d[i] + w(eij) for eachedge eijif d[i] + w(eij) < d[j] then return inconsistent • Time: O(en), Space: No queue but O(n) new edges • Detects path consistency • Edges are not guaranteed minimal
∆STP [Xu & Choueiry 03] • PPC • Operates on triangulated graphs • ‘Fully’ filters convex constraints • ∆STP adapts & refines PPC to STP • Keeps a queue of triangles (vs. a queue of edges) • Pops a triangle from queue & updates all 3 edges • Implicitly separate graph in biconnected components • Enqueues triangles adjacent to only the updated edge • Best performance when queue is FIFO
Constraint checks for selected STP solvers Performance on STPs: BF, DPC, STP[Shi+ 05]
P3C: The Idea [Planken+ 08] • Designers of ∆STP became aware of relevance of simplicial ordering in ∆STP in 2005 (ref. Nic Wilson) • Designers of Prop-STP exploited the idea • The authors of P3C formalize the flaw of ∆STP • Identified a pathological case where ∆STP does unnecessary work (not useful filtering) • Characterized it as set of problems where ∆STP runs in Ω(t2), where t is the number of triangles • P3C addresses flaw by using a simplicial ordering • Proves that propagation can be achieved in (t)
P3C: Pathological Case [Planken+ 08] • {ci→i+1 | 0 ≤ i ≤ t+1} with zero weight • {ci→j | (1 ≤ i ≤ j−2 < t) ∧ i+j−t ∈ {1,2}} with weight j−i−1 • {cj→i | (1 ≤ i ≤ j−2 < t) ∧ i+j−t ∈ {1,2}} with weight t−(j−i−1)
Path. Case: Empirically [Planken+ 08] cubic quadratic linear
P3C: The Algorithm [Planken+ 08] • Given: A triangulated graph & a perfect elimination order • The algorithm has two steps • Bottom up: For every node • Considers every pair of parents • Updates the edge between parents (ref. DPC) • Top down: For every node • Considers every pair of parents • Updates edges adjacent to node i j k i 1 j 2 k
P3C: Bottom up [Planken+ 08] • DPC: For each node update the edges between all parents given the edges with the node
P3C: Top Down [Planken+ 08] • Update the edges between every node and its parent
P3C: Sound & complete [Planken+ 08] • Claim: on iteration k of P3C’s second half, all edges in the subgraph consisting of { Vi | i≤ k } are minimal • Base case: k = 2 • We know that c1,2 (in orange) must be minimal if it exists, due to DPC; the subgraph will always be minimal for k= 2 1 1 k=2 2 k=3
P3C: Sound & complete [Planken+ 08] • Induction hypothesis: Gk-1={Vi≤k-1} forms a minimal subgraph • Induction step: Gk-1 minimalGk minimal • In the kth iteration, wik=min(wik, wij+ wjk) • Any part of a theoretical shorter path that extends out of the Gk-1can be replaced by its two endpoints within Gk-1, due to the filtering from DPC • The only way wik could be non-minimal is if there were a shorter path wij+wjk, but this path was checked in the kth iteration • We have a base step and an inductive step, so the proof is complete! 1 Gk Gk-1 i j k-1 k
Time Complexity [Planken+ 08] • P3C runs in Θ(t), t is the number of triangles • O(t) ⊆ O(nw*2), w* is the min. induced width • O(nw*2) ⊆ O(nδ2), where δ is max. degree • O(nδ2) ⊆ O(n3) • DPC visits each triangle exactly once • The second half of P3C visits each triangle exactly once • Thus we have a constant number of visits to each triangle and a linear time complexity in the number of triangles
Jobshop(enforced consistency)[Planken+ 08] In spite of theoretical bounds, the two algorithms are quite close
Future Work [Planken+ 08] • Extend P3C to general CSPs • Investigate efficiency of triangulation algorithms vs. P3C • Incremental P3C solver for STPs
References • CSP • PC-1, PC-2: see [Mackworth, AIJ 1977] • PPC: see [Bliek & Sam-Haroud, IJCAI 1999] • DPC: see [Dechter 4.2.2, Dechter & Pearl, AIJ 1987] • PC-8: see [Chmeiss & Jégou, IJAITools 1998] • PC-2001: see [Bessière et. Al, AIJ 2005] • STP • Floyd-Warshall, Bellman-Ford: see CLR textbook • DPC: see [Dechter et al., AIJ 1991] • ∆STP: see [Xu and Choueiry, TIME 2003] • Prop-STP: see[Bui, Tyson, and Yorke-Smith, AAAI 07, Workshop] • P3C: see [Planken et al., ICAPS 2008]