Informed Search
Informed Search
[These slides were created by Dan Klein and Pieter Abbeel for CS188 Intro to AI at UC Berkeley. All CS188 materials are available at http://ai.berkeley.edu.]
https://s2.studylib.net/store/data/005619980_1-7549df02baee639673f2ec513575f462.png
Search
heuristic
A heuristic is:
A function that estimates how
close a state is to a goal
Designed for a particular search
problem
Examples: Manhattan distance,
Euclidean distance for pathing
https://thesaurus.plus/img/antonyms/577/heuristic.png
Search
heuristics
10
5
11.2
Informed
search
Heuristic!
Greedy search
• Evaluation function h(n) (heuristic)
• h(n) estimates the cost from n to the
closest goal
• Example: hSLD(n) = straight-line
distance from n to Sault Ste Marie
• Greedy search expands the node that
appears to be closest to goal
Greedy search example
The initial state:
Greedy search example
After expanding St Louis:
Greedy search example
After expanding Chicago:
Greedy search example
After expanding Duluth:
Examples using the map
Start: Saint Louis
Goal: Sault Ste Marie
Greedy search
Examples using the map
Start: Las Vegas
Goal: Calgary
Greedy search
Example: Heuristic Function
h(x)
Greedy Search
Expand the node that seems closest…
(wrong) goal
Worst-case: like a badly-guided DFS
Properties of Gready Search
Video of Demo Contours Greedy (Empty)
Video of Demo Contours Greedy (Pacman Small Maze)
A* Search
UCS Greedy
A*
Combining UCS and Greedy
Uniform-cost orders by path cost, or backward cost g(n)
Greedy orders by goal proximity, or forward cost h(n)
8 g=0
S h=6
h=1 g=1
e a
1 h=5
1 3 2 g=2 g=9
S a d G
h=6 b d g=4 e h=1
h=6 h=5 h=2
1 h=2 h=0
1 g=3 g=6
c b g = 10
h=7 c G h=0 d
h=2
h=7 h=6
g = 12
G h=0
A* Search orders by the sum: f(n) = g(n) + h(n)
Example: Teg Grenager
F(n) is the estimated cost of the cheapest solution through n
A* search
• Minimize the total
estimated solution cost
• Combines:
- g(n): cost to reach node n
- h(n): cost to get from n to
the goal
- f(n) = g(n) + h(n)
A* search example
The initial state:
A* search example
After expanding St Louis:
A* search example
After expanding Chicago:
A* search example
After expanding Kansas City:
A* search example
After expanding Little Rock:
A* search example
After expanding Nashville:
A* search example
After expanding Pittsburgh:
A* search example
After expanding Toronto:
Examples using the map
Start: Saint Louis
Goal: Sault Ste Marie
A*
Example: Heuristic Function
h(x)
Examples using the map
Start: Las Vegas
Goal: Calgary
A*
When should A* terminate?
Should we stop when we enqueue a goal? h=2
2 A 2
S h=3 h=0 G
2 B 3
h=1
No: only stop when we dequeue a goal
Is A* Optimal? h=6
1 A 3
S h=7
G h=0
• Time: exponential
• Optimal: Yes!
Properties of A*
Uniform-Cost A*
b b
… …
UCS vs A* Contours