CSC 380: Design and Analysis of Algorithms Dr. Curry Guinn
Quick Info Dr. Curry Guinn CIS 2015 guinnc@uncw.edu www.uncw.edu/people/guinnc 962-7937 Office Hours: MWF: 10:00am-11:00m and by appointment
Outline of today Satisfiability 3-SAT Brute force Hill climbing Simulated annealing
The Satisfiability Problem Given a set of propositional logic clauses, find an assignment of truth values to each symbol so that all of the clauses are true. (P -> Q & S) & (~P & ~Q) & (S | ~Q)
3SAT is a special case All clauses contain the disjunction of 3 terms Disjunction means OR Each term is of the form P or ~P. (P | Q | ~S) & (~P | ~Q | ~S) & (P | ~Q | S) It turns out that any SAT case, can be transformed into 3SAT
3SAT is an NP-complete problem Which means that it is map-able to other NP-complete problems such as Traveling salesman Clique Map coloring Knapsack, Etc. What do I mean by “map-able”?
Suppose we want to actually write code to solve this problem How do we do it? Analysis Design Implement Test
Analysis Can we write down the problem?
Write down the problem Find a set of truth assignments for the propositional symbols such that are of the clauses are true. Each clause consist of a disjunction (OR) of three terms. Each term is either a proposition symbol or its negation (i.e., P or ~P). More generally, for a particular problem, we will have n different propositional symbols and m different clauses. Do you want to add anything?
Find the nouns. Why?
Find the nouns. Why? Find a set of truth assignments for the propositional symbols such that all of the clauses are true. Each clause consist of a disjunction (OR) of three terms. Each term is either a proposition symbol or its negation (i.e., P or ~P). More generally, for a particular problem, we will have n different propositional symbols and m different clauses.
Start making UML diagrams of the classes Term Clause Symbol TruthAssignment Problem
See board and IDE
Iterative Improvement Algorithms Essentially, guess at a solution and then make improvements until you find a solution. Not important how you get there. Hill climbing Simulated annealing
Local search algorithms In many optimization problems, the path to the goal is irrelevant; the goal state itself is the solution State space = set of "complete" configurations Find configuration satisfying constraints, e.g., n-queens In such cases, we can use local search algorithms keep a single "current" state, try to improve it
Example: n-queens Put n queens on an n × n board with no two queens on the same row, column, or diagonal
Hill-climbing search "Like climbing Everest in thick fog with amnesia"
Hill-climbing search Problem: depending on initial state, can get stuck in local maxima
Hill-climbing search: 8-queens problem h = number of pairs of queens that are attacking each other, either directly or indirectly h = 17 for the above state
Hill-climbing search: 8-queens problem A local minimum with h = 1
Hill climbing From a guess, always choose a successor state that is closer to the solution. Problems Local maxima Plateaux Ridges Solution: Random-restart ... or ...
Simulated annealing Instead of always choosing the “best” successor, occasionally choose something that is worse at random.
Simulated annealing search Idea: escape local maxima by allowing some "bad" moves but gradually decrease their frequency
Properties of simulated annealing search One can prove: If T decreases slowly enough, then simulated annealing search will find a global optimum with probability approaching 1 Widely used in VLSI layout, airline scheduling, etc
For Next Class, Wednesday Read about Hill Climbing