340 likes | 456 Views
An Overview of Compiling Constraint Networks into AND/OR Multi-valued Decision Diagrams ( AOMDDs ). William Lam CS 275 Project. Papers: Mateescu R., Dechter R. Compiling Constraint Networks into AND/OR Multi-valued Decision Diagrams ( AOMDDs ). (CP 2006)
E N D
An Overview of Compiling Constraint Networks into AND/OR Multi-valued Decision Diagrams (AOMDDs) William Lam CS 275 Project • Papers: • Mateescu R., Dechter R. Compiling Constraint Networks into AND/OR Multi-valued Decision Diagrams (AOMDDs). (CP 2006) • Mateescu R., Dechter R., and Marinescu, R. AND/OR Multi-valued Decision Diagrams (AOMDDs) for Graphical Models. (JAIR 2008) The slides on AND/OR search and decision diagrams were provided by RinaDechter.
Outline • Introduction • AND/OR Search Spaces (Quick Review) • Decision Diagrams – Binary and Multi-valued (BDD/MDD) • AND/OR MDDs (AOMDDs) • Experiments • Conclusion
Introduction • Combining two frameworks • AND/OR Search Spaces • Multi-valued Decision Diagrams (MDDs) • Both are more compact ways to represent problems. • Their combination yields an even more compact representation. • Decision Diagrams are known to allow online speed queries.
OFFLINE A F B C E D ONLINE Evaluate answer Polytime? Constant time? Introduction Query Compiled structure ONCE MANY
A F B C E D A B E C D F Classic OR Search Space Ordering: A B E C D F 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
A A F F B B C C E E D D A B OR A E C AND 0 1 D F OR B B AND 0 0 1 1 OR E C E C E C E C AND 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 OR D F D F D F D F D F D F D F D F AND 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 AND/OR Search Space A F B C E D Primal graph DFS tree
A F B C E D A B A 0 1 E C B 0 1 0 1 D F A E 0 1 0 1 0 1 0 1 0 1 B C 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 E D 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 C F 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 D 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 F 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 AND/OR vs. OR OR A AND 0 1 AND/OR OR B B AND 0 0 1 1 OR E C E C E C E C AND 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 OR D F D F D F D F D F D F D F D F AND 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 AND/OR size: exp(4), OR size exp(6) 0 OR 1 1 1 0 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 J J J J G G J J G G J J J J G G J J G G G G J J G G J J G G G G 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 H H H H K K K K H H H H K K K K H H H H K K K K H H H H K K K K H H H H K K K K H H H H K K K K H H H H K K K K H H H H K K K K 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 A J From AND/OR Tree A F B B C K E C E D D F G J G H OR A H K AND 0 1 OR B B AND 0 0 1 1 OR E C E C E C E C AND 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 OR D F D F D F D F D F D F D F D F AND OR AND OR AND
A J To an AND/ORGraph A F B B C K E C E D D F G J G H OR A H K AND 0 1 OR B B AND 0 0 1 1 OR E C E C E C E C AND 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 OR D F D F D F D F D F D F D F D F AND 0 1 0 1 OR J J G G AND 0 1 0 1 0 1 0 1 OR H H H H K K K K AND 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
AND/OR Search Graphs • Any two nodes that root identical subtrees/subgraphs (are unifiable) can be merged • Minimal AND/OR search graph:of R relative to tree T is theclosure under merge of the AND/OR search tree of R relative to T, where inconsistent subtrees are pruned. • Canonicity: The minimal AND/OR graph relative to T is unique for all constraints equivalent to R.
A 0 1 B 0 1 0 1 C C A F 0 1 0 1 0 1 0 1 D 0 1 0 1 0 1 0 1 D B E E 0 1 0 1 F 0 1 OR OR A A A AND AND 0 1 0 1 0 1 B OR OR 0 1 0 1 B B B B C AND AND 0 1 0 1 0 1 0 1 1 1 0 0 1 1 0 0 D OR C C C C OR E 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 E C E E C C C E E E E E AND AND 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 F OR D D D D OR 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 F F F F D D D D D D D D F F F F F F F F AND AND 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 All Four Search Spaces Full OR search tree 126 nodes Context minimal OR search graph 28 nodes Context minimal AND/OR search graph 18 AND nodes Full AND/OR search tree 54 AND nodes
A A A A A A A B B B B B B B B B B B B C C C C C C C C C C C C C C C C C 0 0 0 0 0 0 0 1 0 1 1 1 1 1 0 1 0 0 0 1 0 1 0 1 Decision tree OBDD [Bryant86] Ordered Binary Decision Diagram B = {0,1} f : B3→ B Table 1) Merge nodes with identical children Merge terminal nodes Simplify 2) Remove redundant nodes Ordering enables efficient operations
A B B A C C A C C C C B D D B B B D D D D D D D D D D G G E E E G G E E E E E E E E E H F H F F F F F 0 0 0 0 1 1 1 1 G G H 0 1 AND Decision Diagrams f = (A ∨ E) ∧ (B ∨ F) ? f ∧ g = OBDD g = (C ∨G) ∧ (D ∨ H) f ∧ g = OBDD
A 0 1 A B B 0 1 0 1 0 1 B B C 1 0 1 0 1 C 0 1 1 Minimal AND/OR graph Decision Diagram AOMDDs A Point dead-ends to terminal node “0” Point goods to terminal node “1” B C
A A redundant A A 0 1 0 1 0 0 1 1 B B B B B B 0 1 0 1 0 1 0 0 1 1 0 1 C C C C 0 1 0 1 0 0 1 1 0 1 0 1 0 1 0 1 OBDD (pseudo tree is a chain) Removing Redundancy A Group OR node together with its AND children into a meta-node B C
A D B B D D D A B 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 A 0 1 B B 0 0 1 1 C C 0 0 1 1 0 1 0 1 0 1 AOBDD A A A B B B C D D C = *
B D D A B A 0 0 0 0 0 0 1 1 1 1 1 1 A 0 1 B B 0 0 1 1 A C B 0 1 D C Apply Operator A1B1 A1 B1 A1B1 = * A2B2 A4B6 A2B2 A2 B2 B6 A4B4 A4 B4 B7 0 1 0 1 A3B3 0 A3 A5 B3 B5
B D D A B A 0 0 0 0 0 0 1 1 1 1 1 1 A 0 1 B B 0 0 1 1 A C B 0 1 D C Apply Operator A1 B1 A1B1 = * A4B6 A2B2 A2 B2 B6 A4 A4B4 B4 A4 B4 B7 0 1 0 1 0 A3 A5 B3 B5
A B D D B A D 0 0 0 0 0 0 0 1 1 1 1 1 1 1 A 0 1 B B 0 0 1 1 A C C B 0 0 1 1 D C Apply Operator A1 B1 A1B1 = * A4B6 A2B2 A2 B2 B6 A4 B4 A4 B4 A4 B4 B7 0 1 0 1 0 1 A3 A5 B3 B5
D B D D B A B A 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 A 0 1 B B 0 0 1 1 A C C B 0 0 1 1 D C Apply Operator A1 B1 A1B1 = * A4B6 A2B2 A4B6 A2 B2 B6 A4B4 A4B7 A4 B4 A4 B4 B7 0 1 0 1 0 1 A3 A5 B3 B5
B B D D D B A D A 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 A 0 1 B B 0 0 1 1 A C C B 0 0 1 1 D C Apply Operator A1 B1 A1B1 = * A2B2 A4B6 A2 B2 B6 A4B7 A4 B4 A4 B4 B7 B7 0 1 0 1 0 1 A3 A5 B3 B5
And/Or Multi-Valued Decision Diagrams • AOMDDs are: • AND/OR search graphs • canonical representations, given a pseudo tree • Defined by two rules: • All isomorphic subgraphs are merged • There are no redundant (meta) nodes
A A D G B C B F C F A m7 E A H D E G H B primal graph pseudo tree B C F 0 1 m6 m6 m3 0 1 m3 D E G H A A B F 0 1 0 1 B C F C9 C5 0 1 0 1 0 1 m2 C m4 m1 m5 0 1 m1 m5 m4 G H m2 D E A A A C C B A B C C D D C B C F H E A C B C F F E C H B B F A H D G G G A D B G F H F B A D D A B C E F E H A A F B G H C G F B G F 0 1 0 1 0 1 0 1 0 1 0 1 F E H D 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 C8 E G D C1 C4 C6 C7 C2 F C3 0 1 H G (f ∨ h) ∧ (a∨!h) ∧ (a#b#g) ∧ (f ∨ g) ∧ (b ∨ f) ∧ (a ∨ e) ∧ (c ∨ e) ∧ (c#d) ∧ (b ∨ c) Example: m7
A m7 B C F 0 1 m6 A 0 1 m3 D E G H 0 1 m7 B G B C C C H A F C B F F G H B A F B D C F C C D E F B A H B D F F E D C H G G 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Example (continued)
D G C B F A E A H B primal graph C F D E G H 0 1 C G F F C B G F H A B D C E H F D C 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 AOBDD vs. OBDD A B B C C C C D D D D D D E E E F F F F G G G G G A H H B C 1 0 D AOBDD 18 nonterminals 47 arcs OBDD 27 nonterminals 54 arcs E F G H
Complexity of Compilation • The size of the AOMDD is O(n kw*) • The compilation time is also bounded by O(n kw*) • k = domain size • n = number of variables • w*= treewidth
Semantic Treewidth • Given a network, there may exist a sparser equivalent network. • Challenges the idea of using induced width to measure the difficulty of the problem • AOMDD sizes are much smaller than the bound
Semantic Treewidth • With respect to a pseudo tree, this is the smallest treewidth over all equivalent networks that can have that pseudo tree • With respect to the network, this is the smallest semantic treewidth over all pseudo trees that can express the set of solutions • Instead of the induced width bounding AOMDD size, we can use semantic treewidth.
Experimental Results Langford(2,k) problem as a CSP
Experimental Results Langford(2,k) problem as a SAT problem
Experimental Results Uniform Random 3-SAT instances
Experimental Results Equality constraint network results
Conclusion • AOMDDs allow us to encode the same information about a problem in an exponentially more compact form • Canonicity aids in revealing whether the induced width is overestimating the difficulty of a problem • It may be interesting to perform more experiments on real-world CSPs.
Acknowledgements • RinaDechter • Pointing me to additional literature • Providing me many of these slides • RaduMarinescu • Providing me the code to compile AOMDDs