Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 4700: Foundations of Artificial Intelligence

Similar presentations


Presentation on theme: "CS 4700: Foundations of Artificial Intelligence"— Presentation transcript:

1 CS 4700: Foundations of Artificial Intelligence
Carla P. Gomes Module: Local Search (Reading R&N: Chapter 4:3 and 5:3)

2 So far:  methods that systematically explore the search space, possibly using principled pruning (e.g., A*) Current best such algorithm can handle search spaces of up to states / around 500 binary variables (“ballpark” number only!) What if we have much larger search spaces? Search spaces for some real-world problems might be much larger - e.g. 1030,000 states.  A completely different kind of method is called for: Local search methods or Iterative Improvement Methods (or Metaheuristics, OR)

3 Local Search Approach quite general used in:
planning, scheduling, routing, configuration, protein folding, etc In fact, many (most?) large Operations Research problems are solved using local search methods (e.g., airline scheduling).

4 Local Search Key idea (surprisingly simple):
Select (random) initial state (initial guess at solution) Make local modification to improve current state Repeat Step 2 until goal state found (or out of time) Requirements: generate an initial (often random; probably-not-optimal or even valid) guess evaluate quality of guess move to other states (well-defined neighborhood function) . . . and do these operations quickly . . . and don't save paths followed

5 Hill-climbing search "Like climbing Everest in thick fog with amnesia”
 Move to a better “neighbor” Note: “successor” normally called neighbor.

6 Local search for CSPs Hill-climbing, simulated annealing typically work with "complete" states, i.e., all variables assigned To apply to CSPs: allow states with unsatisfied constraints operators reassign variable values Variable selection: randomly select any conflicted variable Value selection by min-conflicts heuristic: choose value that violates the fewest constraints i.e., hill-climb with h(n) = total number of violated constraints

7 Queens States: 4 queens in 4 columns (256 states)
Neighborhood Operators: move queen in column Goal test: no attacks Evaluation: h(n) = number of attacks Not valid initial solution

8 8 Queens Min-Conflicts Heuristic
1 2 3 2 Pick initial complete assignment (at random) Repeat Pick a conflicted variable var (at random) Set the new value of var to minimize the number of conflicts If the new assignment is not conflicting then return it (Min-conflicts heuristics) Inspired GSAT and Walksat

9 Remark Local search with min-conflict heuristic works extremely well for million-queen problems The reason: Solutions are densely distributed in the O(nn) space, which means that on the average a solution is a few steps away from a randomly picked assignment

10 Stochastic Hill-climbing search: 8-queens problem
Pick next move randomly from among uphill moves. (many other variations of hill climbing) h = number of pairs of queens that are attacking each other, either directly or indirectly h = 17 for the above state Operators: move queen in column - best move leads to h=12 (marked with square)

