0% found this document useful (0 votes)
72 views3 pages

Heuristic Search (6 Page)

1. Heuristic search techniques use heuristics, or estimates of how close a state is to the goal, to guide the search for a solution more efficiently than uninformed searches. 2. Two examples of heuristics for the 8-puzzle problem are counting the number of misplaced tiles and calculating the Manhattan distance of misplaced tiles. 3. Heuristics can help techniques like hill climbing search quickly find solutions, but hill climbing is not guaranteed to find the optimal solution.

Uploaded by

Scout St
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views3 pages

Heuristic Search (6 Page)

1. Heuristic search techniques use heuristics, or estimates of how close a state is to the goal, to guide the search for a solution more efficiently than uninformed searches. 2. Two examples of heuristics for the 8-puzzle problem are counting the number of misplaced tiles and calculating the Manhattan distance of misplaced tiles. 3. Heuristics can help techniques like hill climbing search quickly find solutions, but hill climbing is not guaranteed to find the optimal solution.

Uploaded by

Scout St
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Sometimes we can tell that some states

Heuristic Search appear better that others...


The search techniques we have seen so far...
7 8 4 1 2 3
• Breadth first search 3 5 1 4 5 6
• Uniform cost search 6 2 7 8
• Depth first search uninformed search
• Depth limited search blind search
FWD D
• Iterative Deepening C FW C
• Bi-directional Search

...are all too slow for most real world problems

...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

Heuristics for 8-puzzle II 1


4
2
8
3
5
h(n)
7 6 5

3 2 8 3 3 We can use heuristics 1 2 1 2 3


Current to guide “hill climbing”
State 4 5 6 2 spaces 4 8 3 6 4 8 5 4
search. 7 6 5 7 6
7 1
•The Manhattan 1 2 3
Distance (not 8 In this example, the 4 8 5 3
including the 1 2 3 Manhattan Distance 7 6

blank) Goal 3 spaces


State 4 5 6 heuristic helps us 1 2 3 1 2 3
8 quickly find a solution
7 8 4 8 5 4 4 5 2
to the 8-puzzle. 7 6 7 8 6
1
In this case, only the “3”, “8” and “1” tiles are 1 2 3 1 2 3 1 3
misplaced, by 2, 3, and 3 squares respectively, so 3 spaces 4 5 1 4 5 3 4 2 5 3
the heuristic function evaluates to 8. 1 7 8 6 7 8 6 7 8 6
In other words, the heuristic is telling us, that it thinks a
solution is available in just 8 more moves. Total 8 1 2 3 1 2
But “hill climbing has 0
4 5 6 4 5 3
2
Notation: h(n) h(current state) = 8 a problem...” 7 8 7 8 6

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

Uniform Cost Search The A* Algorithm (“A-Star”)


Enqueue nodes in order of cost

Enqueue nodes in order of estimate cost to goal, f(n)


5 2 5 2 5 2
g(n) is the cost to get to a node.
1 7 1 7 h(n) is the estimated distance to the goal.

Intuition: Expand the cheapest node. Where 4 5


f(n) = g(n) + h(n)
the cost is the path cost g(n)

Hill Climbing Search


We can think of f(n) as the estimated cost of the cheapest solution that goes through node n

Enqueue nodes in order of estimated distance to goal


Note that we can use the general search algorithm we used before.
17 19 17 19 17 19 All that we have changed is the queuing strategy.

16 14 16 14 If the heuristic is optimistic, that is to say, it never overestimates


13 15 the distance to the goal, then…
Intuition: Expand the node you think is nearest to
goal. Where the estimate of distance to goal is h(n)
A* is optimal and complete!

Informal proof outline of A* completeness


• Assume that every operator has some minimum positive cost,
How fast is A*?
epsilon . A* is the fastest search algorithm. That is, for any given
• Assume that a goal state exists, therefore some finite set of heuristic, no algorithm can expand fewer nodes than A*.
operators lead to it.
•Expanding nodes produces paths whose actual costs increase by How fast is it? Depends of the quality of the heuristic.
at least epsilon each time. Since the algorithm will not terminate
until it finds a goal state, it must expand a goal state in finite time. •If the heuristic is useless (ie h(n) is hardcoded to equal 0 ), the
algorithm degenerates to uniform cost.
Informal proof outline of A* optimality
• When A* terminates, it has found a goal state •If the heuristic is perfect, there is no real search, we just
• All remaining nodes have an estimate cost to goal (f(n)) greater march down the tree to the goal.
than or equal to that of goal we have found.
•Since the heuristic function was optimistic, the actual cost to goal Generally we are somewhere in between the two situations
for these other paths can be no better than the cost of the one we above. The time taken depends on the quality of the heuristic.
have already found.

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.

Heuristic: Manhattan distance

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.

You might also like