240 likes | 688 Views
Local Search Algorithms. CPS 4801. Outline. Hill-Climbing Search Simulated Annealing Local Beam Search (briefly ). Local search algorithms. In many optimization problems, the path to the goal is irrelevant; the goal state itself is the solution.
E N D
Local Search Algorithms CPS 4801
Outline • Hill-Climbing Search • Simulated Annealing • Local Beam Search (briefly)
Local search algorithms • In many optimization problems, the path to the goal is irrelevant; the goal state itself is the solution. • Find the final 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 • generally move to neighbors • The path are not retained
Local search algorithms • uses very little memory • useful for solving pure optimization problems • can often find reasonable solutions in large state spaces.
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 (steepest-ascent version) • A simple loop that continuously moves in the direction of increasing value – uphill • Terminates when reaches a “peak” • does not look ahead beyond the immediate neighbors, does not maintain a search tree
8-queens problem • Each state has 8*7 = 56 successors. complete-state formulation vs. incremental formulation
8-queens problem • h= number of pairs of queens that are attacking each other, either directly or indirectly (h=0 solution) • h = 17 for the above state
Hill-climbing search • “Greedy local search” • grabs a good neighbor state without thinking ahead about where to go next • makes rapid progress
Hill-climbing search: 8-queens problem • 5 steps from the state in the previous slide • A local minimum with h = 1
Hill-climbing search • Problem: depending on initial state, can get stuck in local maxima.
Hill-climbing search • Starting from a randomly generated 8-queen state, steepest-ascent hill climbing gets stuck 86% of the time. • It takes 4 steps on average when it succeeds and 3 when it gets stuck. • The steepest ascent version halts if the best successor has the same value as the current.
Hill-climbing search • allow a sideways move • shoulder • flat local maximum, that is not a shoulder • Solution: a limit on the number of consecutive sideway moves • E.g., 100 consecutive sideways movies in the 8-queens problem • successful rate: raises from14% to 94% • cost: 21 steps on average for each successful instance, 64 for each failure
Variants of hill climbing • Stochastic hill climbing • chooses at random from among the uphillmoves • converge more slowly, but finds better solutions • First-choice hill climbing • generates successors randomly until one is better than the current state • good when with many (thousands) of successors
Variants of hill climbing • Random-restart hill climbing • “If you don’t succeed, try, try again.” • conducts a series of hill-climbing searches from randomly generated initial states, until a goal is found.
Simulated Annealing • A hill-climbing algorithm that never makes “downhill” moves is guaranteed to be incomplete. • Idea: escape local maxima by allowing some “bad” moves
Simulated Annealing • Picks a random move (instead of the best) • If “good move” • accepted; • else • accepted with some probability • The probability decreases exponentially with the “badness” of the move
Simulated Annealing • Simulated annealing was first used extensively to solve VLSI (Very-Large-Scale Integration) layout problems. • It has been applied widely to factory scheduling and other large-scale optimization tasks.
Local Beam Search • Idea: keep k states instead of 1; choose top k of all their successors • Not the same as k searches run in parallel! • Searches that find good states recruit other searches to join them • moves the resources to where the most progress is being made
Local Beam Search • Problem: quite often, all k states end up on same local hill (concentrated in a small region) • Idea: choose k successors randomly(stochastic beam search)