Local Search
Local Search
CSAL3243
2
Beyond A*, IDA*, …
• Systematic exploration so far: O(bd)
– Explore full search space (possibly) (A*, IDA*, … )
Neighborhoods
3. Repeat Step 2 until goal state
found (or out of time) 6
Example: n-queens
Put N Queens on an n × n board with no two queens on
the same row, column, or diagonal
Move a queen to reduce number of conflicts
8
Example: Travelling Salesman Problem
• A Solution: Exhaustive Search
– (Generate and Test) !!
• The number of all tours is
about (n-1)!/2
10
Local Search Algorithms
Hill Climbing,
Simulated Annealing,
Tabu Search
• These are called “anytime algorithms”.
• They can return a valid solution even if they are
interrupted at any time before they properly terminate
Hill Climbing
"Like climbing Everest in thick fog with amnesia"
12
Hill-Climbing Algorithm
1. Pick a random point in the search space
2. Consider all the neighbours of the current state
3. Choose the neighbour with the best quality and
move to that state
4. Repeat 2 to 4 until all the neighboring states are
of lower quality
5. Return the current state as the solution state.
13
State Space Landscape
A state space landscape is a graph of states associated with
their costs
14
Hill Climbing
evaluation
states
15
Neighbourhood
• The neighbourhood defines a set of potential
successor states
• Often defined by the an operator that moves from
one solution to another
• The larger the neighbourhood, the better the
chance we will see a global optimum
– . . . but the longer it will take to search it
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Hill-Climbing – Two Versions
• Greedy Local Search
– Systematically search the Neighbourhood.
– Accept the {first or best} cost decreasing move found.
• Stochastic Local Search
– Choose randomly from amongst the cost-decreasing
moves found.
30
Hill-Climbing Problems
• Greedy Local Search: grabs a good neighbour state
without thinking about where to go next
– However, greedy algos do make good progress generally
towards the solution
• Unfortunately, hill-climbing
– Can get stuck in local maxima
– Can be stuck by ridges (a series of local maxima that occur
close together)
– Can be stuck by plateaux (a flat area in the state space
landscape)
• Shoulder: if the flat area rises uphill later on
• Flat local maximum: no uphill rise exists. 31
Improvements
32
Questions
33