270 likes | 401 Views
Exploiting Problem Structure for Solution Counting Aurélie Favier, Simon de Givry, and Philippe Jégou Presented by Shant Karakashian. Advanced Constraint Processing CSCE 990 02, Fall 2009. Outline. Introduction Motivation Tree Decomposition and BTD Exact Solution Counting
E N D
Exploiting Problem Structure for Solution CountingAurélie Favier, Simon de Givry, and Philippe JégouPresented by Shant Karakashian Advanced Constraint Processing CSCE 990 02, Fall 2009
Outline • Introduction • Motivation • Tree Decomposition and BTD • Exact Solution Counting • Approximate Solution Counting: ApproxBTD • Problem Structure • Counting Formula • Experimental Results • Conclusions
Introduction • #CSP • Is the problem of counting # solutions of a CSP • Belongs to #P-complete class of complexity • Two principal classes of approaches • Exact number of solutions • Approximation of the number of solutions • Numerous applications • Approximate reasoning • Diagnosis • Belief revision
Motivation • Solving #CSP with search may require #Sol(P) steps • What if #Sol(P) = 240? Can we do better? • Divide P into sub-problems {P1, P2, …, Pk} such that • #Sol(P) = #Sol(P1) #Sol(P2) … #Sol(Pk) • #Sol = 27 x 26 x 28 x 26 x 26 x 27 = 240 • Idea • Divide the problem • Exploiting the structure
Other Methods that Exploit Structure • deterministic Decomposable Negation Normal • Form (d-DNNF compiler) [Darwiche 2001] • AND/OR graph search [Dechter 2004] • Backtracking with Tree (BTD) [Jégou 2003]
Tree Decomposition • Given a CSP P=(X, D, R) • X variables, D variable domains, R relations • Decompose the CSP into a tree structure T=(C,E) • C: tree nodes, a tree node is a cluster of variables • E: tree edges • Conditions on tree • All variables appear in some tree node • Scope of every constraint appears in some tree node • Connectedness property holds • The tree width • of the tree decomposition is equal to #vars in largest cluster - 1 • of the CSP is the minimum width over all its decompositions, NP-hard • If there is a global constraint • The tree decomposition cannot be applied • Consequently, BTD cannot be used {R1, R2} {V1,V2,V3} {R3,R5} {V1,V4,V5} {R1,R4} {V2,V8,V9} {R6,R7,R8} {V1,V4,V6,V7} {R9,R10} {V2, V8,V10}
BTD for Solving Tree Decomposition a b c d good: a b 1 0 1 1 nogood: a b 0 0 0 1 good: b c d 0 1 0 1 1 1 nogood: b c d 0 0 0 a b e f b c d g good: d 1 nogood: d 0 good: g 1 nogood: g 0 d h g i • Search root, find one solution • Project solution on separator • Move to child • Extend solution to child • Success: record good in separator • Failure: record nogood in separator • Next time the same values for separator are explored, reuse recorded knowledge
Solution Counting in Trees CountSolutions(Root) Σ xe Input: Root of a tree-structured constraint network T Output: ntotalfor T ntotal 1 foreachvaluein Domain(Root) do nc 1; foreachChild in Children(Root) do Revise (Child, Root value) ncnc×CountSolutions(Child) ntotalntotal+nc returnntotal; See [Dechter & Pearl, AIJ 89] & [Dechter Fig 13.9] Pseudo code from Yaling, Figure from Dechter
Exact Solution Counting in BTD Do BT search on vars in C1 stop at a solution C1 a b c Do BT search on vars in C2 find all solutions #solutions: 1 3 6 0 0 0 - - - 0 0 1 Record 3 solutions for b = 0 + Multiply #solutions of the parent with the child’s 1 3 Do BT search on vars in C3 find all solutions b = 0 (3 sols) b = 0 & c = 0 (2 sols) Record 2 solutions for b = 0 & c = 0 C2 C3 b d e Multiply #solutions of the parent with the child’s b c f Continue search on vars in C1 stop at next sol. 0 0 1 0 1 0 0 1 1 - - - 0 - - 0 0 - - - - 0 0 0 0 0 1 Skip subtree and use the solution count = 3 Continue …. #solutions: #solutions: 2 3
ApproxBTD: Problem Structure • Given a CSP P=(X, R) • X set of variables • R set of relations • Partition P into k subgraphs • P1(X1, R1), P2(X2, R2), …, Pk(Xk, Rk) • Such that • U Xi = X • U Ri = R • ⋂ Ri = (constraints are partitioned) • Each (Xi, Ri) is chordal • Note: domains are not split R2 x4 x5 R3 R1 x3 x2 x1 x7 x8 x6 R4 R1 R2 R3 R4 x1 x2 x3 x4 x5 x5 x6 x7 x8 x1
Decomposition into chordal subproblems • SubproblemsPi, i[1,k] are all chordal • BTD is search on tree clustering • Use MaxChord iteratively to compute Piin O(e.)[Dearing et al., 88] • #Sol(P) = #Sol(P1) #Sol (P2) … #Sol(Pk) if • Pi are independent (i.e., ⋂ Xi = ) • P is chordal (i.e., k=1) • One Pi at least is inconsistent (i.e., #Sol(P)=0) • Solving all Pi with BTD is O(n2edk)
Solution Probability in a Problem • Given a CSP P=(X,R) and an instantiation A of the variables, the probability of “Ais a solution of P” is given by: PrP = SP / TX Where • Sp is the number of solutions in P • TX = ∏x∈X dx, dx is the domain size of variable x
Solution Probability using decomposition R2 R3 x4 x5 x3 x2 x1 R1 x7 x8 x6 R4 R1 R2 R3 R4 x1 x2 x3 x4 x5 x5 x6 x7 x8 x1 Prp1 = 8/32 Prp2 = 20/32 #Sol = 8/32 × 20/32 × 256 = 40 Upper bound = 8/32 × 256 = 64 • Given a CSP P=(X,R) and a decomposition {P1, P2, …, Pk} of P, the number of solutions of P is estimated by (∏ i=1..k PrPi ) * TX • Upper bound on the number of solutions is min i=1..k (PrPi * TX)
Search in the BTD Constraint propagation: GAC for constraints with 2 or 3 unassigned variables Variable ordering: min domain / max degree dynamic variable ordering heuristic inside clusters Backtracking: conflict back-jumping heuristic inside clusters Branching: 2-way branching
Benchmarks • CSP • Coloring • Pedigree • SAT • Academic • Random k-SAT (wff) • All interval series (ais) • Tower of Hanoi • Industrial • Circuit fault analysis (ssa, bit) • Planning
Experiments • Exact methods: BTD versus #SAT solvers • Relsat [Bayardo + Pehoushek, 2000] • Cachet [Sang+, 2004] • c2d [Darwiche, 2004] • Approximate methods: ApproxBTD versus • SampleCount-LB: lower bound • SampleCount-A: no bound guarantee • CSP instances are translated into SAT using direct encoding • One Boolean variable per vv-pair of CSP • One clause per domain enforces selection of at least one domain value • Binary clauses to forbid multiple value selection
Measurements • Exact methods • Compare CPU time • Approximate methods • Compare CPU time • Compare quality of approximation, #Sol found
Experiment Results Summary • BTD can solve instances with relatively small tree width • Exact #SAT solvers: • Generally perform better than BTD on SAT instances • Have difficulties on translated CSP instances • BTD performed better than #SAT with unit propagation on CSP instances • ApproxBTD: • Decomposes a CSP into sub-problems with small tree-width (w ≤ 11) • Relatively fast no matter what the tree-width of the original problem • Approximation quality comparable to SampleCount (except for ssa and logistics benchmarks) • Faster than SampleCount • Outperforms the results in [Gomes ‘07] for the problems: 2_Insertions_3, mug100_1, games120 and myciel5.
Conclusions • The paper presents two methods for counting solutions of CSPs using the BTD • Exact method, suitable for problems with small tree width • Approximate method • Is much faster than existing methods • Result quality is comparable to existing methods • The results encourage further investigation on tree decomposition for solving #CSP