Professional Documents
Culture Documents
Heuristic-Search 4 PDF
Heuristic-Search 4 PDF
1 2
•At each step, best-first search sorts the queue according to a Arad
heuristic function. h=366
Arad
function BEST-FIRST-SEARCH( problem, EVAL-FN) returns a solution sequence
inputs: problem, a problem Sibiu Timisoara Zerind
Eval-Fn, an evaluation function h=253 h=329 h=374
Arad
Queueing-Fn a function that orders nodes by EVAL-FN
return GENERAL-SEARCH( problem, Queueing-Fn) Sibiu Timisoara Zerind
h=329 h=374
3 4
Best-First Properties Beam Search
•Focuses search more but may eliminate solution even for finite
•Worst case time complexity is still O(bm) where m is the seach graphs
maximum depth.
•Example for n=2.
Arad
h=366
Arad
•Since must maintain a queue of all unexpanded states,
m
space-complexity is also O(b ). Sibiu Timisoara Zerind
h=253 h=329 h=374
Arad
Sibiu Bucharest
h=253 h=0
5 6
7 8
A* Example Optimality of A*
Arad
f=0+366 Arad •If h is admissible, A* will always find a least cost path to the
=366 goal.
Sibiu Timisoara Zerind
f=140+253 f=118+329 f=75+374 Arad
=393 =447 =449
Therefore:
•Finds the optimal path to Bucharest through Rimnicu and Pitesti f* >= f(G2)
Therefore G2 is optimal.
Contradiction.
Q.E.D.
9 10
7 3 22 7 6 25
•However, with a good heuristic can find optimal solutions for
many problems in reasonable time. Start State Goal State
•Admissible Heuristics:
•Again, space complexity is a worse problem than time. -Number of tiles out of place (h1): 7
-City-block (Manhattan) distance (h2):
2+3+3+2+4+2+0+2=18
11 12
Heuristic Performance Quality of Heuristics
13 14
Inventing Heuristics
•For 8-puzzle:
A tile can move from square A to B if A is adjacent to B and
B is blank
15