Foundations of Artificial Intelligence 12. State-Space Search: - - PowerPoint PPT Presentation

foundations of artificial intelligence
SMART_READER_LITE
LIVE PREVIEW

Foundations of Artificial Intelligence 12. State-Space Search: - - PowerPoint PPT Presentation

Foundations of Artificial Intelligence 12. State-Space Search: Depth-first Search & Iterative Deepening Malte Helmert and Thomas Keller University of Basel March 18, 2020 Depth-first Search Iterative Deepening Summary State-Space


slide-1
SLIDE 1

Foundations of Artificial Intelligence

  • 12. State-Space Search: Depth-first Search & Iterative

Deepening Malte Helmert and Thomas Keller

University of Basel

March 18, 2020

slide-2
SLIDE 2

Depth-first Search Iterative Deepening Summary

State-Space Search: Overview

Chapter overview: state-space search 5.–7. Foundations 8.–12. Basic Algorithms

  • 8. Data Structures for Search Algorithms
  • 9. Tree Search and Graph Search
  • 10. Breadth-first Search
  • 11. Uniform Cost Search
  • 12. Depth-first Search and Iterative Deepening

13.–19. Heuristic Algorithms

slide-3
SLIDE 3

Depth-first Search Iterative Deepening Summary

Depth-first Search

slide-4
SLIDE 4

Depth-first Search Iterative Deepening Summary

Depth-first Search

Depth-first search (DFS) expands nodes in opposite order of generation (LIFO). deepest node expanded first

  • pen list implemented as stack

German: Tiefensuche

slide-5
SLIDE 5

Depth-first Search Iterative Deepening Summary

Depth-first Search: Example

A

  • pen: A
slide-6
SLIDE 6

Depth-first Search Iterative Deepening Summary

Depth-first Search: Example

A B C

  • pen: C, B
slide-7
SLIDE 7

Depth-first Search Iterative Deepening Summary

Depth-first Search: Example

A B D E C

  • pen: C, E, D
slide-8
SLIDE 8

Depth-first Search Iterative Deepening Summary

Depth-first Search: Example

A B D I J E C

  • pen: C, E, J, I
slide-9
SLIDE 9

Depth-first Search Iterative Deepening Summary

Depth-first Search: Example

A B D I J E C

  • pen: C, E, J
slide-10
SLIDE 10

Depth-first Search Iterative Deepening Summary

Depth-first Search: Example

A B D I J E C

  • pen: C, E
slide-11
SLIDE 11

Depth-first Search Iterative Deepening Summary

Depth-first Search: Example

A B D I J E C

  • pen: C
slide-12
SLIDE 12

Depth-first Search Iterative Deepening Summary

Depth-first Search: Example

A B D I J E C F G H

  • pen: H, G, F
slide-13
SLIDE 13

Depth-first Search Iterative Deepening Summary

Depth-first Search: Example

A B D I J E C F G H

solution found!

slide-14
SLIDE 14

Depth-first Search Iterative Deepening Summary

Depth-first Search: Some Properties

almost always implemented as a tree search (we will see why) not complete, not semi-complete, not optimal (Why?) complete for acyclic state spaces, e.g., if state space directed tree

slide-15
SLIDE 15

Depth-first Search Iterative Deepening Summary

Reminder: Generic Tree Search Algorithm

reminder from Chapter 9: Generic Tree Search

  • pen := new OpenList
  • pen.insert(make root node())

while not open.is empty(): n := open.pop() if is goal(n.state): return extract path(n) for each a, s′ ∈ succ(n.state): n′ := make node(n, a, s′)

  • pen.insert(n′)

return unsolvable

slide-16
SLIDE 16

Depth-first Search Iterative Deepening Summary

Depth-first Search (Non-recursive Version)

depth-first search (non-recursive version): Depth-first Search (Non-recursive Version)

  • pen := new Stack
  • pen.push back(make root node())

while not open.is empty(): n := open.pop back() if is goal(n.state): return extract path(n) for each a, s′ ∈ succ(n.state): n′ := make node(n, a, s′)

  • pen.push back(n′)

return unsolvable

slide-17
SLIDE 17

Depth-first Search Iterative Deepening Summary

