InformedSearch 6pp
InformedSearch 6pp
1 2
3 4
• f(n) = h(n) 38
18
Straight line distance
Wilsonville
(as the crow flies) to
28 Wilsonville in miles
30
McMinnville
Corvallis 56
Salem Albany 49
46
Salem 28
Initial State 26
Portland 17
11 Albany McMinnville 18
Corvallis
5 6
1
Greedy Best-First Search Example Greedy Best-First Search Example
Corvallis Corvallis
56
18 49
Corvallis 56 Corvallis 56
Albany 49 Albany 49
Salem 28 Salem 28
Portland 17 Portland 17
McMinnville 18 McMinnville 18
7 8
Wilsonville
McMinnville Albany
28
49
McMinnville
30 But the route below
is much shorter than
Corvallis 56
Portland Corvallis Wilsonville Salem the route found by
17 56 0 Albany 49
46 26 Greedy Best-First
Salem 28 Initial State
Search!
Portland 17 11 Albany
McMinnville 18 Corvallis
Corvallis →McMinnville→ Wilsonville = 74 miles
Corvallis →Albany→ Salem → Wilsonville = 67 miles
Complete? No (could start down an infinite Complete? No (could start down an infinite
path) path)
Optimal? Optimal? No
2
Evaluating Greedy Best-First Search Evaluating Greedy Best-First Search
Complete? No (could start down an infinite Complete? No (could start down an infinite
path) path)
Optimal? No Optimal? No
Greedy Best-First search results in lots of dead ends which Greedy Best-First search results in lots of dead ends which
leads to unnecessary nodes being expanded leads to unnecessary nodes being expanded
13 14
3
A* Search Example A* Search Example
Corvallis Corvallis
11 46 11
46
Portland Corvallis Wilsonville Salem Corvallis Portland Corvallis Wilsonville Salem Corvallis
84+17=101 92+56=148 74+0=74 37+28=65 22+56=78 84+17=101 92+56=148 74+0=74 22+56=78
30 26
Wilsonville Albany
Note: Don’t stop when you put a goal state on the priority 67+0=67 63+49=112
queue (otherwise you get a suboptimal solution)
Proper termination: Stop when you pop a goal state from the
21
priority queue
4
Consistency Consistency
• A heuristic is consistent if, for every node n and every • Every consistent heuristic is also admissible
successor n’ of n generated by any action a:
h(n) ≤ c(n,a,n’) + h(n’)
• A* using GRAPH-SEARCH is optimal if
h(n) is consistent
Step cost of going from n to n’
by doing action a • Most admissible heuristics are also
• A form of the triangle inequality – each side of the triangle
cannot be longer than the sum of the two sides consistent
n’ n’ h(n’)=1 n’ h(n’)=1
c(n,a,n’) h(n’) c(n,a,n’)=2 c(n,a,n’)=2
n G n n
G G
h(n)
h(n)=2 h(n)=4
26
CONSISTENT INCONSISTENT
29 30
5
Summary of A* Search Summary of A* Search
Complete? Yes if h(n) is consistent, b is finite, and Complete? Yes if h(n) is consistent, b is finite, and
all step costs exceed some finite 1 all step costs exceed some finite 1
Optimal? Optimal? Yes if h(n) is consistent and admissible
1 Since f(n) is nondecreasing, we must eventually hit an f(n) = cost of the path to a 1 Since f(n) is nondecreasing, we must eventually hit an f(n) = cost of the path to a
goal state goal state
Time Complexity O(bd) (In the worst case but a good Time Complexity O(bd) (In the worst case but a good
heuristic can reduce this significantly) heuristic can reduce this significantly)
Space Complexity Space Complexity O(bd) – Needs O(number of states), will
run out of memory for large search
spaces
1 Since f(n) is nondecreasing, we must eventually hit an f(n) = cost of the path to a 1 Since f(n) is nondecreasing, we must eventually hit an f(n) = cost of the path to a
goal state goal state
6
Examples of heuristic functions Which heuristic is better?
The 8-puzzle • h2 dominates h1. That is, for any node n, h2(n) ≥ h1(n).
• h2 never expands more nodes than A* using h1 (except
possibly for some nodes with f(n) = C*)
7 2 4 1 2
Proof:
From Russell and Norvig Figure 4.8 (Results averaged over 100
instances of the 8-puzzle for depths 2-24). 40