Inf2D 03: Search Strategies Valerio Restocchi School of - - PowerPoint PPT Presentation

inf2d 03 search strategies
SMART_READER_LITE
LIVE PREVIEW

Inf2D 03: Search Strategies Valerio Restocchi School of - - PowerPoint PPT Presentation

Inf2D 03: Search Strategies Valerio Restocchi School of Informatics, University of Edinburgh 17/01/20 Slide Credits: Jacques Fleuriot, Michael Rovatsos, Michael Herrmann, Vaishak Belle Outline Uninformed search strategies use only


slide-1
SLIDE 1

Inf2D 03: Search Strategies

Valerio Restocchi

School of Informatics, University of Edinburgh

17/01/20

Slide Credits: Jacques Fleuriot, Michael Rovatsos, Michael Herrmann, Vaishak Belle

slide-2
SLIDE 2

Outline

− Uninformed search strategies use only information in problem definition − Breadth-first search − Depth-first search − Depth-limited and iterative deepening search

2

slide-3
SLIDE 3

Search strategies

− A search strategy is defined by picking the order of node expansion – nodes are taken from the frontier − Strategies are evaluated along the following dimensions:

◮ completeness: does it always find a solution if one exists? ◮ time complexity: number of nodes generated ◮ space complexity: maximum number of nodes in memory ◮ optimality: does it always find a least-cost solution?

− Time and space complexity are measured in terms of

◮ b: maximum branching factor of the search tree ◮ d: depth of the least-cost solution ◮ m: maximum depth of the state space (may be ∞)

3

slide-4
SLIDE 4

Recall: Tree Search

“Arad” is a repeated state!

4

slide-5
SLIDE 5

Repeated states

− Failure to detect repeated states can turn a linear problem into an exponential one!

5

slide-6
SLIDE 6

Graph search

Augment TREE-SEARCH with a new data-structure: − the explored set (closed list), which remembers every expanded node − newly expanded nodes already in explored set are discarded

6

slide-7
SLIDE 7

Breadth-first search

− Expand shallowest unexpanded node − Implementation:

◮ frontier is a FIFO queue, i.e., new successors go at end

7

slide-8
SLIDE 8

Breadth-first search

− Expand shallowest unexpanded node − Implementation:

◮ frontier is a FIFO queue, i.e., new successors go at end

8

slide-9
SLIDE 9

Breadth-first search

− Expand shallowest unexpanded node − Implementation:

◮ frontier is a FIFO queue, i.e., new successors go at end

9

slide-10
SLIDE 10

Breadth-first search

− Expand shallowest unexpanded node − Implementation:

◮ frontier is a FIFO queue, i.e., new successors go at end

10

slide-11
SLIDE 11

Breadth-first search algorithm

11

slide-12
SLIDE 12

Properties of breadth-first search

− Complete? Yes (if b is finite) − Time? b + b2 + b3 + ... + bd = O

  • bd

(worst-case: regular b-ary tree of depth d) − Space? O

  • bd

(keeps every node in memory) − Optimal? Yes (if cost = 1 per step, then a solution is

  • ptimal if it is closest to the start node)

Space is the bigger problem (more than time)

12

slide-13
SLIDE 13

Depth-first search

− Expand deepest unexpanded node − Implementation:

◮ frontier = LIFO queue, i.e., put successors at front

13

slide-14
SLIDE 14

Depth-first search

− Expand deepest unexpanded node − Implementation:

◮ frontier = LIFO queue, i.e., put successors at front

14

slide-15
SLIDE 15

Depth-first search

− Expand deepest unexpanded node − Implementation:

◮ frontier = LIFO queue, i.e., put successors at front

15

slide-16
SLIDE 16

Depth-first search

− Expand deepest unexpanded node − Implementation:

◮ frontier = LIFO queue, i.e., put successors at front

16

slide-17
SLIDE 17

Depth-first search

− Expand deepest unexpanded node − Implementation:

◮ frontier = LIFO queue, i.e., put successors at front

17

slide-18
SLIDE 18

Depth-first search

− Expand deepest unexpanded node − Implementation:

◮ frontier = LIFO queue, i.e., put successors at front

18

slide-19
SLIDE 19

Depth-first search

− Expand deepest unexpanded node − Implementation:

◮ frontier = LIFO queue, i.e., put successors at front

19

slide-20
SLIDE 20

Depth-first search

− Expand deepest unexpanded node − Implementation:

◮ frontier = LIFO queue, i.e., put successors at front

20

slide-21
SLIDE 21

Depth-first search

− Expand deepest unexpanded node − Implementation:

◮ frontier = LIFO queue, i.e., put successors at front

21

slide-22
SLIDE 22

Depth-first search

− Expand deepest unexpanded node − Implementation:

◮ frontier = LIFO queue, i.e., put successors at front

22

slide-23
SLIDE 23

Depth-first search

− Expand deepest unexpanded node − Implementation:

◮ frontier = LIFO queue, i.e., put successors at front

23

slide-24
SLIDE 24

Depth-first search

− Expand deepest unexpanded node − Implementation:

◮ frontier = LIFO queue, i.e., put successors at front

24

slide-25
SLIDE 25

Properties of depth-first search

− Complete? No: fails in infinite-depth spaces, spaces with loops

◮ Modify to avoid repeated states along path ◮ Complete in finite spaces

− Time? O (bm): terrible if m is much larger than d

◮ but if solutions are dense, may be much faster than breadth-first

− Space? O (bm), i.e., linear space! − Optimal? No

25

slide-26
SLIDE 26

Mid-Lecture Problem

− Compare breadth-first and depth-first search.

◮ When would breadth-first be preferable? ◮ When would depth-first be preferable?

26

slide-27
SLIDE 27

Solution

− Breadth-First:

◮ When completeness is important. ◮ When optimal solutions are important.

− Depth-First:

◮ When solutions are dense and low-cost is important, especially space costs.

27

slide-28
SLIDE 28

Depth-limited search

This is depth-first search with depth limit l, i.e., nodes at depth l have no successors Recursive implementation:

28

slide-29
SLIDE 29

Iterative deepening search

29

slide-30
SLIDE 30

Iterative deepening search

30

slide-31
SLIDE 31

Iterative deepening search

31

slide-32
SLIDE 32

Iterative deepening search

32

slide-33
SLIDE 33

Iterative deepening search

33

slide-34
SLIDE 34

Iterative deepening search

− Number of nodes generated in an iterative deepening search to depth d with branching factor b: NIDS = (d)b + (d − 1)b2 + · · · + (2)bd−1 + (1)bd − Some cost associated with generating upper levels multiple times − Example: For b = 10, d = 5,

◮ NBFS = 10+100+3, 000+10, 000+100, 000 = 111, 110 ◮ NIDS = 50+400+3, 000+20, 000+100, 000 = 123, 450

− Overhead = (123, 450 − 111, 110)/111, 110 = 11%

34

slide-35
SLIDE 35

Properties of iterative deepening search

− Complete? Yes − Time? (d)b + (d − 1)b2 + ... + (1)bd = O(bd) − Space? O (bd) − Optimal? Yes, if step cost = 1

35

slide-36
SLIDE 36

Uniform cost search (UCS)

Step costs are not uniform. Details: home work.

36

slide-37
SLIDE 37

Summary of algorithms

37

slide-38
SLIDE 38

Summary

− Variety of uninformed search strategies:

◮ breadth-first ◮ depth-first ◮ depth limited ◮ iterative deepening

− Iterative deepening search uses only linear space and not much more time than other uninformed algorithms

38