Professional Documents
Culture Documents
Best-First Search: Evaluation Function
Best-First Search: Evaluation Function
function Tree-Search( problem, fringe) returns a solution, or failure Evaluation function h(n) (heuristic)
fringe ← Insert(Make-Node(Initial-State[problem]), fringe) = estimate of cost from n to the closest goal
loop do
if fringe is empty then return failure E.g., hSLD (n) = straight-line distance from n to Bucharest
node ← Remove-Front(fringe)
Greedy search expands the node that appears to be closest to goal
if Goal-Test[problem] applied to State(node) succeeds return node
fringe ← InsertAll(Expand(node, problem), fringe)
Arad Arad
366
Sibiu Bucharest
253 0
Arad Arad
Arad Fagaras Oradea Rimnicu Vilcea Arad Fagaras Oradea Rimnicu Vilcea
646=280+366 415=239+176 671=291+380 413=220+193 646=280+366 671=291+380
G G2
Craiova Pitesti Sibiu
526=366+160 417=317+100 553=300+253
I
Sibiu Bucharest Craiova Pitesti Sibiu A
591=338+253 450=450+0 526=366+160 417=317+100 553=300+253 380 S
F
V
400
T R
L P
H
M U
B
420
D
E
C
G
Properties of A∗ Properties of A∗
Complete?? Yes, unless there are infinitely many nodes with f ≤ f (G) Complete?? Yes, unless there are infinitely many nodes with f ≤ f (G)
Time?? Time?? Exponential in [relative error in h × length of soln.]
Space?? Keeps all nodes in memory
Optimal?? Yes—cannot expand fi+1 until fi is finished
A∗ expands all nodes with f (n) < C ∗
A∗ expands some nodes with f (n) = C ∗
A∗ expands no nodes with f (n) > C ∗
h1(S) =??
h2(S) =??
5 6 4 5 6
8 3 1 7 8
Dominance Summary
If h2(n) ≥ h1(n) for all n (both admissible) Heuristic functions estimate costs of shortest paths
then h2 dominates h1 and is better for search
Good heuristics can dramatically reduce search cost
Typical search costs:
Greedy best-first search expands lowest h
d = 14 IDS = 3,473,941 nodes – incomplete and not always optimal
A∗(h1) = 539 nodes
A∗(h2) = 113 nodes A∗ search expands lowest g + h
d = 24 IDS ≈ 54,000,000,000 nodes – complete and optimal
A∗(h1) = 39,135 nodes – also optimally efficient (up to tie-breaks, for forward search)
A∗(h2) = 1,641 nodes Admissible heuristics can be derived from exact solution of relaxed problems
Given any admissible heuristics ha, hb,
h(n) = max(ha(n), hb(n))
is also admissible and dominates ha, hb