1 solving problems by searching chapter 3. depth first search expand deepest unexpanded node the...

22
1 Solving problems by searching Chapter 3

Upload: derrick-golden

Post on 18-Jan-2016

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

1

Solving problems by searching

Chapter 3

Page 2: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

Depth First Search

Expand deepest unexpanded node The root is examined first; then the left child of the

root; then the left child of this node, etc. until a leaf is found. At a leaf, backtrack to the lowest right child and repeat.

Does not have to keep all nodes on the open list, only retains the children of a single state

May get stuck in a deep search space Implementation : Fringe = LIFO queue, i.e., put successors at front

2

Page 3: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

Depth-first Search Algorithm

3

Page 4: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

4

Depth-first search

Page 5: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

5

Depth-first search

Page 6: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

6

Depth-first search

Page 7: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

7

Depth-first search

Page 8: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

8

Depth-first search

Page 9: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

9

Depth-first search

Page 10: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

10

Depth-first search

Page 11: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

Depth-first Search

11

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

complete in finite spaces

Time? O(bm): terrible if m is much larger than d where m is maximum depth of any node,

d is depth of the least-cost solution but if solutions are dense, may be much faster

than breadth-first Space? O(bm), i.e., linear space!

where b is maximum branching factor of the search tree

Optimal? No

Page 12: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

12

Depth-first search of 8-puzzle with a depth bound of 5

Page 13: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

Depth Limited Search

13

Depth-limit for search is set at depth (level) l.

Nodes at depth (level) l have no successors in the search tree.

It is not optimal. It is complete if d < l. It has time complexity of O(bl). But space complexity is only O(bl).

Page 14: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

Depth Limited Search

14

Page 15: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

15

Iterative Deepening Search

Combines the benefits of depth-first and breadth-first search.

It is complete and optimal. It has time complexity of O(bd). But space complexity is only O(bd).

Page 16: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

16

Iterative deepening search l =0

Page 17: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

17

Iterative deepening search l =1

Page 18: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

18

Iterative deepening search l =2

Page 19: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

19

Iterative deepening search l =3

Page 20: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

20

Iterative Deepening: Efficiency

Iterative deepening looks inefficient because so many states are expanded multiple times. In practice this is not that bad, because by far most of the nodes are at the bottom level. For a branching factor b of 2, this

might double the search time. For a branching factor b of 10, this

might add 10% to the search time.

Page 21: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

21

Properties of iterative deepening search

Complete? Yes

Time? (d+1)b0 + d b1 + (d-1)b2 + … + bd = O(bd)

Space? O(bd)

Optimal? Yes

Page 22: 1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;

Summary of algorithms

Example :

http://www.cs.rochester.edu/u/kautz/Mazes/search/applet.html

22