Advanced Constraint Processing CSCE 990 02, Fall 2009
description
Transcript of Advanced Constraint Processing CSCE 990 02, Fall 2009
Advanced Constraint Processing, Fall 2009
Exploiting Problem Structure for Solution Counting
Aurélie Favier, Simon de Givry, and Philippe Jégou
Presented by Shant Karakashian
Advanced Constraint ProcessingCSCE 990 02, Fall 2009
19/8/2009
Advanced Constraint Processing, Fall 2009
Outline
• Introduction• Motivation• Tree Decomposition and BTD• Exact Solution Counting• Approximate Solution Counting: ApproxBTD
– Problem Structure– Counting Formula
• Experimental Results• Conclusions
29/8/2009
Advanced Constraint Processing, Fall 2009
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
39/8/2009
Advanced Constraint Processing, Fall 2009
Motivation
49/8/2009
• 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
Advanced Constraint Processing, Fall 2009
Other Methods that Exploit Structure
59/8/2009
• deterministic Decomposable Negation Normal
Form (d-DNNF compiler)
[Darwiche 2001]
• AND/OR graph search
[Dechter 2004]
• Backtracking with Tree (BTD)
[Jégou 2003]
Advanced Constraint Processing, Fall 2009
Tree Decomposition
69/8/2009
• 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}
Advanced Constraint Processing, Fall 2009
• 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
BTD for Solving Tree Decomposition
8/25/2009 7
a b c d
good: a b1 01 1
a b e f b c d g
d h g i
nogood:
a b0 00 1
good: d1
nogood: d0
good: b c d0 1 01 1 1
nogood:
b c d0 0 0
good: g1
nogood: g0
Advanced Constraint Processing, Fall 2009
Solution Counting in Trees
Input: Root of a tree-structured constraint network TOutput: ntotal for Tntotal 1foreach value in DOMAIN(Root) do
nc 1;foreach Child in CHILDREN(Root) do
REVISE (Child, Root value)nc nc × COUNTSOLUTIONS(Child)
ntotal ntotal + nc
return ntotal;
See [Dechter & Pearl, AIJ 89] & [Dechter Fig 13.9]
Pseudo code from Yaling, Figure from Dechter
8/25/2009 8
Σ
xe
COUNTSOLUTIONS(Root)
Advanced Constraint Processing, Fall 2009
Exact Solution Counting in BTD
8/25/2009 9
a b c- - -
b d e- - -
b c f- - -
#solutions:
#solutions: #solutions:
Do BT search on vars in C1 stop at a solutionC1
C2 C3
0 0 0
0 - -
1Do BT search on vars in C2 find all solutions
0 0 1 0 1 0 0 1 1
3
Multiply #solutions of the parent with the child’s
3
Do BT search on vars in C3 find all solutions
0 0 -0 0 0 0 0 1
2
Multiply #solutions of the parent with the child’s
6Record 3 solutions for b = 0
b = 0 (3 sols) b = 0 & c = 0 (2 sols)
Continue search on vars in C1 stop at next sol.
0 0 1
Skip subtree and use the solution count = 3
+13
Record 2 solutions for b = 0 & c = 0
Continue ….
Advanced Constraint Processing, Fall 2009
ApproxBTD: Problem Structure
109/8/2009
• 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
R1 R2
x1 x2 x3 x4 x5
R3 R4
x5 x6 x7 x8 x1
R1
R2
R3
R4
x4 x5
x7 x8 x6
Advanced Constraint Processing, Fall 2009
Decomposition into chordal subproblems
• Subproblems Pi, i[1,k] are all chordal– BTD is search on tree clustering– Use MAXCHORD iteratively to compute Pi in O(e.)
[Dearing et al., 88]
• #Sol(P) = #Sol(P1) #Sol (P2) … #Sol(Pk) if– Pi are independent (i.e., X⋂ i = )
– 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)
8/25/2009 11
Advanced Constraint Processing, Fall 2009
Solution Probability in a Problem
• Given a CSP P=(X,R) and an instantiation A of the variables, the probability of “A is 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
129/8/2009
Advanced Constraint Processing, Fall 2009
Solution Probability using decomposition
• 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)
139/8/2009
Prp1 = 8/32 Prp2 = 20/32
#Sol = 8/32 × 20/32 × 256 = 40Upper bound = 8/32 × 256 = 64
R1 R2
x1 x2 x3 x4 x5
R3 R4
x5 x6 x7 x8 x1
R1
R2 R3
R4
x4 x5
x7 x8 x6
Advanced Constraint Processing, Fall 2009
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
8/25/2009 14
Advanced Constraint Processing, Fall 2009
Benchmarks
• SAT– Academic
• Random k-SAT (wff)• All interval series (ais)• Tower of Hanoi
– Industrial• Circuit fault analysis (ssa, bit)• Planning
8/25/2009 15
• CSP– Coloring– Pedigree
Advanced Constraint Processing, Fall 2009
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
8/25/2009 16
Advanced Constraint Processing, Fall 2009
Measurements
• Exact methods– Compare CPU time
• Approximate methods– Compare CPU time– Compare quality of approximation, #Sol found
8/25/2009 17
Advanced Constraint Processing, Fall 2009
Exact results on coloring and pedigree
189/8/2009
Instances Vars w #Sol c2d cachet relsat BTDcoloring (Bool vars) Time Time Time Time2-Insertions3 37(148) 9 6.84E+013 235 - - 7.92-Insertions4 149(596) 38 - - - - -DSJC125.1 125(625) 65 - - - - -games120 120(1080) 41 - - - - -GEOM30a 30(180) 6 4.98E+014 0.86 - - 0.08GEOM40 40(240) 5 4.10E+023 1 - - 0.09le4505a 450(2250) 315 3840 - 343.68 326 953.24le4505b 450(2250) 318 120 - 242.3 187 1167.78le4505c 450(2250) 315 120 - 20.79 57 43.66le4505d 450(2250) 299 960 - 16.07 36 85.03mug1001 100(400) 3 1.30E+037 0.19 - - 0.02myciel5 47(282) 21 - - - - mem
pedigree (Bool vars) Time Time Time Timeparkinson 34(340) 4 3.56E+010 31.34 5.33 344 0.12Moissac3 72(1350) 2 4.89E+035 0.98 0.09 1 0.02langladeM7 427(8818) 8 6.73E+196 - - - 31.79
Advanced Constraint Processing, Fall 2009
Exact results on SAT
199/8/2009
Instances Vars w #Sol c2d cachet relsat BTDSAT (Bool vars) Time Time Time Time
wff.3.100.150 100 39 1.80E+021 - - - memwff.3.150.525 150 92 1.40E+014 - - 2509 memssa7552-038 1501 25 2.84E+040 0.15 0.22 67 0.72ssa7552-160 1391 12 7.47E+032 0.12 0.08 5 0.292bitcomp5 125 36 9.84E+015 0.47 0.15 1 11.532bitmax6 252 58 2.10E+029 18.71 1.57 20 memais10 181 116 296 17.14 29.31 6 390.32ais12 265 181 1328 1162.75 2169 229 -logistics.a 828 116 3.80E+014 - 3.82 10 memlogistics.b 843 107 2.30E+023 - 12.4 433 memhanoi4 718 46 1 3.41 32.69 3 1.72hanoi5 1931 58 1 - - - 25.46
Advanced Constraint Processing, Fall 2009
Approximation results on coloring & pedigree
209/8/2009
Instances Vars Solutions ApproxBTD SampleCount-A SampleCount-LBcoloring (Bool vars) w #Sol Time #Sol Time #Sol Time2-Insertions3 37(148) 6.84E+013 1 1.91E+013 6.00E+017 0.01 4.73E+012 1 4.73E+012 7.422-Insertions4 149(596) - 1 1.30E+022 1.64E+071 0.07 0 3.76 0 3.78DSJC125.1 125(625) - 3 1.23E+013 2.27E+070 0.13 0 73.14 0 73.17games120 120(1080) - 8 1.12E+078 1.92E+099 9.83 0 13.76 1.35E+061 91.07GEOM30a 30(180) 4.98E+014 5 7.29E+014 1.81E+015 0.03 1.23E+013 0.432 3.28E+012 3.7GEOM40 40(240) 4.10E+023 5 4.42E+023 1.10E+024 0.02 2.14E+020 1.552 6.50E+019 9.31le4505a 450(2250) 3840 4 1 2.41E+216 2.87 0 8.56 0 8.58le4505b 450(2250) 120 4 1 5.71E+216 2.9 0 8.59 0 8.61le4505c 450(2250) 120 4 1 1.49E+201 6.65 0 110.5 0 110.56le4505d 450(2250) 960 4 1 8.58E+200 6.64 0 54.57 0 54.58mug1001 100(400) 1.30E+037 2 5.33E+037 7.08E+041 0.01 4.20E+034 2.08 4.20E+034 15.59myciel5 47(282) - 1 7.70E+017 8.53E+032 0.02 7.29E+017 0.86 7.29E+017 6.37
Instances Vars Solutions ApproxBTD SampleCount-A SampleCount-LBpedigree (Bool vars) w Solutions Time Solutions Time Solutions Timeparkinson 34(340) 3.56E+010 2 2.33E+010 6.30E+011 0.02 4.08E+010 3.58 9.17E+008 25.62moissac3 72(1350) 4.89E+035 2 3.40E+035 6.11E+035 0.02 1.18E+034 16.93 6.75E+031 118.41langladeM7 427(8818) 6.73E+196 2 3.81E+193 8.07E+203 0.14 3.03E+179 816.9 - -
Advanced Constraint Processing, Fall 2009
Approximation results on SAT
219/8/2009
Instances Vars Solutions ApproxBTD SampleCount-A SampleCount-LBSAT (Bool vars) w #Sol Time #Sol Time #Sol Time
wff.3.100.150 100 1.80E+021 2 2.21E+021 1.95E+027 0.02 1.37E+021 959.8 - -wff.3.150.525 150 1.40E+014 2 9.93E+014 7.80E+040 0.2 3.80E+014 0.68 2.53E+012 4.65ssa7552-038 1501 2.84E+040 5 2.47E+037 1.51E+138 1.05 1.11E+040 134.2 3.54E+038 1162.06ssa7552-160 1391 7.47E+032 5 1.56E+034 2.23E+113 0.82 5.08E+032 144.6 2.31E+031 12932bitcomp5 125 9.84E+015 5 9.50E+016 1.75E+031 0.03 4.37E+015 0.184 3.26E+015 1.232bitmax6 252 2.10E+029 5 2.69E+030 4.27E+065 0.14 1.62E+029 1.676 2.36E+026 10.34ais10 181 296 9 1 2.86E+022 1.05 124 45.93 20 312.74ais12 265 1328 11 1 1.64E+040 3.78 0 9.156 0 9.17logistics.a 828 3.80E+014 10 1 2.33E+147 13.3 7.25E+011 170.9 0 605.33logistics.b 843 2.30E+023 13 1 2.28E+143 13.72 2.13E+023 198.7 0 229.86hanoi4 718 1 6 1 8.65E+107 1.57 0 5.24 0 5.25hanoi5 1931 1 7 1 2.62E+298 15.69 0 6.14 0 6.16
Advanced Constraint Processing, Fall 2009
Approximation results on coloring & pedigree
229/8/2009
Instances Vars Solutions ApproxBTD SampleCount-A SampleCount-LBcoloring (Bool vars) w #Sol Time #Sol Time #Sol Time2-Insertions3 37(148) 6.84E+013 1 1.91E+013 6.00E+017 0.01 4.73E+012 1 4.73E+012 7.422-Insertions4 149(596) - 1 1.30E+022 1.64E+071 0.07 0 3.76 0 3.78DSJC125.1 125(625) - 3 1.23E+013 2.27E+070 0.13 0 73.14 0 73.17games120 120(1080) - 8 1.12E+078 1.92E+099 9.83 0 13.76 1.35E+061 91.07GEOM30a 30(180) 4.98E+014 5 7.29E+014 1.81E+015 0.03 1.23E+013 0.432 3.28E+012 3.7GEOM40 40(240) 4.10E+023 5 4.42E+023 1.10E+024 0.02 2.14E+020 1.552 6.50E+019 9.31le4505a 450(2250) 3840 4 1 2.41E+216 2.87 0 8.56 0 8.58le4505b 450(2250) 120 4 1 5.71E+216 2.9 0 8.59 0 8.61le4505c 450(2250) 120 4 1 1.49E+201 6.65 0 110.5 0 110.56le4505d 450(2250) 960 4 1 8.58E+200 6.64 0 54.57 0 54.58mug1001 100(400) 1.30E+037 2 5.33E+037 7.08E+041 0.01 4.20E+034 2.08 4.20E+034 15.59myciel5 47(282) - 1 7.70E+017 8.53E+032 0.02 7.29E+017 0.86 7.29E+017 6.37
Instances Vars Solutions ApproxBTD SampleCount-A SampleCount-LBpedigree (Bool vars) w #Sol Time #Sol Time #Sol Timeparkinson 34(340) 3.56E+010 2 2.33E+010 6.30E+011 0.02 4.08E+010 3.58 9.17E+008 25.62moissac3 72(1350) 4.89E+035 2 3.40E+035 6.11E+035 0.02 1.18E+034 16.93 6.75E+031 118.41langladeM7 427(8818) 6.73E+196 2 3.81E+193 8.07E+203 0.14 3.03E+179 816.9 - -
Advanced Constraint Processing, Fall 2009
Approximation results on SAT
239/8/2009
Instances Vars Solutions ApproxBTD SampleCount-A SampleCount-LBSAT (Bool vars) w #Sol Time #Sol Time #Sol Time
wff.3.100.150 100 1.80E+021 2 2.21E+021 1.95E+027 0.02 1.37E+021 959.8 - -wff.3.150.525 150 1.40E+014 2 9.93E+014 7.80E+040 0.2 3.80E+014 0.68 2.53E+012 4.65ssa7552-038 1501 2.84E+040 5 2.47E+037 1.51E+138 1.05 1.11E+040 134.2 3.54E+038 1162.06ssa7552-160 1391 7.47E+032 5 1.56E+034 2.23E+113 0.82 5.08E+032 144.6 2.31E+031 12932bitcomp5 125 9.84E+015 5 9.50E+016 1.75E+031 0.03 4.37E+015 0.184 3.26E+015 1.232bitmax6 252 2.10E+029 5 2.69E+030 4.27E+065 0.14 1.62E+029 1.676 2.36E+026 10.34ais10 181 296 9 1 2.86E+022 1.05 124 45.93 20 312.74ais12 265 1328 11 1 1.64E+040 3.78 0 9.156 0 9.17logistics.a 828 3.80E+014 10 1 2.33E+147 13.3 7.25E+011 170.9 0 605.33logistics.b 843 2.30E+023 13 1 2.28E+143 13.72 2.13E+023 198.7 0 229.86hanoi4 718 1 6 1 8.65E+107 1.57 0 5.24 0 5.25hanoi5 1931 1 7 1 2.62E+298 15.69 0 6.14 0 6.16
Advanced Constraint Processing, Fall 2009
Approximation results on coloring & pedigree
249/8/2009
Instances Vars Solutions ApproxBTD SampleCount-A SampleCount-LBcoloring (Bool vars) w #Sol Time #Sol Time #Sol Time2-Insertions3 37(148) 6.84E+013 1 1.91E+013 6.00E+017 0.01 4.73E+012 1 4.73E+012 7.422-Insertions4 149(596) - 1 1.30E+022 1.64E+071 0.07 0 3.76 0 3.78DSJC125.1 125(625) - 3 1.23E+013 2.27E+070 0.13 0 73.14 0 73.17games120 120(1080) - 8 1.12E+078 1.92E+099 9.83 0 13.76 1.35E+061 91.07GEOM30a 30(180) 4.98E+014 5 7.29E+014 1.81E+015 0.03 1.23E+013 0.432 3.28E+012 3.7GEOM40 40(240) 4.10E+023 5 4.42E+023 1.10E+024 0.02 2.14E+020 1.552 6.50E+019 9.31le4505a 450(2250) 3840 4 1 2.41E+216 2.87 0 8.56 0 8.58le4505b 450(2250) 120 4 1 5.71E+216 2.9 0 8.59 0 8.61le4505c 450(2250) 120 4 1 1.49E+201 6.65 0 110.5 0 110.56le4505d 450(2250) 960 4 1 8.58E+200 6.64 0 54.57 0 54.58mug1001 100(400) 1.30E+037 2 5.33E+037 7.08E+041 0.01 4.20E+034 2.08 4.20E+034 15.59myciel5 47(282) - 1 7.70E+017 8.53E+032 0.02 7.29E+017 0.86 7.29E+017 6.37
Instances Vars Solutions ApproxBTD SampleCount-A SampleCount-LBpedigree (Bool vars) w #Sol Time #Sol Time #Sol Timeparkinson 34(340) 3.56E+010 2 2.33E+010 6.30E+011 0.02 4.08E+010 3.58 9.17E+008 25.62moissac3 72(1350) 4.89E+035 2 3.40E+035 6.11E+035 0.02 1.18E+034 16.93 6.75E+031 118.41langladeM7 427(8818) 6.73E+196 2 3.81E+193 8.07E+203 0.14 3.03E+179 816.9 - -
Advanced Constraint Processing, Fall 2009
Approximation results on SAT
259/8/2009
Instances Vars Solutions ApproxBTD SampleCount-A SampleCount-LBSAT (Bool vars) w #Sol Time #Sol Time #Sol Time
wff.3.100.150 100 1.80E+021 2 2.21E+021 1.95E+027 0.02 1.37E+021 959.8 - -wff.3.150.525 150 1.40E+014 2 9.93E+014 7.80E+040 0.2 3.80E+014 0.68 2.53E+012 4.65ssa7552-038 1501 2.84E+040 5 2.47E+037 1.51E+138 1.05 1.11E+040 134.2 3.54E+038 1162.06ssa7552-160 1391 7.47E+032 5 1.56E+034 2.23E+113 0.82 5.08E+032 144.6 2.31E+031 12932bitcomp5 125 9.84E+015 5 9.50E+016 1.75E+031 0.03 4.37E+015 0.184 3.26E+015 1.232bitmax6 252 2.10E+029 5 2.69E+030 4.27E+065 0.14 1.62E+029 1.676 2.36E+026 10.34ais10 181 296 9 1 2.86E+022 1.05 124 45.93 20 312.74ais12 265 1328 11 1 1.64E+040 3.78 0 9.156 0 9.17logistics.a 828 3.80E+014 10 1 2.33E+147 13.3 7.25E+011 170.9 0 605.33logistics.b 843 2.30E+023 13 1 2.28E+143 13.72 2.13E+023 198.7 0 229.86hanoi4 718 1 6 1 8.65E+107 1.57 0 5.24 0 5.25hanoi5 1931 1 7 1 2.62E+298 15.69 0 6.14 0 6.16
Advanced Constraint Processing, Fall 2009
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.
8/25/2009 26
Advanced Constraint Processing, Fall 2009
Conclusions
279/8/2009
• The paper presents two methods for counting solutions of CSPs using the BTD1. Exact method, suitable for problems with small
tree width2. 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