Heuristic-search PDF Practice
-
Upload
pankaj-shukla -
Category
Documents
-
view
212 -
download
0
Transcript of Heuristic-search PDF Practice
-
7/24/2019 Heuristic-search PDF Practice
1/4
1
Heuristic Search
2
Heuristic Search
Heuristicorinformed searchexploits additionalknowledge about the problem that helps direct search tomore promising paths.
Aheuristic function, h(n), provides an estimate of the cosof the path from a given node to the closest goal state.
Must be zero if node represents a goal state.-Example: Straight-line distance from current location to
the goal location in a road navigation problem.
Many search problems are NP-complete so in the worstcase still have exponential time complexity; however a gooheuristic can:
-Find a solution for an average problem efficiently.
-Find a reasonably good but not optimal solutionefficiently.
3
Best-First Search
At each step, best-first search sorts the queue according to aheuristic function.
function BEST-FIRST-SEARCH(problem,EVAL-FN)returnsa solution sequence
inputs: problem, a problem
Eval-Fn, an evaluation function
Queueing-Fn
a function that orders nodes by EVAL-FN
returnGENERAL-SEARCH(problem,Queueing-Fn)
Bucharest
Giurgiu
Urziceni
Hirsova
Eforie
NeamtOradea
Zerind
Arad
Timisoara
LugojMehadia
DobretaCraiova
Sibiu
Fagaras
PitestiRimnicu Vilcea
Vaslui
Iasi
Straightline distanceto Bucharest
0160
242
161
77
151
241
366
193
178
253
329
80
199
244
380
226
234
374
98
Giurgiu
UrziceniHirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu Fagaras
Pitesti
Vaslui
Iasi
Rimnicu Vilcea
Bucharest
71
75
118
111
70
75
120
151
140
99
80
97
101
211
138
146 85
90
98
142
92
87
86
4
Best-First Example
Does not find shortest path to goal (through Rimnicu) since itonly focused on the cost remaining rather than the total cost.
Arad
h=366
Arad
Timisoara ZerindSibiu
h=253 h=329 h=374
Arad
Timisoara ZerindSibiu
h=329 h=374
Arad OradeaFagaras Rimnicu
h=380 h=193h=366 h=178
Arad
Timisoara ZSibiu
h=329 h=37
Arad OradeaFagaras Rimnicu
h=380 h=193h=366
Sibiu
h=253
Bucharest
h=0
-
7/24/2019 Heuristic-search PDF Practice
2/4
5
Best-First Properties
Not complete, may follow infinite path if heuristic rates eachstate on such a path as the best option. Most reasonableheuristics will not cause this problem however.
Worst case time complexity is still O(b
m
) where m is themaximum depth.
Since must maintain a queue of all unexpanded states,space-complexity is also O(bm).
However, a good heuristic will avoid this worst-casebehavior for most problems.
6
Beam Search
Space and time complexity of storing and sorting the complequeue can be too inefficient.
Beam search trims queue to the best noptions (nis called tbeam width) at each point.
Focuses search more but may eliminate solution even for fin
seach graphs
Example for n=2.
Arad
h=366
Arad
Timisoara ZerindSibiu
h=253 h=329 h=374
Arad
Timisoara ZerindSibiu
h=329 h=374
Arad OradeaFagaras Rimnicu
h=380 h=193h=366 h=178
Arad
Timisoara ZSibiu
h=329 h=37
Arad OradeaFagaras Rimnicuh=380 h=193h=366
Sibiu
h=253
Bucharest
h=0
7
Hill-Climbing
Beam search with a beam-width of 1 is calledhill-climbing.
Pursues locally best option at each point, i.e. the bestsuccessor to the current best node.
Subject to local maxima, plateaux, and ridges.
evaluation
current
state
8
Minimizing Total Path Cost: A* Search
A* combines features of uniform cost search (complete,optimal, inefficient) with best-first (incomplete, non-optimaefficient).
Sort queue by estimated total cost of the completion of apath.
f(n) = g(n) + h(n)
If the heuristic function always underestimates the distancto the goal, it is said to beadmissible.
If his admissible, then f(n) never overestimates the actualcost of the best solution through n.
-
7/24/2019 Heuristic-search PDF Practice
3/4
9
A* Example
Finds the optimal path to Bucharest through Rimnicu and Pitesti
AradArad
Timisoara ZerindSibiu
Sibiu
Arad OradeaFagaras Rimnicu
Arad
Timisoara Zerind
Sibiu
Arad OradeaFagaras Rimnicu
Arad
Timisoara Zerind
Craiova Pitesti Sibiu
f=0+366
=366
f=140+253
=393
f=118+329
=447
f=75+374
=449
f=280+366
=646
f=239+178
=417
f=146+380
=526
f=118+329
=447
f=220+193
=413
f=75+374
=449
f=280+366
=646
f=239+178
=417
f=146+380
=526
f=118+329
=447
f=75+374
=449
f=300+253
=553
f=317+98
=415
f=366+160
=526
10
Optimality of A*
If his admissible, A* will always find a least cost path to thgoal.
Proof by contradiction:
Let Gbe an optimal goal state with a path cost f*
Let G2be a suboptimal goal state supposedly found by A*Let nbe a current leaf node on an optimal path to G
Since his admissible:f*>=f(n)
If G2is chosen for expansion over nthen:f(n) >= f(G2)
Therefore:f*>=f(G2)
Since G2is a goal state, h(G2)=0, thereforef(G2) = g(G2)f*>= g(G2)
Therefore G2is optimal.Contradiction.Q.E.D.
11
Other Properties of A*
A* is complete as long as
-Branching factor is always finite
-Every operator adds cost at least > 0
Time and space complexity still O(bm) in the worst casesince must maintain and sort complete queue of unexploredoptions.
However, with a good heuristic can find optimal solutions formany problems in reasonable time.
Again, space complexity is a worse problem than time.
12
Heuristic Functions
8-puzzle search space
-Typical solution length: 20 steps
-Average branching factor: 3
-Exhaustive search: 320=3.5 x 109
-Bound on unique states: 9! = 362,880
Admissible Heuristics:
-Number of tiles out of place (h1): 7
-City-block (Manhattan) distance (h2):2+3+3+2+4+2+0+2=18
Start State Goal State
2
45
6
7
8
1 2 3
4
67
81
23
45
6
7
81
23
45
6
7
8
5
-
7/24/2019 Heuristic-search PDF Practice
4/4