Non-recursive Depth-first Search: Discussion

discussion: there isn’t much wrong with this pseudo-code

(as long as we ensure to release nodes that are no longer required when using programming languages without garbage collection)

however, depth-first search as a recursive algorithm is simpler and more efficient CPU stack as implicit open list no search node data structure needed

slide-18
SLIDE 18

Depth-first Search Iterative Deepening Summary

Depth-first Search (Recursive Version)

function depth first search(s)

if is goal(s): return for each a, s′ ∈ succ(s): solution := depth first search(s′) if solution = none: solution.push front(a) return solution return none

main function: Depth-first Search (Recursive Version)

return depth first search(init())

slide-19
SLIDE 19

Depth-first Search Iterative Deepening Summary

Depth-first Search: Complexity

time complexity: If the state space includes paths of length m, depth-first search can generate O(bm) nodes, even if much shorter solutions (e.g., of length 1) exist. On the other hand: in the best case, solutions of length ℓ can be found with O(bℓ) generated nodes. (Why?) improvable to O(ℓ) with incremental successor generation space complexity:

  • nly need to store nodes along currently explored path

(“along”: nodes on path and their children) space complexity O(bm) if m maximal search depth reached low memory complexity main reason why depth-first search interesting despite its disadvantages

slide-20
SLIDE 20

Depth-first Search Iterative Deepening Summary

Depth-first Search: Complexity

time complexity: If the state space includes paths of length m, depth-first search can generate O(bm) nodes, even if much shorter solutions (e.g., of length 1) exist. On the other hand: in the best case, solutions of length ℓ can be found with O(bℓ) generated nodes. (Why?) improvable to O(ℓ) with incremental successor generation space complexity:

  • nly need to store nodes along currently explored path

(“along”: nodes on path and their children) space complexity O(bm) if m maximal search depth reached low memory complexity main reason why depth-first search interesting despite its disadvantages

slide-21
SLIDE 21

Depth-first Search Iterative Deepening Summary

Iterative Deepening

slide-22
SLIDE 22

Depth-first Search Iterative Deepening Summary

Depth-limited Search

depth-limited search: depth-first search which prunes (does not expand) all nodes at a given depth d not very useful on its own, but important ingredient

  • f more useful algorithms

German: tiefenbeschr¨ ankte Suche

slide-23
SLIDE 23

Depth-first Search Iterative Deepening Summary

Depth-limited Search: Pseudo-Code

function depth limited search(s, depth limit):

if is goal(s): return if depth limit > 0: for each a, s′ ∈ succ(s): solution := depth limited search(s′, depth limit − 1) if solution = none: solution.push front(a) return solution return none

slide-24
SLIDE 24

Depth-first Search Iterative Deepening Summary

Iterative Deepening Depth-first Search

iterative deepening depth-first search (iterative deepening DFS): idea: perform a sequence of depth-limited searches with increasing depth limit sounds wasteful (each iteration repeats all the useful work

  • f all previous iterations)

in fact overhead acceptable ( analysis follows) Iterative Deepening DFS

for depth limit ∈ {0, 1, 2, . . . }: solution := depth limited search(init(), depth limit) if solution = none: return solution

German: iterative Tiefensuche

slide-25
SLIDE 25

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Properties

combines advantages of breadth-first and depth-first search: (almost) like BFS: semi-complete (however, not complete) like BFS: optimal if all actions have same cost like DFS: only need to store nodes along one path space complexity O(bd), where d minimal solution length time complexity only slightly higher than BFS ( analysis soon)

slide-26
SLIDE 26

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 0 generated in this round: 1 total generated: 1

slide-27
SLIDE 27

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 1 generated in this round: 1 total generated: 1 + 1

slide-28
SLIDE 28

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 1 generated in this round: 2 total generated: 1 + 2

slide-29
SLIDE 29

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 1 generated in this round: 3 total generated: 1 + 3

slide-30
SLIDE 30

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 2 generated in this round: 1 total generated: 1 + 3 + 1

slide-31
SLIDE 31

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 2 generated in this round: 2 total generated: 1 + 3 + 2

slide-32
SLIDE 32

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 2 generated in this round: 3 total generated: 1 + 3 + 3

