Search Strategies
CPS4801
Uninformed Search Strategies
Uninformed search strategies use only the information available in the problem definition•
• Breadth-first search• Uniform-cost search• Depth-first search• Depth-limited search• Iterative deepening search
3
Breadth-first searchExpand shallowest unexpanded node• Implementation:• Frontier is a FIFO queue, i.e., new successors go at end
o
4
Breadth-first search
Expand shallowest unexpanded node• Implementation:
o Frontier is a FIFO queue, i.e., new successors go at end
5
Breadth-first searchExpand shallowest unexpanded node• Implementation:
o Frontier is a FIFO queue, i.e., new successors go at end
6
Breadth-first searchExpand shallowest unexpanded node• Implementation:
o Frontier is a FIFO queue, i.e., new successors go at end
7
Properties of breadth-first search
Complete? Yes (if b is finite)•• Time? 1+b+b2+b3+… +bd = O(bd)•• Space? O(bd) (O(bd-1) nodes in the explored
set and O(bd) nodes in the frontier)•• Optimal? Yes (if cost = 1 per step)•
Properties of breadth-first search
• O(bd) is scary.• Assuming b=10
• Space is the bigger problem (more than time)
Depth Nodes Time Memory
10 10 10 3 hours 10 terabytes
12 10 12 13 days 1 petabyte
14 10 14 3.5 years 99 petabytes
16 10 16 350 years 10 exabytes
9
Uniform-cost search• Expand least-cost unexpanded node• (Cheapest search)• Implementation:
o Frontier = queue ordered by path cost
10
Example: Romania
Properties of uniform-cost search
• Equivalent to breadth-first if step costs all equal
• Complete? Yes, if step cost ≥ ε• Time? # of nodes with g ≤ cost of optimal
solution, O(bceiling(C*/ ε)) where C* is the cost of the optimal solution
• Space? # of nodes with g ≤ cost of optimal solution, O(bceiling(C*/ ε))
• Optimal? Yes – nodes expanded in increasing order of g(n)
12
Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front
o
13
Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front
o
14
Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front
o
15
Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front
o
16
Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front
o
17
Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front
o
18
Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front
o
19
Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front
o
20
Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front
o
21
Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front
o
22
Depth-first searchExpand deepest unexpanded node• Implementation:• fringe = LIFO queue, i.e., put successors at front
o
23
Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front
o
24
Properties of depth-first search
• Complete? No: fails in infinite-depth spaces, spaces with loopso Modify to avoid repeated states along patho complete in finite spaces
• Time? O(bm): terrible if m is much larger than do but if solutions are dense, may be much faster than
breadth-first
Space? O(bm), i.e., linear space!•
• Optimal? No•
Depth-limited search• depth-first search with depth limit l,• i.e., nodes at depth l have no successors
• 20 cities in map of Romania• l =19• Any city can be reached from any other
city in at most 9 steps.• Diameter gives a better depth limit.
Iterative deepening search
• Gradually increases the limit – 0, 1, 2, …• Combines the benefits of depth-first and
breadth-first search.
27
Iterative deepening search l =0
28
Iterative deepening search l =1
29
Iterative deepening search l =2
30
Iterative deepening search l =3
31
Properties of iterative deepening search
Complete? Yes•
• Time? d b1 + (d-1)b2 + … + (1)bd = O(bd)•
• Space? O(bd)•
• Optimal? Yes
32
Summary of algorithms
Informed Search Strategies
• uses problem-specific knowledge beyond the definition of the problem itself
Best-first search• Idea: use an evaluation function f(n) for each
nodeo estimate of "desirability" Expand most desirable unexpanded node
• Implementation:Order the nodes in frontier in decreasing order of desirability
• Special cases:o greedy best-first searcho A* search
Romania with step costs in km
Greedy best-first search
• Evaluation function f(n) = h(n) (heuristic)• = estimate of cost from n to goal•
• e.g., hSLD(n) = straight-line distance from n to Bucharest
•
• Greedy best-first search expands the node that appears to be closest to goal
•
Greedy best-first search example
Greedy best-first search example
Greedy best-first search example
Greedy best-first search example
Properties of greedy best-first search
Complete? No – can get stuck in loops, e.g., Iasi Neamt Iasi Neamt •
• Time? O(bm)•
• Space? O(bm) -- keeps all nodes in memory•
• Optimal? No•
A* searchIdea: 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 from n to goal• f(n) = estimated total cost of path through n to
goal
Romania with step costs in km
A* search example
A* search example
A* search example
A* search example
A* search example
A* search example
Admissible heuristicsA heuristic h(n) is admissible if for every node n, h(n) ≤ h*(n), where h*(n) is the true cost to reach the goal state from n.•
• An admissible heuristic never overestimates the cost to reach the goal, i.e., it is optimistic
•
• Example: hSLD(n) (never overestimates the actual road distance)
Top Related