21
Local Search Algorithms CPS 4801

Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

Embed Size (px)

Citation preview

Page 1: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

Local Search Algorithms

CPS 4801

Page 2: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

Outline• Hill-Climbing Search• Simulated Annealing • Local Beam Search (briefly)

Page 3: 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 ito generally move to neighborso The path are not retained

Page 4: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

Local search algorithms

• uses very little memory• useful for solving pure optimization

problems• can often find reasonable solutions in large

state spaces.

Page 5: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

Example: n-queens• Put n queens on an n × n board with no

two queens on the same row, column, or diagonal

Page 6: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

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

Page 7: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

8-queens problem

• Each state has 8*7 = 56 successors.

complete-state formulationvs.incremental formulation

Page 8: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

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

Page 9: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

Hill-climbing search• “Greedy local search”

o grabs a good neighbor state without thinking ahead about where to go next

• makes rapid progress

Page 10: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

Hill-climbing search: 8-queens problem

• 5 steps from the state in the previous slide• A local minimum with h = 1

Page 11: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

Hill-climbing search• Problem: depending on initial state, can

get stuck in local maxima.

Page 12: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

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.

Page 13: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

Hill-climbing search• allow a sideways move

o shouldero flat local maximum, that is not a shoulder

• Solution: a limit on the number of consecutive sideway moves o E.g., 100 consecutive sideways movies in the

8-queens problemo successful rate: raises from14% to 94%o cost: 21 steps on average for each successful

instance, 64 for each failure

Page 14: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

Variants of hill climbing

• Stochastic hill climbingo chooses at random from among the uphill

moveso converge more slowly, but finds better

solutions

• First-choice hill climbingo generates successors randomly until one is

better than the current stateo good when with many (thousands) of

successors

Page 15: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

Variants of hill climbing

• Random-restart hill climbingo “If you don’t succeed, try, try again.”o conducts a series of hill-climbing searches from

randomly generated initial states, until a goal is found.

Page 16: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

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

Page 17: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

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

Page 18: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

Simulated Annealing

Page 19: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

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.

Page 20: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

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 themo moves the resources to where the most

progress is being made

Page 21: Local Search Algorithms CPS 4801. Outline Hill-Climbing Search Simulated Annealing Local Beam Search (briefly)

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)