0% found this document useful (0 votes)
63 views107 pages

Lecture - 17 - 21

Best First Search is an informed search algorithm that prioritizes nodes based on an evaluation function. It uses a priority queue to store nodes and selects the most promising node first based on the evaluation function. The evaluation function considers both the cost to reach a node and an estimate of remaining cost to the goal. Greedy Best First Search is a variant that only considers the heuristic estimate of remaining cost.

Uploaded by

spandansahil15
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)
63 views107 pages

Lecture - 17 - 21

Best First Search is an informed search algorithm that prioritizes nodes based on an evaluation function. It uses a priority queue to store nodes and selects the most promising node first based on the evaluation function. The evaluation function considers both the cost to reach a node and an estimate of remaining cost to the goal. Greedy Best First Search is a variant that only considers the heuristic estimate of remaining cost.

Uploaded by

spandansahil15
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/ 107

Best First Search

Dr. Ashish Kumar


Associate Professor-CSE
Manipal University Jaipur
Best First Search
• Best-First Search is typically used in scenarios where you have a search space or a graph, and you need
to find the optimal path or solution from a start state to a goal state.
• The best first search uses the concept of a priority queue and heuristic search/information.
• The key to Best-First Search is the use of an evaluation function, often denoted as 'f(n)', where 'n' is a
node or state in the search space. This function estimates the desirability or quality of a node with
respect to the goal.
• The goal is to minimize or maximize this function, depending on the nature of the problem.
• The evaluation function guides the search algorithm to prioritize nodes that seem most promising
based on the evaluation criteria.
• To implement Best-First Search, you maintain a priority queue (sometimes called an open list) to store
the nodes or states that need to be explored.
• Nodes are inserted into the priority queue based on their evaluation function values.
• It considers both the cost to reach a node and an estimate of the remaining cost to the goal ('f(n)’).
Best First Search
• Depth-first search: not all competing branches having to be expanded.
• Breadth-first search: not getting trapped on dead-end paths.
• Combining the two is to follow a single path at a time, but switch paths whenever some competing path
look more promising than the current one.

Priority Queues:
• OPEN list: nodes that have been generated but have not examined.
• This is organized as a priority queue.

• CLOSED list: nodes that have already been examined.


• Whenever a new node is generated, check whether it has been generated before.
Best First Search - Algo
Algorithm:
1. Create 2 empty lists: OPEN and CLOSED
2. Start from the initial node (say N) and put it in the ‘ordered’ OPEN list
3. Repeat the next steps until the GOAL node is reached:
1. If the OPEN list is empty, then EXIT the loop returning ‘False’
2. Select the first/top node (say N) in the OPEN list and move it to the CLOSED list. Also, capture the
information of the parent node
3. If N is a GOAL node, then move the node to the Closed list and exit the loop returning ‘True’. The
solution can be found by backtracking the path
4. If N is not the GOAL node, expand node N to generate the ‘immediate’ next nodes linked to node N
and add all those to the OPEN list
5. Reorder the nodes in the OPEN list in ascending order according to an evaluation function f(n)
Best First Search - Pros & Cons
Advantages:
• It is efficient in finding the shortest path from a starting node to a goal node.
• It can handle large graphs (state spaces) efficiently due to its use of a priority queue.
• It can be easily implemented using various programming languages.
• Allows customization through the choice of the evaluation function.
Disadvantages:
• Can be misled by the evaluation function if it does not accurately represent the problem's
characteristics.
• May not guarantee finding the optimal solution in all cases.

Special Cases (Variants) of BFS:


• Greedy best-first search
• A*search
Greedy Best First Search
• Greedy Best-First Search is a variant of the Best-First Search algorithm used in artificial intelligence and
search problems.
• It is a heuristic search algorithm that prioritizes expanding nodes in a way that seems most promising
based solely on a heuristic evaluation function.
• Evaluation function f(n) = h(n) (heuristic function) = estimate of cost from node (n) to goal
• e.g., hSLD(n) = straight-line distance from city (n) to Bucharest
• Greedy best-first search expands the node that appears to be closest to goal.
• Unlike the evaluation function in the standard Best-First Search, which considers both the cost to reach
a node and an estimate of the remaining cost to the goal ('f(n)'), the Greedy Best-First Search algorithm
only considers the heuristic value ('h(n)').
• The heuristic function is problem-specific and aims to provide a quick estimate of how close a node is to
the goal.
• Like Best-First Search, Greedy Best-First Search maintains a priority queue (open list) for nodes that need to be explored.
Nodes are inserted into the priority queue based solely on their heuristic values ('h(n)').
Greedy Best First Search
• Greedy Best-First Search is "greedy" because it makes decisions solely based on the current estimate of
how close each node is to the goal. It doesn't consider the cost to reach a node from the start state.
• This algorithm is often used when you want to quickly find a solution without necessarily guaranteeing
the optimality of the solution. It tends to prioritize nodes that appear to be closer to the goal based on
the heuristic.
Advantages:
• Can be very efficient in finding a solution, especially in situations where a good heuristic is available.
• Well-suited for problems where you need a quick, reasonably good solution.
Disadvantages:
• Does not guarantee finding the optimal solution, as it may prioritize paths that lead to dead ends or
high-cost solutions if the heuristic is not well-designed.
• Highly dependent on the quality of the heuristic function.
Greedy Best First Search – Example 1
Greedy Best First Search – Example 1
Greedy Best First Search – Example 1
Romania with step costs in km [g(n)] Heuristic Info [h(n)]

G
Greedy Best First Search – Example 1

Solution Route:
Arad  Sibiu  Fagarus  Bucharest
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 2
Greedy Best First Search – Example 3
MAZE Problem
Heuristic function? Manhattan distance.

A
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

11 9 7 3 2 B
12 10 8 7 6 4 1

13 12 11 9 7 6 5 2

13 10 8 6 3

14 13 12 11 9 7 6 5 4

13 10

A 16 15 14 11 10 9 8 7 6
Greedy Best-First Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 10 9 8 7 6 5 4 2

13 11 5 3

14 13 12 10 9 8 7 6 4

13 11 5

A 16 15 14 12 11 10 9 8 7 6
Greedy Best-First Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 10 9 8 7 6 5 4 2

13 11 5 3

14 13 12 10 9 8 7 6 4

13 11 5

A 16 15 14 12 11 10 9 8 7 6
Greedy Best-First Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 10 9 8 7 6 5 4 2

13 11 5 3

14 13 12 10 9 8 7 6 4

13 11 5

A 16 15 14 12 11 10 9 8 7 6
Evaluation of Greedy Best First Search
• Complete? : No B’coz, can get stuck in loops. e.g.: Iasi  Neamt  Iasi  Neamt 

• Time? : O(bm) but a good heuristic can give dramatic improvement

• Space? : O(bm) In any case, keeps all nodes in memory

• Optimal? : No

b:maximum branching factor of the search tree


d: depth of the least-cost solution
m: maximum depth of the state space (may be ∞)
A* Search
• A* Search is a widely used and highly effective search algorithm in the field of artificial intelligence and
computer science.
• It is a heuristic search algorithm designed for finding the shortest path or optimal solution from a start
state to a goal state within a search space or graph.
• It combines the advantages of both Dijkstra's algorithm and Greedy Best-First Search by considering
both the cost to reach a node and an estimate of the remaining cost to the goal.
• It is a graph search algorithm that evaluates nodes by a function f(n), which combines a new term, g(n),
or the cost to reach the node, and h(n), the cost to get from the node to the goal.
• Idea: avoid expanding paths that are already expensive.
• The key to A* Search is its evaluation function, denoted as f(n), which combines the cost function and
the heuristic function: f(n) = g(n) + h(n)
• The evaluation function f(n) represents the estimated total cost from the start node to the goal node
passing through node n.
A* Search - Algo
• Similar to Best-First Search and Greedy Best-First Search, A* Search maintains a priority queue (often
called an open list) to store nodes that need to be explored. Nodes are inserted into the priority queue
based on their evaluation function values f(n).
Algorithm:
1. Initialize the priority queue with the start state and set 'g(start)' to 0.
2. While the priority queue is not empty:
1. Dequeue the node with the lowest 'f(n)' value.
2. If this node is the goal state, terminate the search, and you have found the optimal solution.
3. Otherwise, expand the node by generating its successor states.
4. For each successor, calculate 'g(successor)' as the cost to reach the successor from the start state.
5. Calculate 'h(successor)' using the heuristic function.
6. Update 'f(successor) = g(successor) + h(successor)'.
7. Enqueue the successors into the priority queue based on their 'f(n)' values.
3. If the priority queue becomes empty and the goal state is not reached, the search fails, indicating that there is no path to
the goal.
A* Search – Pros & Cons
Advantages:
• Can efficiently find the optimal solution in a wide range of problems.
• Provides a balance between completeness and efficiency.
Disadvantages:
• The quality of the heuristic function is crucial; an inaccurate heuristic may lead to suboptimal
solutions.
• Can be memory-intensive for large search spaces.
A* Search – Example 1
Romania with step costs in km [g(n)] Heuristic Info [h(n)]

G
A* Search – Example 1

Solution Route:
Arad  Sibiu  Rimnicu Vilcea  Pitesti  Bucharest
A* Search – Example 2
MAZE Problem
A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 10 9 8 7 6 5 4 2

13 11 5 3

14 13 12 10 9 8 7 6 4

13 11 5

A 16 15 14 12 11 10 9 8 7 6
A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 10 9 8 7 6 5 4 2

13 11 5 3

14 13 12 10 9 8 7 6 4

13 11 5

A 1+16 15 14 12 11 10 9 8 7 6
A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 10 9 8 7 6 5 4 2

13 11 5 3

14 13 12 10 9 8 7 6 4

13 11 5

A 1+16 2+15 14 12 11 10 9 8 7 6
A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 10 9 8 7 6 5 4 2

13 11 5 3

14 13 12 10 9 8 7 6 4

13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 10 9 8 7 6 5 4 2

13 11 5 3

14 13 12 10 9 8 7 6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 10 9 8 7 6 5 4 2

13 11 5 3

14 13 5+12 10 9 8 7 6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 10 9 8 7 6 5 4 2

13 6+11 5 3

14 13 5+12 10 9 8 7 6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 7+10 9 8 7 6 5 4 2

13 6+11 5 3

14 13 5+12 10 9 8 7 6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 7+10 8+9 8 7 6 5 4 2

13 6+11 5 3

14 13 5+12 10 9 8 7 6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 7+10 8+9 9+8 7 6 5 4 2

13 6+11 5 3

14 13 5+12 10 9 8 7 6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 7+10 8+9 9+8 10+7 6 5 4 2

13 6+11 5 3

14 13 5+12 10 9 8 7 6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 7+10 8+9 9+8 10+7 11+6 5 4 2

13 6+11 5 3

14 13 5+12 10 9 8 7 6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 7+10 8+9 9+8 10+7 11+6 12+5 4 2

13 6+11 5 3

14 13 5+12 10 9 8 7 6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 7+10 8+9 9+8 10+7 11+6 12+5 13+4 2

13 6+11 5 3

14 13 5+12 10 9 8 7 6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 7+10 8+9 9+8 10+7 11+6 12+5 13+4 2

13 6+11 14+5 3

14 13 5+12 10 9 8 7 6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 7+10 8+9 9+8 10+7 11+6 12+5 13+4 2

13 6+11 14+5 3

14 6+13 5+12 10 9 8 7 6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 7+10 8+9 9+8 10+7 11+6 12+5 13+4 2

13 6+11 14+5 3

14 6+13 5+12 10 9 8 7 15+6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 7+10 8+9 9+8 10+7 11+6 12+5 13+4 2

13 6+11 14+5 3

7+14 6+13 5+12 10 9 8 7 15+6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

12 7+10 8+9 9+8 10+7 11+6 12+5 13+4 2

8+13 6+11 14+5 3

7+14 6+13 5+12 10 9 8 7 15+6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

10 9 8 7 6 5 4 3 2 1 B
11 1

9+12 7+10 8+9 9+8 10+7 11+6 12+5 13+4 2

8+13 6+11 14+5 3

7+14 6+13 5+12 10 9 8 7 15+6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

10 9 8 7 6 5 4 3 2 1 B
10+11 1

9+12 7+10 8+9 9+8 10+7 11+6 12+5 13+4 2

8+13 6+11 14+5 3

7+14 6+13 5+12 10 9 8 7 15+6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

11+10 9 8 7 6 5 4 3 2 1 B
10+11 1

9+12 7+10 8+9 9+8 10+7 11+6 12+5 13+4 2

8+13 6+11 14+5 3

7+14 6+13 5+12 10 9 8 7 15+6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

11+10 12+9 8 7 6 5 4 3 2 1 B
10+11 1

9+12 7+10 8+9 9+8 10+7 11+6 12+5 13+4 2

8+13 6+11 14+5 3

7+14 6+13 5+12 10 9 8 7 15+6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

11+10 12+9 13+8 7 6 5 4 3 2 1 B


10+11 1

9+12 7+10 8+9 9+8 10+7 11+6 12+5 13+4 2

8+13 6+11 14+5 3

7+14 6+13 5+12 10 9 8 7 15+6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

11+10 12+9 13+8 14+7 6 5 4 3 2 1 B


10+11 1

9+12 7+10 8+9 9+8 10+7 11+6 12+5 13+4 2

8+13 6+11 14+5 3

7+14 6+13 5+12 10 9 8 7 15+6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

11+10 12+9 13+8 14+7 15+6 5 4 3 2 1 B


10+11 1

9+12 7+10 8+9 9+8 10+7 11+6 12+5 13+4 2

8+13 6+11 14+5 3

7+14 6+13 5+12 10 9 8 7 15+6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

11+10 12+9 13+8 14+7 15+6 16+5 4 3 2 1 B


10+11 1

9+12 7+10 8+9 9+8 10+7 11+6 12+5 13+4 2

8+13 6+11 14+5 3

7+14 6+13 5+12 10 9 8 7 15+6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

11+10 12+9 13+8 14+7 15+6 16+5 17+4 3 2 1 B


10+11 1

9+12 7+10 8+9 9+8 10+7 11+6 12+5 13+4 2

8+13 6+11 14+5 3

7+14 6+13 5+12 10 9 8 7 15+6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

11+10 12+9 13+8 14+7 15+6 16+5 17+4 18+3 2 1 B


10+11 1

9+12 7+10 8+9 9+8 10+7 11+6 12+5 13+4 2

8+13 6+11 14+5 3

7+14 6+13 5+12 10 9 8 7 15+6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

11+10 12+9 13+8 14+7 15+6 16+5 17+4 18+3 19+2 1 B


10+11 1

9+12 7+10 8+9 9+8 10+7 11+6 12+5 13+4 2

8+13 6+11 14+5 3

7+14 6+13 5+12 10 9 8 7 15+6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


A* Search

11+10 12+9 13+8 14+7 15+6 16+5 17+4 18+3 19+2 20+1
B
10+11 1

9+12 7+10 8+9 9+8 10+7 11+6 12+5 13+4 2

8+13 6+11 14+5 3

7+14 6+13 5+12 10 9 8 7 15+6 4

4+13 11 5

A 1+16 2+15 3+14 12 11 10 9 8 7 6


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.

• An admissible heuristic never overestimates the cost to reach the goal, i.e., it is optimistic.

• Example: hSLD(n) (never overestimates the actual road distance)

• Theorem: If h(n) is admissible, A* using TREE-SEARCH is optimal.

• However, in GRAPH-SEARCH to prove optimality, the admissible is not sufficient.


Consistent heuristics
• A heuristic is consistent if for every node n, every successor n' of n generated by any action a,
• h(n) ≤ c(n,a,n') + h(n’)

• Intuition: can’t do worse than going through n’.

• If h is consistent, we have
• f(n') = g(n') + h(n') = g(n) + c(n,a,n') + h(n')
• ≥ g(n) + h(n) = f(n)
• i.e., f(n) is non-decreasing along any path.

• Theorem: If h(n) is consistent, A* using GRAPH-SEARCH is optimal.


A* Search – Evaluation
• A* generates an optimal solution if h(n) is an admissible heuristic and the search space is a tree:
• h(n) is admissible if it never overestimates the cost to reach the destination node

• A* generates an optimal solution if h(n) is a consistent heuristic and the search space is a graph:
• h(n) is consistent if for every node n and for every successor node n’ of n: h(n) ≤ c(n,n’) + h(n’)

• If h(n) is consistent then h(n) is admissible. And frequently when h(n) is admissible, it is also
consistent.
A* Search – Evaluation
Criteria Evaluation
Completeness Guaranteed to find a solution if one exists, given the search space is finite and the
heuristic is admissible.
Optimality Guaranteed to find the optimal solution when an admissible/consistent heuristic
is used depends upon tree/graph state space.
Exponential in the worst case i.e., O(bd), but often performs well in practice due to
Time Complexity the heuristic. The time complexity depends on factors like the quality of the
heuristic, branching factor, and depth of the optimal solution.
Can be memory-intensive due to the need to maintain a priority queue. The space
Space Complexity complexity (i.e., O(bd)) depends on the size of the search space and the number of
explored nodes.
“Thank you for being such an
engaged audience during my
presentation.”
- Dr. Ashish Kumar

You might also like