Satisfiability Solvers

Slides:



Advertisements
Similar presentations
Propositional Satisfiability (SAT) Toby Walsh Cork Constraint Computation Centre University College Cork Ireland 4c.ucc.ie/~tw/sat/
Advertisements

Local Search Jim Little UBC CS 322 – CSP October 3, 2014 Textbook §4.8
CPSC 322, Lecture 14Slide 1 Local Search Computer Science cpsc322, Lecture 14 (Textbook Chpt 4.8) Oct, 5, 2012.
Neural and Evolutionary Computing - Lecture 4 1 Random Search Algorithms. Simulated Annealing Motivation Simple Random Search Algorithms Simulated Annealing.
LOCAL SEARCH AND CONTINUOUS SEARCH. Local search algorithms  In many optimization problems, the path to the goal is irrelevant ; the goal state itself.
CPSC 322, Lecture 16Slide 1 Stochastic Local Search Variants Computer Science cpsc322, Lecture 16 (Textbook Chpt 4.8) February, 9, 2009.
Local and Stochastic Search based on Russ Greiner’s notes.
Local search algorithms
Local search algorithms
Ryan Kinworthy 2/26/20031 Chapter 7- Local Search part 1 Ryan Kinworthy CSCE Advanced Constraint Processing.
Optimization via Search CPSC 315 – Programming Studio Spring 2009 Project 2, Lecture 4 Adapted from slides of Yoonsuck Choe.
Local and Stochastic Search Based on Russ Greiner’s notes.
Iterative Improvement Algorithms
Introduction to Artificial Intelligence Local Search (updated 4/30/2006) Henry Kautz.
CS 4700: Foundations of Artificial Intelligence
Knowledge Representation II (Inference in Propositional Logic) CSE 473.
Informed Search Chapter 4 Adapted from materials by Tim Finin, Marie desJardins, and Charles R. Dyer CS 63.
Knowledge Representation II (Inference in Propositional Logic) CSE 473 Continued…
Lukas Kroc, Ashish Sabharwal, Bart Selman Cornell University, USA SAT 2010 Conference Edinburgh, July 2010 An Empirical Study of Optimal Noise and Runtime.
Logic - Part 2 CSE 573. © Daniel S. Weld 2 Reading Already assigned R&N ch 5, 7, 8, 11 thru 11.2 For next time R&N 9.1, 9.2, 11.4 [optional 11.5]
Optimization via Search CPSC 315 – Programming Studio Spring 2008 Project 2, Lecture 4 Adapted from slides of Yoonsuck Choe.
Metaheuristics The idea: search the solution space directly. No math models, only a set of algorithmic steps, iterative method. Find a feasible solution.
1 Local search and optimization Local search= use single current state and move to neighboring states. Advantages: –Use very little memory –Find often.
/425 Declarative Methods - J. Eisner1 Satisfiability Solvers Part 2: Stochastic Solvers.
Constrainedness Including slides from Toby Walsh.
An Introduction to Artificial Life Lecture 4b: Informed Search and Exploration Ramin Halavati In which we see how information.
Local Search Algorithms This lecture topic Chapter Next lecture topic Chapter 5 (Please read lecture topic material before and after each lecture.
Local Search: walksat, ant colonies, and genetic algorithms.
2005MEE Software Engineering Lecture 11 – Optimisation Techniques.
Local Search Pat Riddle 2012 Semester 2 Patricia J Riddle Adapted from slides by Stuart Russell,
Local Search Introduction to Artificial Intelligence COS302 Michael L. Littman Fall 2001.
Local Search and Optimization Presented by Collin Kanaley.
/425 Declarative Methods - J. Eisner 1 Random 3-SAT  sample uniformly from space of all possible 3- clauses  n variables, l clauses Which are.
Local search algorithms In many optimization problems, the state space is the space of all possible complete solutions We have an objective function that.
© Daniel S. Weld 1 Logistics Problem Set 2 Due Wed A few KR problems Robocode 1.Form teams of 2 people 2.Write design document.
Optimization Problems
Local Search. Systematic versus local search u Systematic search  Breadth-first, depth-first, IDDFS, A*, IDA*, etc  Keep one or more paths in memory.
INTRO TO OPTIMIZATION MATH-415 Numerical Analysis 1.
CPSC 322, Lecture 16Slide 1 Stochastic Local Search Variants Computer Science cpsc322, Lecture 16 (Textbook Chpt 4.8) Oct, 11, 2013.
Inference in Propositional Logic (and Intro to SAT) CSE 473.
Escaping Local Optima. Where are we? Optimization methods Complete solutions Partial solutions Exhaustive search Hill climbing Exhaustive search Hill.
Local Search Algorithms CMPT 463. When: Tuesday, April 5 3:30PM Where: RLC 105 Team based: one, two or three people per team Languages: Python, C++ and.
1 Intro to AI Local Search. 2 Intro to AI Local search and optimization Local search: –use single current state & move to neighboring states Idea: –start.
Games: Expectimax MAX MIN MAX Prune if α ≥ β. Games: Expectimax MAX MIN MAX
Optimization Problems
Optimization via Search
CSCI 4310 Lecture 10: Local Search Algorithms
Inference in Propositional Logic (and Intro to SAT)
Department of Computer Science
For Monday Chapter 6 Homework: Chapter 3, exercise 7.
Foundations of Constraint Processing
Local Search Algorithms
Local Search Strategies: From N-Queens to Walksat
Computer Science cpsc322, Lecture 14
Artificial Intelligence (CS 370D)
Subject Name: Operation Research Subject Code: 10CS661 Prepared By:Mrs
Computer Science cpsc322, Lecture 14
Optimization Problems
Heuristics Local Search
School of Computer Science & Engineering
More on Search: A* and Optimization
Stochastic Local Search Variants Computer Science cpsc322, Lecture 16
Heuristics Local Search
Boltzmann Machine (BM) (§6.4)
Foundations of Constraint Processing
Lecture 9 Administration Heuristic search, continued
More on HW 2 (due Jan 26) Again, it must be in Python 2.7.
More on HW 2 (due Jan 26) Again, it must be in Python 2.7.
Local Search Algorithms
Local Search Algorithms
Presentation transcript:

Satisfiability Solvers Part 2: Stochastic Solvers 600.325/425 Declarative Methods - J. Eisner

Structured vs. Random Problems So far, we’ve been dealing with SAT problems that encode other problems Most not as hard as # of variables & clauses suggests Small crossword grid + medium-sized dictionary may turn into a big formula … but still a small puzzle at some level Unit propagation does a lot of work for you Clause learning picks up on the structure of the encoding But some random SAT problems really are hard! zChaff’s tricks don’t work so well here 600.325/425 Declarative Methods - J. Eisner

600.325/425 Declarative Methods - J. Eisner Random 3-SAT sample uniformly from space of all possible 3-clauses n variables, l clauses Which are the hard instances? around l/n = 4.26 600.325/425 Declarative Methods - J. Eisner slide thanks to Henry Kautz (modified)

600.325/425 Declarative Methods - J. Eisner The magic ratio 4.26 Complexity peak is very stable … across problem sizes across solver types systematic (last lecture) stochastic (this lecture) 600.325/425 Declarative Methods - J. Eisner slide thanks to Henry Kautz (modified)

600.325/425 Declarative Methods - J. Eisner Why 4.26? Complexity peak coincides with solubility transition l/n < 4.3 problems under-constrained and SAT l/n > 4.3 problems over-constrained and UNSAT l/n=4.3, problems on “knife-edge” between SAT and UNSAT 600.325/425 Declarative Methods - J. Eisner slide thanks to Henry Kautz (modified)

That’s called a “phase transition” Problems < 32˚F are like ice; > 32˚F are like water Similar “phase transitions” for other NP-hard problems job shop scheduling traveling salesperson (instances from TSPlib) exam timetables (instances from Edinburgh) Boolean circuit synthesis Latin squares (alias sports scheduling) Hot research topic: predict hardness of a given instance, & use hardness to control search strategy (Horvitz, Kautz, Ruan 2001-3) 600.325/425 Declarative Methods - J. Eisner slide thanks to Henry Kautz (modified)

Methods in today’s lecture … Can handle “big” random SAT problems Can go up about 10x bigger than systematic solvers!  Rather smaller than structured problems (espec. if ratio  4.26) Also handle big structured SAT problems But lose here to best systematic solvers  Try hard to find a good solution Very useful for approximating MAX-SAT Not intended to find all solutions Not intended to show that there are no solutions (UNSAT) 600.325/425 Declarative Methods - J. Eisner

GSAT vs. DP on Hard Random Instances today (not today’s best algorithm) yesterday (not yesterday’s best algorithm) 600.325/425 Declarative Methods - J. Eisner slide thanks to Russ Greiner and Dekang Lin

600.325/425 Declarative Methods - J. Eisner Local search for SAT Make a guess (smart or dumb) about values of the variables Try flipping a variable to make things better Algorithms differ on which variable to flip Repeat until satisfied How’m I doin’? 600.325/425 Declarative Methods - J. Eisner

600.325/425 Declarative Methods - J. Eisner Local search for SAT Make a guess (smart or dumb) about values of the variables Try flipping a variable that makes things better How’m I doin’? Repeat until satisfied Flip a randomly chosen variable? No, blundering around blindly takes exponential time Ought to pick a variable that improves … what? Increase the # of satisfied clauses as much as possible Break ties randomly Note: Flipping a var will repair some clauses and break others This is the “GSAT” (Greedy SAT) algorithm (almost) 600.325/425 Declarative Methods - J. Eisner

600.325/425 Declarative Methods - J. Eisner Local search for SAT Make a guess (smart or dumb) about values of the variables Try flipping a variable that makes things better How’m I doin’? Repeat until satisfied Flip most-improving variable. Guaranteed to work? What if first guess is A=1, B=1, C=1? 2 clauses satisfied Flip A to 0  3 clauses satisfied Flip B to 0  all 4 clauses satisfied (pick this!) Flip C to 0  3 clauses satisfied A v C A v B ~C v ~B ~B v ~A 600.325/425 Declarative Methods - J. Eisner example thanks to Monaldo Mastrolilli and Luca Maria Gambardella

600.325/425 Declarative Methods - J. Eisner Local search for SAT Make a guess (smart or dumb) about values of the variables Try flipping a variable that makes things better How’m I doin’? Repeat until satisfied Flip most-improving variable. Guaranteed to work? But what if first guess is A=0, B=1, C=1? 3 clauses satisfied Flip A to 1  3 clauses satisfied Flip B to 0  3 clauses satisfied Flip C to 0  3 clauses satisfied Pick one anyway … (picking A wins on next step) A v C A v B ~C v ~B ~B v ~A 600.325/425 Declarative Methods - J. Eisner example thanks to Monaldo Mastrolilli and Luca Maria Gambardella

600.325/425 Declarative Methods - J. Eisner Local search for SAT Make a guess (smart or dumb) about values of the variables Try flipping a variable that makes things better How’m I doin’? Repeat until satisfied Flip most-improving variable. Guaranteed to work? Yes for 2-SAT: probability  1 within O(n2) steps No in general: can & usually does get locally stuck Therefore, GSAT just restarts periodically New random initial guess Believe it or not, GSAT outperformed everything else when it was invented in 1992. 600.325/425 Declarative Methods - J. Eisner example thanks to Monaldo Mastrolilli and Luca Maria Gambardella

Discrete vs. Continous Optimization In MAX-SAT, we’re maximizing a real-valued function of n boolean variables SAT is the special case where the function is –infinity or 0 everywhere This is discrete optimization since the variables can’t change gradually You may already know a little about continuous optimization From your calculus class: maximize a function by requiring all its partial derivatives = 0 But what if you can’t solve those simultaneous equations? Well, the partial derivatives tell you which direction to change each variable if you want to increase the function 600.325/425 Declarative Methods - J. Eisner

Gradient Ascent (or Gradient Descent) nice smooth and convex cost function nasty non-differentiable cost function with local maxima GSAT is a greedy local optimization algorithm: Like a discrete version of gradient ascent. Could we make a continuous version of the SAT problem? What would happen if we tried to solve it by gradient ascent? Note: There are alternatives to gradient descent … conjugate gradient, variable metric, simulated annealing, etc. Go take an optimization course: 550.{361,661,662}. Or just download some software! 600.325/425 Declarative Methods - J. Eisner

Problems with Hill Climbing 600.325/425 Declarative Methods - J. Eisner slide thanks to Russ Greiner and Dekang Lin

Problems with Hill Climbing Local Optima (foothills): No neighbor is better, but not at global optimum. (Maze: may have to move AWAY from goal to find (best) solution) Plateaus: All neighbors look the same. (15-puzzle: perhaps no action will change # of tiles out of place) Ridge: going up only in a narrow direction. Suppose no change going South, or going East, but big win going SE: have to flip 2 vars at once Ignorance of the peak: Am I done? 600.325/425 Declarative Methods - J. Eisner slide thanks to Russ Greiner and Dekang Lin

How to escape local optima? Restart every so often Don’t be so greedy (more randomness) Walk algorithms: With some probability, flip a randomly chosen variable instead of a best-improving variable WalkSAT algorithms: Confine selection to variables in a single, randomly chosen unsatisfied clause (also faster!) Simulated annealing (general technique): Probability of flipping is related to how much it helps/hurts Force the algorithm to move away from current solution Tabu algs: Refuse to flip back a var flipped in past t steps Novelty algs for WalkSAT: With some probability, refuse to flip back the most recently flipped var in a clause Dynamic local search algorithms: Gradually increase weight of unsatisfied clauses 600.325/425 Declarative Methods - J. Eisner

How to escape local optima? Lots of algorithms have been tried … Simulated annealing, genetic or evolutionary algorithms, GSAT, GWSAT, GSAT/Tabu, HSAT, HWSAT, WalkSAT/SKC, WalkSAT/Tabu, Novelty, Novelty+, R-Novelty(+), Adaptive Novelty(+), … 600.325/425 Declarative Methods - J. Eisner

Adaptive Novelty+ (current winner) How do we generalize to MAX-SAT? Adaptive Novelty+ (current winner) with probability 1% (the “+” part) Choose randomly among all variables that appear in at least one unsatisfied clause else be greedier (other 99%) Randomly choose an unsatisfied clause C Flipping any variable in C will at least fix C Choose the most-improving variable in C … except … with probability p, ignore most recently flipped variable in C The “adaptive” part: If we improved # of satisfied clauses, decrease p slightly If we haven’t gotten an improvement for a while, increase p If we’ve been searching too long, restart the whole algorithm (the “novelty” part) 600.325/425 Declarative Methods - J. Eisner

600.325/425 Declarative Methods - J. Eisner WalkSAT/SKC (first good local search algorithm for SAT, very influential) Choose an unsatisfied clause C Flipping any variable in C will at least fix C Compute a “break score” for each var in C Flipping it would break how many other clauses? If C has any vars with break score 0 Pick at random among the vars with break score 0 else with probability p Pick at random among the vars with min break score else Pick at random among all vars in C 600.325/425 Declarative Methods - J. Eisner

600.325/425 Declarative Methods - J. Eisner Simulated Annealing (popular general local search technique – often very effective, rather slow) Pick a variable at random If flipping it improves assignment: do it. Else flip anyway with probability p = e-/T where  = damage to score What is p for =0? For large ? T = “temperature” What is p as T tends to infinity? Higher T = more random, non-greedy exploration As we run, decrease T from high temperature to near 0. 600.325/425 Declarative Methods - J. Eisner slide thanks to Russ Greiner and Dekang Lin (modified)

Simulated Annealing and Markov Chains [discuss connection between optimization and sampling] 600.325/425 Declarative Methods - J. Eisner

Evolutionary algorithms (another popular general technique) Many local searches at once Consider 20 random initial assignments Each one gets to try flipping 3 different variables (“reproduction with mutation”) Now we have 60 assignments Keep the best 20 (“natural selection”), and continue 600.325/425 Declarative Methods - J. Eisner

600.325/425 Declarative Methods - J. Eisner Sexual reproduction (another popular general technique – at least for evolutionary algorithms) Derive each new assignment by somehow combining two old assignments, not just modifying one (“sexual reproduction” or “crossover”) 1 0 1 0 1 1 1 1 1 0 0 0 1 1 Parent 1 Parent 2 1 0 1 0 0 1 1 1 1 0 0 1 1 0 Child 1 Child 2 Mutation Good idea? 600.325/425 Declarative Methods - J. Eisner slide thanks to Russ Greiner and Dekang Lin (modified)