Combining Component Combining Component Caching and Clause Caching and Clause Learning for Effective Learning for Effective Model Counting Model Counting Tian Sang Tian Sang University of Washington University of Washington Fahiem Bacchus (U Toronto), Paul Beame Fahiem Bacchus (U Toronto), Paul Beame (UW), (UW), Henry Kautz (UW), & Toniann Pitassi (U Henry Kautz (UW), & Toniann Pitassi (U Toronto) Toronto)
32
Embed
Combining Component Caching and Clause Learning for Effective Model Counting Tian Sang University of Washington Fahiem Bacchus (U Toronto), Paul Beame.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Combining Component Caching Combining Component Caching and Clause Learning for Effective and Clause Learning for Effective
Model Counting Model Counting
Tian SangTian SangUniversity of WashingtonUniversity of Washington
Fahiem Bacchus (U Toronto), Paul Beame (UW), Fahiem Bacchus (U Toronto), Paul Beame (UW), Henry Kautz (UW), & Toniann Pitassi (U Toronto)Henry Kautz (UW), & Toniann Pitassi (U Toronto)
Why #SAT?Why #SAT?
Prototypical #P complete problemPrototypical #P complete problem Natural encoding for counting problemsNatural encoding for counting problems
Test-set sizeTest-set size CMOS power consumptionCMOS power consumption
Can encode probabilistic inferenceCan encode probabilistic inference
DPLL with Clause LearningDPLL with Clause Learning
Conflict GraphConflict Graph
Decision scheme(p q b)
1-UIP scheme(t)
p
q
b
a
x1
x2
x3
y
yfalset
Known Clauses(p q a)
( a b t)(t x1)(t x2)(t x3)
(x1 x2 x3 y)(x2 y)
Current decisionsp falseq falseb true
Component AnalysisComponent Analysis
Can use DPLL to count modelsCan use DPLL to count models Just don’t stop when first assignment is foundJust don’t stop when first assignment is found
If formula breaks into If formula breaks into separate componentsseparate components (no shared variables), can count each (no shared variables), can count each separately and multiply results:separately and multiply results: #SAT(C#SAT(C1 C C2) = #SAT(C) = #SAT(C1) * #SAT(C) * #SAT(C2))
(Bayardo & Shrag 1996)(Bayardo & Shrag 1996)
Formula CachingFormula Caching
New idea: cache number of models of New idea: cache number of models of residual formulas at each noderesidual formulas at each node Bacchus, Dalmao & Pitassi 2003Bacchus, Dalmao & Pitassi 2003 Beame, Impagliazzo, Pitassi, & Segerlind 2003Beame, Impagliazzo, Pitassi, & Segerlind 2003
Matches time/space tradeoffs of best known Matches time/space tradeoffs of best known exact probabilistic inference algorithms:exact probabilistic inference algorithms:
(1) ( )
( log )
2
2
O O w
O w n
n wwhere is tree - width of formula
if only linear space is used for cache
#SAT with Component Caching#SAT with Component Caching#SAT(F) #SAT(F) // Returns fraction of all truth// Returns fraction of all truth
// assignments that satisfy F// assignments that satisfy F a = 1;a = 1;for each G for each G to_components(F) to_components(F) { {
if (G == if (G == ) m = 1;) m = 1;else if (else if ( G) m = 0; G) m = 0;else else if (in_cache(G)) m = if (in_cache(G)) m =
cache_value(G);cache_value(G);else { select v else { select v G; G;
m = ½ * #SAT(G|v) + m = ½ * #SAT(G|v) + ½ * #SAT(G|½ * #SAT(G|v);v);
insert_cache(G,m);insert_cache(G,m);}}
if (m == 0) return 0;if (m == 0) return 0;a = a * m; }a = a * m; }
to create a to create a practicalpractical #SAT algorithm #SAT algorithm Not Not quitequite as straightforward as it looks! as straightforward as it looks!
Issue 1: How Much to Cache?Issue 1: How Much to Cache?
EverythingEverything Infeasible – often > 10,000,000 nodesInfeasible – often > 10,000,000 nodes
Only sub-formulas on current branchOnly sub-formulas on current branch Linear spaceLinear space Similar to recursive conditioningSimilar to recursive conditioning
[Darwiche 2002[Darwiche 2002]]
Can we do better?Can we do better?
Age versus Cumulative HitsAge versus Cumulative Hits
age = time elapsed since the entry was cachedage = time elapsed since the entry was cached
Age-bounded cachingAge-bounded caching Separate-chaining hash tableSeparate-chaining hash table Lazy deletion of entries older than Lazy deletion of entries older than KK when when
searching chainssearching chains Constant amortized timeConstant amortized time
Issue 2: Interaction of Component Issue 2: Interaction of Component Analysis & Clause LearningAnalysis & Clause Learning
As clause learning progresses, formula As clause learning progresses, formula becomes becomes hugehuge
Use only clauses Use only clauses derived from originalderived from original formula forformula for Component analysisComponent analysis ““Keys” for cached entriesKeys” for cached entries
Use Use all the learned clausesall the learned clauses for unit for unit propagationpropagation
Can this possibly be sound?Can this possibly be sound?
Almost!
Safety TheoremSafety Theorem
Given:Given:
original formula Foriginal formula F
learned clauses Glearned clauses G
partial assignment partial assignment F|F| is satisfiable is satisfiable
AAi is a component of F| is a component of F|
satisfies Asatisfies Ai
F| G|
A2A1 A3
Then:
can be extended to satisfy G|
It is safe to use learned clauses for unit propagation for SAT sub-formulas
UNSAT Sub-formulasUNSAT Sub-formulas
But if F|But if F| is is unsatisfiableunsatisfiable, all bets are off..., all bets are off... Without component caching, there is still no Without component caching, there is still no
problem – because the final value is 0 in any problem – because the final value is 0 in any casecase
With component caching, could cause With component caching, could cause incorrect values to be cachedincorrect values to be cached
Solution:Solution:Flush siblings (& their descendents) of UNSAT Flush siblings (& their descendents) of UNSAT
Implementation based on zChaff Implementation based on zChaff (Moskewicz, Madigan, Zhao, Zhang, & Malik 2001)(Moskewicz, Madigan, Zhao, Zhang, & Malik 2001)
1010 110/191110/191 6.95E+186.95E+18 XX 0.060.06 0.670.67 0.920.92 69616961
1515 240/436240/436 3.01E+543.01E+54 XX 0.530.53 465465 106106 XX
2020 420/781420/781 5.06E+955.06E+95 XX 33 XX XX XX
2525 650/1226650/1226 1.81E+1511.81E+151 XX 3535 XX XX XX
3030 930/1771930/1771 1.54E+2181.54E+218 XX 3737 XX XX XX
X means time-out after 12 hours
SummarySummary
A A practical exact model-counting algorithmpractical exact model-counting algorithm can be built by the careful combination ofcan be built by the careful combination of Bounded component analysisBounded component analysis Component cachingComponent caching Clause learningClause learning
Outperforms the best previous algorithm Outperforms the best previous algorithm by orders of magnitudeby orders of magnitude
Incremental component analysisIncremental component analysis Currently consumes 10-50% of run time!Currently consumes 10-50% of run time!
Applications to Bayesian networksApplications to Bayesian networks Compiler for discrete BN to weighted #SATCompiler for discrete BN to weighted #SAT Direct BN implementationDirect BN implementation
Applications to other #P problemsApplications to other #P problems Testing, model-based diagnosis, …Testing, model-based diagnosis, …
Bayesian Nets to CountingBayesian Nets to Counting
Unweighted counting is case where all Unweighted counting is case where all non-defined variables have weight 0.5non-defined variables have weight 0.5
Introduce sets of variables to define other Introduce sets of variables to define other probabilities to desired accuracyprobabilities to desired accuracy
In practice: just modify #SAT algorithm to In practice: just modify #SAT algorithm to weighted #SATweighted #SAT