11 Problems with Hill Climbing
Foothills / Local Optimal: 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. (8-puzzle: perhaps no action will change # of tiles out of place) Ridges: sequence of local maxima Ignorance of the peak: Am I done?

12 Hill-climbing search: 8-queens problem
What’s the value of the evaluation function h, (num. of attacking queens)? h = 1 Find a move to improve it. A local minimum with h = 1

13 Hill-climbing search Random-restart hill climibing
Problem: depending on initial state, can get stuck in local optimum (here maximum) How to overcome local optima and plateaus ? Random-restart hill climibing

14 Variations on Hill-Climbing
Random restarts: Simply restart at a new random state after a pre-defined number of steps. Local Beam Search: Run the random starting points in parallel, always keeping the k most promising states Random restarts: Probability of failure is 86%. How often need to restart on average, before finding solutions? 1* * 0.86* * 0.86 * 0.86 * = 7.14 Example: Plot from previous figure. If we start in different places, we’ll eventually find a good solution. Benefits of beam search Don’t spend a long time when start at bad random positions. Potential problems? Clustering if all the best states are near by (in which case use stochastic beam search, choosing successors to keep at random proportionally to the value) Lots of local maxima (e.g. ridges) Success of hill climbing searches - depends on shape of state space surface. If there are only a few local maxima, it works well! Q: When will these methods still fail? A: Lots of local maxima.

15 Local beam search Start with k randomly generated states
Keep track of k states rather than just one At each iteration, all the successors of all k states are generated If any one is a goal state, stop; else select the k best successors from the complete list and repeat. Equivalent to k random-restart hill-climbing???? No: This is different than k random restarts since information is shared between k search points: Some search points may contribute none to best successors: one search point may contribute all k successors “Come over here, the grass is greener” (Russell and Norvig)

16 Improvements to Basic Local Search
Issue: How to move more quickly to successively better plateaus? Avoid “getting stuck” / local maxima? Idea: Introduce downhill moves (“noise”) to escape from plateaus/local maxima Noise strategies: 1. Simulated Annealing Kirkpatrick et al. 1982; Metropolis et al. 1953 2. Mixed Random Walk (Satisfiability) Selman and Kautz 1993

17 Simulated Annealing Idea:
Use conventional hill-climbing style techniques, but occasionally take a step in a direction other than that in which there is improvement (downhill moves). As time passes, the probability that a down-hill step is taken is gradually reduced and the size of any down-hill step taken is decreased. Kirkpatrick et al. 1982; Metropolis et al.1953. Purpose of SA is to avoid local maxima. (Most frequently encountered difficulty with hill climbing.) Idea... [allows downhill steps occasionally]. The undirected steps won't in general reduce the ability of the procedure to find a global maximum (although they might increase the running time). But they may dislodge the problem solver from a foothill, i.e., a local maximum. Q: Why large steps at first? A: To avoid local maxima that extend over a wide area of the search space. Like doing a lot of exploring of the whole search space early. Subsequent undirected steps are smaller because we expect to only have to avoid more restricted local maxima. Name came from an analogy with metal-casting.

18 Another Approach: Simulated annealing search
Idea: escape local maxima by allowing some "bad" moves but gradually decrease their frequency Similar to hill climbing, but a random move instead of best move case of improvement, make the move Otherwise, choose the move with probability that decreases exponentially with the “badness” of the move. What’s the probability when: T  inf? What’s the probability when: T  0? What’s the probability when: =0? What’s the probability when: -∞?

19 Notes on Simulated Annealing
Noise model based on statistical mechanics . . . introduced as analogue to physical process of growing crystals Kirkpatrick et al. 1982; Metropolis et al. 1953 Convergence: 1. W/ exponential schedule, will converge to global optimum One can prove: If T decreases slowly enough, then simulated annealing search will find a global optimum with probability approaching 1 2. No more-precise convergence rate (Recent work on rapidly mixing Markov chains) Key aspect: downwards / sideways moves Expensive, but (if have enough time) can be best Hundreds of papers/ year; Many applications: VLSI layout, factory scheduling, protein folding. . .

20 Genetic Algorithms

21 Genetic Algorithms Another class of iterative improvement algorithms
A genetic algorithm maintains a population of candidate solutions for the problem at hand, and makes it evolve by iteratively applying a set of stochastic operators Inspired by the biological evolution process Uses concepts of “Natural Selection” and “Genetic Inheritance” (Darwin 1859) Originally developed by John Holland (1975)

22 High-level Algorithm Randomly generate an initial population.
Evaluate the fitness population Select parents and “reproduce” the next generation Replace the old generation with the new generation Repeat step 2 though 4 till iteration N T is predefined by the user.

23 Stochastic Operators Cross-over
decomposes two distinct solutions and then randomly mixes their parts to form novel solutions Mutation randomly perturbs a candidate solution

24 Genetic Algorithm Operators: Mutation and Crossover
Parent 1 Mutation Parent 2 How are the children produce? Child 1 Child 2

25 Genetic algorithms A successor state is generated by combining two parent states Start with k randomly generated states (population) A state is represented as a string over a finite alphabet (often a string of 0s and 1s) Evaluation function (fitness function). Higher values for better states. Produce the next generation of states by selection, crossover, and mutation

26 Genetic algorithms random mutation production of next generation
crossover point randomly generated random mutation production of next generation probability of a given pair selection proportional to the fitness (b) Fitness function: number of non-attacking pairs of queens (min = 0, max = 8 × 7/2 = 28  the higher the better) 24/( ) = 31% 23/( ) = 29% etc

27 Genetic algorithms

28 Lots of variants of genetic algorithms with different selection, crossover, and mutation rules.
GA have a wide application in optimization – e.g., circuit layout and job shop scheduling Much wirk remains to be done to formally understand GA’s and to identify the conditions under which they perform well.

29 Summary Local search algorithms Hill-climbing search Local beam search
Simulated annealing search Genetic algorithms

30 Local Search Summary Surprisingly efficient search technique
Wide range of applications Formal properties elusive Intuitive explanation: Search spaces are too large for systematic search anyway. . . Area will most likely continue to thrive


Download ppt "CS 4700: Foundations of Artificial Intelligence"

Similar presentations


Ads by Google