Lecture - 17 - 21
Lecture - 17 - 21
Priority Queues:
• OPEN list: nodes that have been generated but have not examined.
• This is organized as a priority queue.
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
• Optimal? : No
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
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
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
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
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
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
10 9 8 7 6 5 4 3 2 1 B
11 1
13 6+11 5 3
14 13 5+12 10 9 8 7 6 4
4+13 11 5
10 9 8 7 6 5 4 3 2 1 B
11 1
13 6+11 5 3
14 13 5+12 10 9 8 7 6 4
4+13 11 5
10 9 8 7 6 5 4 3 2 1 B
11 1
13 6+11 5 3
14 13 5+12 10 9 8 7 6 4
4+13 11 5
10 9 8 7 6 5 4 3 2 1 B
11 1
13 6+11 5 3
14 13 5+12 10 9 8 7 6 4
4+13 11 5
10 9 8 7 6 5 4 3 2 1 B
11 1
13 6+11 5 3
14 13 5+12 10 9 8 7 6 4
4+13 11 5
10 9 8 7 6 5 4 3 2 1 B
11 1
13 6+11 14+5 3
14 13 5+12 10 9 8 7 6 4
4+13 11 5
10 9 8 7 6 5 4 3 2 1 B
11 1
13 6+11 14+5 3
14 6+13 5+12 10 9 8 7 6 4
4+13 11 5
10 9 8 7 6 5 4 3 2 1 B
11 1
13 6+11 14+5 3
4+13 11 5
10 9 8 7 6 5 4 3 2 1 B
11 1
13 6+11 14+5 3
4+13 11 5
10 9 8 7 6 5 4 3 2 1 B
11 1
4+13 11 5
10 9 8 7 6 5 4 3 2 1 B
11 1
4+13 11 5
10 9 8 7 6 5 4 3 2 1 B
10+11 1
4+13 11 5
11+10 9 8 7 6 5 4 3 2 1 B
10+11 1
4+13 11 5
11+10 12+9 8 7 6 5 4 3 2 1 B
10+11 1
4+13 11 5
4+13 11 5
4+13 11 5
4+13 11 5
4+13 11 5
4+13 11 5
4+13 11 5
4+13 11 5
11+10 12+9 13+8 14+7 15+6 16+5 17+4 18+3 19+2 20+1
B
10+11 1
4+13 11 5
• An admissible heuristic never overestimates the cost to reach the goal, i.e., it is optimistic.
• 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.
• 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