Oct 22 - Lesson Plan - 473 Intro to AI 1. Walksat 2. Demo - N-Queens 3. Applications 4. Sat competition ************************************************** So far: systematic search Alternative: local search Idea: - start at some state (possibly random) - repeat until (at a goal state) { make small changes to state } Good when: - care about finding a goal state - do not care about how you get there - do not need to PROVE no goal state exists Example: Satisfiability state = complete truth assignment small change = flip value of one proposition ==> move to a NEIGHBOR search = random walk through space of assignments EVENTUALLY WILL FIND A SOLUTION WITH PROBABILITY APROACHING 1 IF THERE IS ONE! BUT: too slow! Better version: hill-climbing AKA gradiant descent h(state) = heuristic measure of distance to goal (NO need to be admissible! NOT A*!) repeat (until at a goal state){ move to neighbor with best h(n) } ------------------------------------------------------------- WHAT IF NO NEIGHBOR IS BETTER? Options: - give up - keep going WHAT IF SEVERAL NEIGHBORS ARE EQUALLY GOOD? - pick one at random WHY IS THIS CALLED HILL-CLIMBING???? (draw picture) WHICH WAY ARE WE CLIMBING? can go up up - gradiant ascent or down -- gradiant descent SUPPOSE THE HILL LOOKS LIKE THIS, AND WE START HERE. (draw picture with local minima) WHAT IS THE PROBLEM? local minima SOLUTION: allow "bad" moves. But when? 2-D case is EASY. But for SAT can have 1,000 dimensions! MANY possible strategies - one a simple, surprisingly effective one: Make a random (instead of best) move with a fixed probability. E.G. 20% noise ------------------------------------------------------------- Local Search for SAT h(S) = number of unsatisfied clauses IN PRACTICE, BETTER CHOICE IS: h(S1,P,S2) = number of clauses now satisfied in S2 that become unsatisfied if you flip proposition P resulting in S2 WALKSAT(cnf formula F, int maxflip){ S = random truth assignment i = 0; while (i++