slide-33
SLIDE 33

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 2 generated in this round: 4 total generated: 1 + 3 + 4

slide-34
SLIDE 34

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 2 generated in this round: 5 total generated: 1 + 3 + 5

slide-35
SLIDE 35

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 2 generated in this round: 6 total generated: 1 + 3 + 6

slide-36
SLIDE 36

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 2 generated in this round: 7 total generated: 1 + 3 + 7

slide-37
SLIDE 37

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 3 generated in this round: 1 total generated: 1 + 3 + 7 + 1

slide-38
SLIDE 38

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 3 generated in this round: 2 total generated: 1 + 3 + 7 + 2

slide-39
SLIDE 39

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 3 generated in this round: 3 total generated: 1 + 3 + 7 + 3

slide-40
SLIDE 40

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 3 generated in this round: 4 total generated: 1 + 3 + 7 + 4

slide-41
SLIDE 41

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 3 generated in this round: 5 total generated: 1 + 3 + 7 + 5

slide-42
SLIDE 42

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 3 generated in this round: 6 total generated: 1 + 3 + 7 + 6

slide-43
SLIDE 43

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 3 generated in this round: 7 total generated: 1 + 3 + 7 + 7

slide-44
SLIDE 44

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 3 generated in this round: 8 total generated: 1 + 3 + 7 + 8

slide-45
SLIDE 45

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 3 generated in this round: 9 total generated: 1 + 3 + 7 + 9

slide-46
SLIDE 46

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 3 generated in this round: 10 total generated: 1 + 3 + 7 + 10

slide-47
SLIDE 47

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 3 generated in this round: 11 total generated: 1 + 3 + 7 + 11

slide-48
SLIDE 48

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Example

depth limit: 3 generated in this round: 12 total generated: 1 + 3 + 7 + 12 solution found!

slide-49
SLIDE 49

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Complexity Example

time complexity (generated nodes):

breadth-first search 1 + b + b2 + · · · + bd−1 + bd iterative deepening DFS (d + 1) + db + (d − 1)b2 + · · · + 2bd−1 + 1bd

example: b = 10, d = 5

breadth-first search 1 + 10 + 100 + 1000 + 10000 + 100000 = 111111 iterative deepening DFS 6 + 50 + 400 + 3000 + 20000 + 100000 = 123456

for b = 10, only 11% more nodes than breadth-first search

slide-50
SLIDE 50

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Time Complexity

Theorem (time complextive of iterative deepening DFS) Let b be the branching factor and d be the minimal solution length of the given state space. Let b ≥ 2. Then the time complexity of iterative deepening DFS is (d + 1) + db + (d − 1)b2 + (d − 2)b3 + · · · + 1bd = O(bd) and the memory complexity is O(bd).

slide-51
SLIDE 51

Depth-first Search Iterative Deepening Summary

Iterative Deepening DFS: Evaluation

Iterative Deepening DFS: Evaluation Iterative Deepening DFS is often the method of choice if tree search is adequate (no duplicate elimination necessary), all action costs are identical, and the solution depth is unknown.

slide-52
SLIDE 52

Depth-first Search Iterative Deepening Summary

Summary

slide-53
SLIDE 53

Depth-first Search Iterative Deepening Summary

Summary

depth-first search: expand nodes in LIFO order usually as a tree search easy to implement recursively very memory-efficient can be combined with iterative deepening to combine many of the good aspects

  • f breadth-first and depth-first search
slide-54
SLIDE 54

Depth-first Search Iterative Deepening Summary

Comparison of Blind Search Algorithms

completeness, optimality, time and space complexity

search algorithm criterion breadth- uniform depth- depth- iterative first cost first limited deepening complete? yes* yes no no semi

  • ptimal?

yes** yes no no yes** time O(bd) O(b⌊c∗/ε⌋+1) O(bm) O(bℓ) O(bd) space O(bd) O(b⌊c∗/ε⌋+1) O(bm) O(bℓ) O(bd) b ≥ 2 branching factor d minimal solution depth m maximal search depth ℓ depth limit c∗

  • ptimal solution cost

ε > 0 minimal action cost remarks:

* for BFS-Tree: semi-complete ** only with uniform action costs