4.module3 INFORMED SEARCH 3
4.module3 INFORMED SEARCH 3
4.module3 INFORMED SEARCH 3
Outline
• Best-first search
• Greedy best-first search
• A* search
• Heuristics
• Local search algorithms
• Hill-climbing search
• Simulated annealing search
• Local beam search
• Genetic algorithms
Best-first search
• Idea: use an evaluation function f(n) for each node
– estimate of "desirability"
Expand most desirable unexpanded node
In BFS and DFS, when we are at a node, we can consider any of the
adjacent as next node. So both BFS and DFS blindly explore paths without
considering any cost function. The idea of Best First Search is to use an
evaluation function to decide which adjacent is most promising and then
explore.
• Implementation:
Order the nodes in fringe in decreasing order of desirability
• Special cases:
– greedy best-first search
– A* search
Greedy best-first search
• Evaluation function f(n) = h(n) (heuristic)
• = estimate of cost from n to goal
• e.g., hSLD(n) = straight-line distance from n to
Bucharest
• Optimal? No
A* search
• Idea: avoid expanding paths that are already
expensive
• Evaluation function f(n) = g(n) + h(n)
• g(n) = cost so far to reach n
• h(n) = estimated cost from n to goal
• f(n) = estimated total cost of path through n to
goal
Working of A*
1. The algorithm maintains two sets
• OPEN list: The OPEN list keeps track of those nodes
that need to be examined.
• CLOSED list: The CLOSED list keeps track of nodes
that have already been examined.
2. Initially, the OPEN list contains just the
initial node, and the CLOSED list is empty
• g(n) = the cost of getting from the initial node to n
• h(n) = the estimate, according to the heuristic
function, of the cost from n to goal node
• f(n) = g(n)+h(n); intuitively, this is the estimate of the
best solution that goes through n
Working of A*
3. Each node also maintains a pointer to its parent, so that the
best solution if found can be retrieved.
– It has main loop that repeatedly gets the node, call it n with lowest f(n) value
from OPEN list.
– If n is goal node then stop (done) otherwise, n is removed from OPEN list &
added to the CLOSED list.
– Next all the possible successor nodes of n are generated.
– Similarly, if n is already in the OPEN list & the copy there has an equal or
lower f estimate, we can discard the newly generated n and move on.
A* search example
A* search example
A* search example
A* search example
A* search example
A* search example
Admissible heuristics
• A heuristic h(n) is admissible if for every node n,
h(n) ≤ h*(n), where h*(n) is the true cost to reach the goal state
from n.
• If h is consistent, we have
• Time? Exponential
• Optimal? Yes
Local Search
• They apply mostly to problems for which we don't need to know the
path to the solution but only the solution itself.
• They operate using a single state or a small number of states and
explore the neighbours of that state. They usually don't store the
path.
• A particular case are optimization problems for which we search for
the best solution according to an objective function.
• The distribution of values of the objective function in the state space
is called a landscape.
• Advantages
– Use very little memory
– Find reasonable solution in large or infinite(continuous) state spaces for which
systematic algorithms are unsuitable.
Local search algorithms
• In many optimization problems, the path to the goal is
irrelevant; the goal state itself is the solution
• Hill-climbing Search
• Simulation Annealing Search
• Genetic Algorithm
Example: n-queens
• 24/(24+23+20+11) = 31%