Escolar Documentos
Profissional Documentos
Cultura Documentos
A* Search
UCS Greedy
A*
Combining UCS and Greedy
o Uniform-cost orders by path cost, or backward cost g(n)
o Greedy orders by goal proximity, or forward cost h(n)
8 g=0
S h=6
h=1 g=1
e
1 h=5 a
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
o A* Search orders by the sum: f(n) = g(n) + h(n)
Example: Teg
When should A* terminate?
1 A 3
gh+
S 077
S h=7
G h=0 S->A 1 6 7
S->G 505
5
o Examples:
0.0
15 11.5
Claim:
o A will exit the fringe before B
Optimality of A* Tree Search: Blocking
Proof:
…
o Imagine B is on the fringe
o Some ancestor n of A is on the
fringe, too (maybe A!)
o Claim: n will be expanded
before B
1. f(n) is less or equal to f(A)
Definition of f-cost
Admissibility of h
h = 0 at a goal
Optimality of A* Tree Search: Blocking
Proof:
…
o Imagine B is on the fringe
o Some ancestor n of A is on the
fringe, too (maybe A!)
o Claim: n will be expanded
before B
1. f(n) is less or equal to f(A)
2. f(A) is less than f(B)
B is suboptimal
h = 0 at a goal
Optimality of A* Tree Search: Blocking
Proof:
…
o Imagine B is on the fringe
o Some ancestor n of A is on the
fringe, too (maybe A!)
o Claim: n will be expanded before B
1. f(n) is less or equal to f(A)
2. f(A) is less than f(B)
3. n expands before B
o All ancestors of A expand before B
o A expands before B
o A* search is optimal
Properties of A*
Properties of A*
Uniform-Cost A*
b b
… …
UCS vs A* Contours
366
15
o Why is it admissible?
Average nodes expanded
o h(start) = 3 + 1 + 2 + … = 18 when the optimal path has…
…4 steps …8 steps …12 steps
TILES 13 39 227
MANHATTAN 12 25 73
8 Puzzle III
o How about using the actual cost as a heuristic?
o Would it be admissible?
o Would we save on nodes expanded?
o What’s wrong with it?
o With A*: a trade-off between quality of estimate and work per node
o As heuristics get closer to the true cost, you will expand fewer nodes but
usually do more work per node to compute the heuristic itself
Graph Search
Tree Search: Extra Work!
o Failure to detect repeated states can cause exponentially more
work.
State Graph Search Tree
Graph Search
o In BFS, for example, we shouldn’t bother expanding the circled nodes
(why?)
S
d e p
b c e h r q
a a h r p q f
p q f q c G
q c G a
a
Graph Search
o Idea: never expand a state twice
o How to implement:
o Tree search + set of expanded states (“closed set”)
o Expand the search tree node-by-node, but…
o Before expanding a node, check to make sure its state has
never been expanded before
o If not new, skip it, if new add to closed set
h=0
Closed Set:S B C A
Consistency of Heuristics
o Main idea: estimated heuristic costs ≤ actual costs
o Consequences of consistency:
o The f value along a path never decreases
G
h(A) ≤ cost(A to C) + h(C)