Artificial Intelligence
CS-340
Local Search - I
Mr. Mustajab Hussain
mustajab@aack.au.edu.pk
1
Local search algorithms
• In the problems we studied so far, the solution is the path. For
example, the solution to the 8-puzzle is a series of movements for
the “blank tile.” The solution to the traveling in Romania problem is
a sequence of cities to get to Bucharest.
• In many optimization problems, the path to goal state is irrelevant,
the goal state itself is the solution.
• State space = set of "complete" configurations
• Find configuration satisfying constraints, e.g., n-queens, job
scheduling, optimization problems
• In such cases, we can use local search algorithms.
• Keep a single "current" state, try to improve it
2
Local search algorithms
• Local Search Algorithms keep a single "current" state, and
move to neighboring states in order to try improve it.
• Solution path needs not be maintained.
• Hence, the search is “local”.
• Local search suitable for problems in which path is not
important; the goal state itself is the solution.
• It is an optimization search
3
Example: n-queens
• Put n queens on a n × n board with no two queens on the
same row, column, or diagonal.
• In the 8-queens problem, what matters is the final
configuration of queens, not the order in which they are
added.
4
Local search algorithms
• Advantages:
• Usually uses constant additional memory
• Useful in large and infinite state spaces
• “Pure optimization” problems
• All states have an objective function
• Goal is to find state with max (or min) objective value
• Some problems do not quite fit into path-cost/goal-state formulation
e.g. nature provides reproductive fitness, Darwin evolution seems to
optimize it.
• Local search can do quite well on these problems.
5
Local search algorithms
• Terminate on a time bound or if the situation is not improved after
number of steps.
• Local search algorithms are typically incomplete algorithms, as the
search may stop even if the best solution found by the algorithm is
not optimal.
6
Types of local search algorithms
• Hill climbing search.
• Simulated annealing.
• Local beam search
• Genetic algorithm.
7
Hill-Climbing Search
• Main Idea: Keep a single current node and move to a
neighboring state to improve it.
• Uses a loop that continuously moves in the direction of
increasing value (uphill)
• Choose the best successor, choose randomly if there is more
than one.
• Terminate when a peak reached where no neighbor has a
higher value.
• It also called greedy local search, steepest ascent/descent.
8
Hill-Climbing Search
• Like climbing Everest in a thick fog.
• “a loop that continuously moves in the direction of increasing
value”
• terminates when a peak is reached
• Aka greedy local search
9
Hill climbing search algorithm
10
Hill climbing search variations
Stochastic hill-climbing
• Random selection among the uphill moves.
• The selection probability can vary with the steepness of the uphill move.
• This usually converges slowly than steepest ascent.
• Incomplete
First-choice hill-climbing
• Stochastic hill climbing by generating successors randomly until a better one is found
• Useful when there are a very large number of successors
• Incomplete
Random-restart hill-climbing
• Hill Climbing from randomly generated initial states
• Tries to avoid getting stuck in local maxima.
• Complete 11
Drawbacks of Hill-Climbing Search
• Local maxima: Peak higher than
neighboring states but lower than
global maxima.
• Ridge: sequence of local maxima
that is difficult to navigate.
• Plateau: flat area of the state
space landscape
12
The End
13