Search Strategies

51
Search Strategies CPS4801

description

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. Breadth-first search. - PowerPoint PPT Presentation

Transcript of Search Strategies

Page 1: Search Strategies

Search Strategies

CPS4801

Page 2: Search Strategies

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

Page 3: Search Strategies

3

Breadth-first searchExpand shallowest unexpanded node• Implementation:• Frontier is a FIFO queue, i.e., new successors go at end

o

Page 4: Search Strategies

4

Breadth-first searchExpand shallowest unexpanded node• Implementation:

o Frontier is a FIFO queue, i.e., new successors go at end

Page 5: Search Strategies

5

Breadth-first searchExpand shallowest unexpanded node• Implementation:

o Frontier is a FIFO queue, i.e., new successors go at end

Page 6: Search Strategies

6

Breadth-first searchExpand shallowest unexpanded node• Implementation:

o Frontier is a FIFO queue, i.e., new successors go at end

Page 7: Search Strategies

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)•

Page 8: Search Strategies

Properties of breadth-first search

• O(bd) is scary.• Assuming b=10

• Space is the bigger problem (more than time)

Depth Nodes Time Memory10 10 10 3 hours 10

terabytes12 10 12 13 days 1 petabyte14 10 14 3.5 years 99

petabytes16 10 16 350 years 10

exabytes

Page 9: Search Strategies

9

Uniform-cost search• Expand least-cost unexpanded node• (Cheapest search)• Implementation:

o Frontier = queue ordered by path cost

Page 10: Search Strategies

10

Example: Romania

Page 11: Search Strategies

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)

Page 12: Search Strategies

12

Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front

o

Page 13: Search Strategies

13

Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front

o

Page 14: Search Strategies

14

Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front

o

Page 15: Search Strategies

15

Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front

o

Page 16: Search Strategies

16

Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front

o

Page 17: Search Strategies

17

Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front

o

Page 18: Search Strategies

18

Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front

o

Page 19: Search Strategies

19

Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front

o

Page 20: Search Strategies

20

Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front

o

Page 21: Search Strategies

21

Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front

o

Page 22: Search Strategies

22

Depth-first searchExpand deepest unexpanded node• Implementation:• fringe = LIFO queue, i.e., put successors at front

o

Page 23: Search Strategies

23

Depth-first searchExpand deepest unexpanded node• Implementation:• Frontier = LIFO queue, i.e., put successors at front

o

Page 24: Search Strategies

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•

Page 25: Search Strategies

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.

Page 26: Search Strategies

Iterative deepening search

• Gradually increases the limit – 0, 1, 2, …• Combines the benefits of depth-first and

breadth-first search.

Page 27: Search Strategies

27

Iterative deepening search l =0

Page 28: Search Strategies

28

Iterative deepening search l =1

Page 29: Search Strategies

29

Iterative deepening search l =2

Page 30: Search Strategies

30

Iterative deepening search l =3

Page 31: Search Strategies

31

Properties of iterative deepening search

Complete? Yes•• Time? d b1 + (d-1)b2 + … + (1)bd = O(bd)•• Space? O(bd)•• Optimal? Yes

Page 32: Search Strategies

32

Summary of algorithms

Page 33: Search Strategies

Informed Search Strategies

• uses problem-specific knowledge beyond the definition of the problem itself

Page 34: Search Strategies
Page 35: Search Strategies

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

Page 36: Search Strategies

Romania with step costs in km

Page 37: Search Strategies

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•

Page 38: Search Strategies

Greedy best-first search example

Page 39: Search Strategies

Greedy best-first search example

Page 40: Search Strategies

Greedy best-first search example

Page 41: Search Strategies

Greedy best-first search example

Page 42: Search Strategies

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•

Page 43: Search Strategies

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

Page 44: Search Strategies

Romania with step costs in km

Page 45: Search Strategies

A* search example

Page 46: Search Strategies

A* search example

Page 47: Search Strategies

A* search example

Page 48: Search Strategies

A* search example

Page 49: Search Strategies

A* search example

Page 50: Search Strategies

A* search example

Page 51: Search Strategies

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)