















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Informed search algorithms, specifically greedy search, a* search, and ida*. These algorithms use heuristic functions to estimate the cost of paths and find optimal solutions. The document also covers the properties of these algorithms, their completeness, and space requirements.
Typology: Study notes
1 / 55
This page cannot be seen from the preview
Don't miss anything!
















































Last update: September 9, 2008
CMSC 421: Chapter 4, Sections 1–
♦ In Chapter 3 we were talked about trial-and-error search
♦ In the worst case, most searches take exponential time (unless P=NP)
♦ Can sometimes do much better on the average, using heuristic techniques
heuristic: A rule of thumb, simplification, or educated guess that reduces or limits the search for solutions in domains that are difficult and poorly understood.
Depending on what heuristic you use, you won’t necessarily find an optimal solution, or even a solution at all.
function Tree-Search( problem) returns a solution, or failure fringe ← a list containing Make-Node(Initial-State[problem]) loop do if fringe is empty then return failure node ← Remove-Front(fringe) if Goal-Test[problem] applied to State(node) succeeds return node fringe ← InsertAll(Expand(node, problem), fringe)
Heuristic choice in search algorithms: what node to expand next Use an evaluation function for each node – estimate of “desirability” ⇒ Expand most desirable unexpanded node
This depends on InsertAll Want to keep fringe sorted in decreasing order of desirability
function Graph-Search( problem, fringe) returns a solution, or failure closed ← an empty set fringe ← Insert(Make-Node(Initial-State[problem]), fringe) loop do if fringe is empty then return failure node ← Remove-Front(fringe) if Goal-Test(problem, State[node]) then return node if State[node] is not in closed then add State[node] to closed fringe ← InsertAll(Expand(node, problem), fringe) end
Same as for Tree-Search: Use InsertAll to keep fringe sorted in decreasing order of desirability
Evaluation function h(n) (heuristic) = estimate of cost from n to the closest goal
E.g., hSLD(n) = straight-line distance from n to Bucharest
Greedy search keeps fringe ordered in increasing value of h, hence always expands whatever node appears to be closest to a goal
Arad 366 ↗ straight-line distance to Bucharest
Rimnicu Vilcea
Zerind
Arad
Sibiu
Arad Fagaras Oradea
Timisoara 329 374
366 176 380 193
Rimnicu Vilcea
Zerind
Arad
Sibiu
Arad Fagaras Oradea
Timisoara
Sibiu Bucharest
329 374
366 380 193
253 0
Complete? No. Can get stuck in loops: Iasi → Neamt → Iasi → Neamt → Complete in finite space with repeated-state checking
Time?
Complete? No. Can get stuck in loops: Iasi → Neamt → Iasi → Neamt → Complete in finite space with repeated-state checking
Time? O(bm), but a good heuristic can give dramatic improvement
Space?
Complete? No. Can get stuck in loops: Iasi → Neamt → Iasi → Neamt → Complete in finite space with repeated-state checking
Time? O(bm), but a good heuristic can give dramatic improvement
Space? O(bm)—keeps all nodes in memory
Optimal? No
Problem with terminology: Greedy search is not the same as an ordinary greedy algorithm.
An ordinary greedy algorithm doesn’t remember all of fringe. It remembers only the current path, and never backtracks. Hence: ♦ Repeated-state checking cannot make it complete ♦ It runs in time O(l) if it finds a solution of length l
Idea: avoid expanding paths that are already expensive
Evaluation function f (n) = g(n) + h(n)
g(n) = cost so far to reach n h(n) = estimated cost to goal from n f (n) = estimated total cost of path through n to goal
First requirement for A∗^ search:
A∗^ needs an admissible heuristic i.e., 0 ≤ h(n) ≤ h∗(n) where h∗(n) is the true cost from n. (Thus h(G) = 0 for any goal G.)
E.g., hSLD(n) never overestimates the actual road distance
Recall that we want to get from Arad to Bucharest:
Bucharest
Giurgiu
Urziceni
Hirsova
Eforie
Neamt Oradea
Zerind
Arad
Timisoara
Lugoj Mehadia
Dobreta
Craiova
Sibiu
Fagaras
Pitesti Rimnicu Vilcea
Vaslui
Iasi
Straight−line distanceto Bucharest
0 160 242 161 77 151
241
366
193
178
253 329 80 199
244
380
226
234
374
98
Giurgiu
Urziceni Hirsova
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
Arad 366=0+