Heuristic Search (6 Page)
Heuristic Search (6 Page)
...we can use this knowledge of the relative merit of states to guide search Heuristics for 8-puzzle I
Heuristic Search (informed search) Current
1 2 3
State 4 5 6
A Heuristic is a function that, when applied to a state, returns a 7 8 11 22 33
number that is an estimate of the merit of the state, with respect to •The number of
misplaced tiles 44 55 66
the goal. 1 2 3
(not including Goal 77 8 8
In other words, the heuristic tells us approximately how far the state the blank) State 4 5 6
is from the goal state*. 7 8
N N N
Note we said “approximately”. Heuristics might underestimate or In this case, only “8” is misplaced, so the heuristic
function evaluates to 1. N N N
overestimate the merit of a state. But for reasons which we will see,
In other words, the heuristic is telling us, that it thinks a N Y
heuristics that only underestimate are very desirable, and are called solution might be available in just 1 more move.
admissible.
*I.e Smaller numbers are better Notation: h(n) h(current state) = 1
1
1 2 3 h(n) We have seen two interesting algorithms.
In this example, 4 5 8 6
hill climbing 6 7 Uniform Cost
does not work! • Measures the cost to each node.
• Is optimal and complete!
All the nodes • Can be very slow.
1 2 3 1 2 3
on the fringe
are taking a step 4 5 8 7 4 5 5 Hill Climbing
“backwards” 6 7 6 7 8 • Estimates how far away the goal is.
(local minima) • Is neither optimal nor complete.
• Can be very fast.
Note that this
puzzle is 1 2 3 1 2
Can we combine them to create an optimal and complete
solvable in just 4 5 6 4 5 3 6 algorithm that is also very fast?
12 more steps. 6 7 8 6 7 8
2
What is A*’s space complexity? A Worked Example: Maze Traversal
A* has worst case O(bd) space complexity, but an iterative Problem: To get from square A3 to
A
deepening version is possible ( IDA* ) square E2, one step at a time, avoiding
obstacles (black squares). B
C
Operators: (in order) D
•go_left(n)
E
•go_down(n)
•go_right(n) 1 2 3 4 5
each operator costs 1.
A3 A
A2
g(A2) = 1
B3
g(B3) = 1
A4
g(A4) = 1 B
h(A2) = 4 h(B3) = 4 h(A4) = 6
C
g(A1) = 2 D
A1 h(A1) = 5
E
g(C3) = 2 g(B4) = 2
C3 h(C3) = 3 B4 h(B4) = 5 1 2 3 4 5
g(B1) = 3
B1 h(B1) = 4
g(B5) = 3
B5 h(B5) = 6
Operators: (in order)
•go_left(n)
•go_down(n)
•go_right(n)
each operator costs 1.