cs137 today electronic design automation
play

CS137: Today Electronic Design Automation SAT Davis-Putnam - PDF document

CS137: Today Electronic Design Automation SAT Davis-Putnam Data Structures Day 10: October 19, 2005 Optimizations Modern SAT Solvers Watch2 VSIDS ({z}Chaff, GRASP,miniSAT) ?restarts Learning 1 2


  1. CS137: Today Electronic Design Automation • SAT • Davis-Putnam • Data Structures Day 10: October 19, 2005 • Optimizations Modern SAT Solvers – Watch2 – VSIDS ({z}Chaff, GRASP,miniSAT) – ?restarts • Learning 1 2 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon Problem CNF • SAT: Boolean Satisfiability • Conjunctive Normal Form • Given: logical formula f in CNF • Logical AND of a set of clauses • Find a set of variable assignments that • Clauses: logical OR of a set of literals makes f true • Literal: a variable or its complement • Or conclude no such assignment exists • E.g. (A+B+/C)*(/B+D)*(C+/A+/E) 3 4 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon CNF Search • Conjunctive Normal Form • Can be solved with pruning search • Logical AND of a set of clauses – Pick an unassigned variable – Branch on true/false • To be satisfied: – Compute implications – Every clause must be made true • (A+B+/C)*(/B+D)*(C+/A+/E) – If know D= false � B must be false 5 6 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon 1

  2. Davis-Putnam Previously while (true) { • Also looked at PODEM if (!decide()) // no unassigned vars – Backtracking search on variable return(satisfiable); assignment while ( !bcp()) { // constraint propagation if (!resolveConflict()) // backtrack return(not satisfiable); } } 7 8 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon decide() Data Structures • Picks an unassigned variable • Variable “array” • Gives it a value • Clause “DB” • Push on decision stack • Each clause is a set of variables – Efficient structure for depth- • Decision “stack” first search tree 9 10 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon bcp() bcp • Q=new queue(); • Q.insert(top of decision stack); • What do we need to do on each variable assignment? • while (!Q.empty()) – V=Q.pop(); – Find implications – For each clause C in DB with V • Implication when all other literals in a clause are false • If C has one unassigned literal, rest false • Look through all clauses this assignment effects – Vnew=unassigned literal in C • See if any now have all false and one unassigned – val=value Vnew must take – Assign implied values – If (Vnew assigned to value other than val) » return ( false ); // conflict – Propagate that assignment – Q.add(Vnew=val); – Conflict if get implications for true and false • return( true ) 11 12 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon 2

  3. Tracking Implications Variable array • Each implication made at • Each variable has a list pointing to all some tree level clauses in which it appears? – Associated with some entry on decision stack – Avoid need to look at every clause – Has associated decision stack height • On backtrack – Unassign implications above changed decision level 13 14 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon Track Variable Assignment Track Variable Assignment • Each clause has • Each clause has counter counter – Count number of unassigned literals – Count number of – Decrement when assign false literal unassigned literals – Decrement when – Mark clause as satisfied when assign true assign false literal literal (remove from clause database?) – Mark clause as satisfied when assign true literal (remove from clause database?) 15 16 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon Track Variable Assignment resolveConflict() • Each clause has counter • What does resolveConflict need to do? – Count number of unassigned literals – Decrement when assign false literal – Look at most recent decision – Mark clause as satisfied when assign true – If can go other way, switch value literal • (clear implications to this depth) – Watch for counter decrement 2 � 1 – Else pop and recurse on previous decision • That’s when a literal is implied. – If pop top decision, • unsatisfiable 17 18 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon 3

  4. How will this perform? • 10,000’s of variables Chaff Optimizations • 100,000’s of clauses (millions) • Every assignment walks to the clause database • Cache performance? 19 20 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon Challenge 1 Avoiding Clause Visits • Idea: watch only 2 variables in each • Currently, visit every clause on each clause assignment • Only care about final set of next to last – Clause with K variables variable – Visited K-1 times • If set other k-2, won’t force an implication – K-2 of which just to discover it’s not the last • When set one of these (and everything • Can we avoid visiting every clause on else set) every assignment? – Every clause in which a variable appears? – Then we have an implication 21 22 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon Watch 2 Data Structure Avoiding Clause Visits • Idea: watch only 2 variables in each clause • Only care about final set of next to last variable • What if we set of these two “watched” variables? – If not last, change the watch to one of the unset variables 23 24 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon 4

  5. Watch 2 Note • If watched literal becomes false • Watch pair is arbitrary – Check if all non-watched are set • Unassigning a variable (during • if so, set implication on other watched backtrack) • else, update watch literal – Does not require reset of watch set – Constant time to “unset” a variable 25 26 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon Challenge 2: Variable Ordering Variable Ordering • How do we decide() which variable to • Old Ideas: use next? – Random – Want to pick one that facilitates lots of – (DLIS) Dynamic largest individual sum pruning • Used most frequently in unresolved clauses • BAD? – Must re-sort with every variable assignment? – …none clearly superior • DLIS competitive • Rand good on CAD benchmarks? 27 28 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon New: VSIDS New: VSIDS • Variable State Independent Decaying • Variable State Independent Decaying Sum Sum – Each literal has a counter – Each literal has a counter – When clause added to DB, increment – When clause added to DB, increment counter for each literal counter for each literal • Remove clauses when satisfied? – Select unassigned literal with highest count • Reinsert on backtrack – Select unassigned literal with highest count – Periodically, all counters are divided by a constant – Periodically, all counters are divided by a constant 29 30 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon 5

  6. New: VSIDS VSIDS • Variable State Independent Decaying • Goal: satisfy recent conflict clauses Sum • Decaying sum weights things being – Each literal has a counter added – When clause added to DB, increment counter for – Clauses not conflicting for a while, have each literal values reduced – Select unassigned literal with highest count • (? Avoid walking through them by increasing • Don’t need to re-sort each selection weight on new stuff rather than decreasing all • Only re-sort on backtrack old?) • Maybe priority queue insert? • Impact: order of magnitude speedup – Periodically, all counters are divided by a constant 31 32 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon Restarts Overall • Periodically restart • Two orders of magnitude benefit on – Clearing the state of all variables unsatisfiable instances • i.e. clear decision stack • One order of magnitude on satisfiable – Leave clauses in clause database instances • ? Keep ordering based on recent costs • ? Re-insert clauses must reinsert on restart? – State of clause database drives variable ordering • Benefit: new variable ordering based on lessons of previous search 33 34 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon Learning • When encounter a conflict Learning – Determine variable assignment contributing to conflict – Add new clause to database • New clause allows pruning 35 36 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon 6

  7. Davis-Putnam w/ Learning Implication Graph while (true) { • As perform bcp propagation if (!decide()) // no unassigned vars – When set variable, insert back link to return(satisfiable); previous variable set forcing this variable while ( !bcp()) { // constraint propagation set analyzeConflicts(); // learning – Graph captures what this implication if (!resolveConflict()) // backtrack depends upon return(not satisfiable); • When encounter a conflict } – Identify what variable values caused } 37 38 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon Example Conflict Resolution • x1 & /x9 & /x10 & /x11 lead to conflict • /(x1 & /x9 & /x10 & /x11) • /x1+x9+x10+x11 � new clause for DB Marques-Silva/Sakallah TRCOMP v48n5p506 1999 39 40 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon New Clause More Implications •New clause does not include x12, x13 •May encounter this case again • x4 & /x10 & /x11 lead to conflict • /x4+x10+x11 � new clause for DB • Also (/x1+x9+x4) 41 42 CALTECH CS137 Fall2005 -- DeHon CALTECH CS137 Fall2005 -- DeHon 7

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend