0% found this document useful (0 votes)
36 views33 pages

Local Search

The document discusses local search algorithms for optimization problems. It introduces hill climbing, a simple local search algorithm where the search starts at a random initial state and iteratively moves to neighbor states that improve the value of an objective function, until no further improvements can be made. The algorithm may get stuck at local optima rather than finding the global optimum. Variants like simulated annealing and tabu search are designed to avoid getting trapped at local optima. Hill climbing is applied as an example to problems like the n-queens puzzle and travelling salesman problem.

Uploaded by

Faizan Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views33 pages

Local Search

The document discusses local search algorithms for optimization problems. It introduces hill climbing, a simple local search algorithm where the search starts at a random initial state and iteratively moves to neighbor states that improve the value of an objective function, until no further improvements can be made. The algorithm may get stuck at local optima rather than finding the global optimum. Variants like simulated annealing and tabu search are designed to avoid getting trapped at local optima. Hill climbing is applied as an example to problems like the n-queens puzzle and travelling salesman problem.

Uploaded by

Faizan Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 33

Artificial Intelligence

CSAL3243

Modified slides of Dr Humayoun, S. Russell and P. Norvig


1
Local Search
Chapter 4
Local Search for optimization :
Hill climbing

2
Beyond A*, IDA*, …
• Systematic exploration so far: O(bd)
– Explore full search space (possibly) (A*, IDA*, … )

• Best such algorithms (IDA*, A*) can handle


– 10100 states ≈ 500 binary-valued variables

• but. . . some real-world problem have 10,000 to


100,000 variables ≈ 1030,000 states
• We need a completely different approach:
– Local Search Methods, …
3
Local Search Methods
• Applicable when seeking Goal State & don't care how to
get there. E.g.,
– N-queens,
– finding shortest/cheapest round trips
• (Travel Salesman Problem, Vehicle Routing Problem)
– finding models of propositional formulae (SAT solvers)
– VLSI layout, planning, scheduling, time-tabling, . . .
– map coloring,
– resource allocation
– protein structure prediction
– genome sequence assembly 4
Local Search Algorithms
• In many optimization problems, the path to the goal is
irrelevant; the goal state itself is the solution
• State space = set of configurations
– Find a configuration satisfying your constraints, e.g., n-
queens
– Find the best possible state according to a given
objective function
• In such cases, we can use local search algorithms
– Keeps a single "current" state, and then shift states, but
don’t keep track of paths.
– Use very limited memory
– Find reasonable solutions in large state spaces. 5
Local search
 Key idea (surprisingly simple):

1. Select (random) initial state


(generate an initial guess)

2. Make local modification to


improve current state
• Evaluate current state and move to
other states

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

Initial state … Improve it … using local transformations

Almost always solves n-queens problems instantaneously for very


large n, e.g., n = 1 million 7
Example: Travelling Salesman Problem
• Find the shortest Tour traversing all cities once.

8
Example: Travelling Salesman Problem
• A Solution: Exhaustive Search
– (Generate and Test) !!
• The number of all tours is
about (n-1)!/2

• If n = 36 the number is about:


• 566573983193072464833325
668761600000000

• Not Viable Approach !!


9
Example: Travelling Salesman Problem
Start with any complete tour, perform pairwise exchanges

Variants of this approach get within 1% of optimal very


quickly with thousands of cities

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"

• Hill climbing search algorithm (a.k.a greedy local search)


uses a loop that continually moves in the direction of
increasing values (that is uphill).

• It teminates when it reaches a peak where no neighbour


has a higher value.

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

• Random-restart Hill Climbing: Selects a series


of initial nodes randomly until the solution is
found.

• Some problem spaces are great for hill


climbing and others are terrible.

32
Questions

33

You might also like