Uninformed Search Chapter 3 4 1 Uninformed search

  • Slides: 39
Download presentation
Uninformed Search Chapter 3. 4 1

Uninformed Search Chapter 3. 4 1

Uninformed search strategies n n Uninformed: You have no clue whether one non-goal state

Uninformed search strategies n n Uninformed: You have no clue whether one non-goal state is better than any other. Your search is blind. You don’t know if your current exploration is likely to be fruitful. Various blind strategies: n n n Breadth-first search Uniform-cost search Depth-first search Iterative deepening search (generally preferred) Bidirectional search (preferred if applicable) 2

Uninformed search strategies n Queue for Frontier: n n Goal-Test: n n FIFO? LIFO?

Uninformed search strategies n Queue for Frontier: n n Goal-Test: n n FIFO? LIFO? Priority? When inserted into Frontier? When removed? Tree Search or Graph Search: n Forget Explored nodes? Remember them? 3

Breadth-first search n n Expand shallowest unexpanded node Frontier (or fringe): nodes in queue

Breadth-first search n n Expand shallowest unexpanded node Frontier (or fringe): nodes in queue to be explored Frontier is a first-in-first-out (FIFO) queue, i. e. , new successors go at end of the queue. Goal-Test when inserted. Is A a goal state? 4

Breadth-first search n n Expand shallowest unexpanded node Frontier is a FIFO queue, i.

Breadth-first search n n Expand shallowest unexpanded node Frontier is a FIFO queue, i. e. , new successors go at end Expand A to B, C: frontier = [B, C] Is B or C a goal state? 5

Breadth-first search n n Expand shallowest unexpanded node Frontier is a FIFO queue, i.

Breadth-first search n n Expand shallowest unexpanded node Frontier is a FIFO queue, i. e. , new successors go at end Expand B to D, E: frontier=[C, D, E] Is D or E a goal state? 6

Breadth-first search n n Expand shallowest unexpanded node Frontier is a FIFO queue, i.

Breadth-first search n n Expand shallowest unexpanded node Frontier is a FIFO queue, i. e. , new successors go at end Expand C to F, G: fringe=[D, E, F, G] Is F or G a goal state? 7

Example BFS 8

Example BFS 8

Properties of breadth-first search n n n Complete? Yes it always reaches goal (if

Properties of breadth-first search n n n Complete? Yes it always reaches goal (if b is finite) Time? 1+b+b 2+b 3+… +bd + (bd+1 -b)) = O(bd+1) (this is the number of nodes we generate) Space? O(bd+1) (keeps every node in memory, either in fringe or on a path to fringe). Optimal? Yes (if we guarantee that deeper solutions are less optimal, e. g. step-cost=1). Space is the bigger problem (more than time) 9

Uniform-cost search Breadth-first is only optimal if path cost is a non-decreasing function of

Uniform-cost search Breadth-first is only optimal if path cost is a non-decreasing function of depth, i. e. , f(d) ≥ f(d-1); e. g. , constant step cost, as in the 8 -puzzle. Can we guarantee optimality for any positive step cost? Uniform-cost Search: n Expand node with smallest path cost g(n). Frontier is a priority queue, i. e. , new successors are merged into the queue sorted by g(n). n n Remove successor states already on queue w/higher g(n). Goal-Test when node is popped off queue. 10

Uniform-cost search Uniform-cost Search: Expand node with smallest path cost g(n). Proof of Completeness:

Uniform-cost search Uniform-cost Search: Expand node with smallest path cost g(n). Proof of Completeness: Given that every step will cost more than 0, and assuming a finite branching factor, there is a finite number of expansions required before the total path cost is equal to the path cost of the goal state. Hence, we will reach it. Proof of optimality given completeness: Assume UCS is not optimal. Then there must be an (optimal) goal state with path cost smaller than the found (suboptimal) goal state (invoking completeness). However, this is impossible because UCS would have expanded that node first by definition. Contradiction. 11

Uniform-cost search Implementation: Frontier = queue ordered by path cost. Equivalent to breadth-first if

Uniform-cost search Implementation: Frontier = queue ordered by path cost. Equivalent to breadth-first if all step costs all equal. Complete? Yes, if step cost ≥ ε (otherwise it can get stuck in infinite loops) Time? # of nodes with path cost ≤ cost of optimal solution. Space? # of nodes with path cost ≤ cost of optimal solution. Optimal? Yes, for any step cost ≥ ε 12

A 3 S 2 B 1 C 6 4 D 1 F 8 E

A 3 S 2 B 1 C 6 4 D 1 F 8 E 1 G 20 The graph above shows the step-costs for different paths going from the start (S) to the goal (G). Use uniform cost search to find the optimal path to the goal. Exercise for at home 13

Depth-first search n Expand deepest unexpanded node n Frontier = Last In First Out

Depth-first search n Expand deepest unexpanded node n Frontier = Last In First Out (LIFO) queue, i. e. , new n successors go at the front of the queue. Goal-Test when inserted. Is A a goal state? 14

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e.

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e. , put successors at front queue=[B, C] Is B or C a goal state? 15

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e.

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e. , put successors at front queue=[D, E, C] Is D or E a goal state? 16

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e.

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e. , put successors at front queue=[H, I, E, C] Is H or I a goal state? 17

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e.

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e. , put successors at front queue=[I, E, C] 18

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e.

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e. , put successors at front queue=[E, C] 19

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e.

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e. , put successors at front queue=[J, K, C] Is J or K a goal state? 20

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e.

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e. , put successors at front queue=[K, C] 21

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e.

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e. , put successors at front queue=[C] 22

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e.

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e. , put successors at front queue=[F, G] Is F or G a goal state? 23

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e.

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e. , put successors at front queue=[L, M, G] Is L or M a goal state? 24

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e.

Depth-first search n Expand deepest unexpanded node n Frontier = LIFO queue, i. e. , put successors at front queue=[M, G] 25

Properties of depth-first search n Complete? No: fails in infinite-depth spaces B A C

Properties of depth-first search n Complete? No: fails in infinite-depth spaces B A C Can modify to avoid repeated states along path n n Time? O(bm) with m=maximum depth terrible if m is much larger than d n n but if solutions are dense, may be much faster than breadth-first Space? O(bm), i. e. , linear space! (we only need to remember a single path + expanded unexplored nodes) n Optimal? No (It may find a non-optimal goal first) 26

Iterative deepening search • To avoid the infinite depth problem of DFS, we can

Iterative deepening search • To avoid the infinite depth problem of DFS, we can decide to only search until depth L, i. e. we don’t expand beyond depth L. Depth-Limited Search • What if solution is deeper than L? Increase L iteratively. Iterative Deepening Search • As we shall see: this inherits the memory advantage of Depth-First search, and is better in terms of time complexity than Breadth first search. 27

Iterative deepening search L=0 28

Iterative deepening search L=0 28

Iterative deepening search L=1 29

Iterative deepening search L=1 29

Iterative deepening search L=2 30

Iterative deepening search L=2 30

Iterative Deepening Search L=3 31

Iterative Deepening Search L=3 31

Iterative deepening search n Number of nodes generated in a depth-limited search to depth

Iterative deepening search n Number of nodes generated in a depth-limited search to depth d with branching factor b: NDLS = b 0 + b 1 + b 2 + … + bd-2 + bd-1 + bd n n Number of nodes generated in an iterative deepening search to depth d with branching factor b: NIDS = (d+1)b 0 + d b 1 + (d-1)b 2 + … + 3 bd-2 +2 bd-1 + 1 bd = O(bd) For b = 10, d = 5, n n NDLS = 1 + 100 + 1, 000 + 100, 000 = 111, 111 NIDS = 6 + 50 + 400 + 3, 000 + 20, 000 + 100, 000 = 123, 450 32

Properties of iterative deepening search n n Complete? Yes Time? O(bd) Space? O(bd) Optimal?

Properties of iterative deepening search n n Complete? Yes Time? O(bd) Space? O(bd) Optimal? Yes, if step cost = 1 or increasing function of depth. 33

Bidirectional Search n Idea n n simultaneously search forward from S and backwards from

Bidirectional Search n Idea n n simultaneously search forward from S and backwards from G stop when both “meet in the middle” need to keep track of the intersection of 2 open sets of nodes What does searching backwards from G mean n need a way to specify the predecessors of G n n this can be difficult, e. g. , predecessors of checkmate in chess? which to take if there are multiple goal states? where to start if there is only a goal test, no explicit list? 34

Bi-Directional Search Complexity: time and space complexity are: 35

Bi-Directional Search Complexity: time and space complexity are: 35

Summary of algorithms Criterion Breadth- Uniform- Depth. First Cost First Depth. Limited Iterative Deepening

Summary of algorithms Criterion Breadth- Uniform- Depth. First Cost First Depth. Limited Iterative Deepening DLS Complete? Yes No No Yes Time O(bd) O(b. C*/ε) O(bm) O(bl) O(bd) Space O(bd) O(b. C*/ε) O(bm) O(bl) O(bd) Optimal? Yes No No Yes Generally the preferred uninformed search strategy 36

Repeated states n n Failure to detect repeated states can turn a linear problem

Repeated states n n Failure to detect repeated states can turn a linear problem into an exponential one! Test is often implemented as a hash table. 37

Solutions to Repeated States S B C State Space n Graph search n C

Solutions to Repeated States S B C State Space n Graph search n C C S B S Example of a Search Tree optimal but memory inefficient never generate a state generated before n n must keep track of all possible states (uses a lot of memory) e. g. , 8 -puzzle problem, we have 9! = 362, 880 states approximation for DFS/DLS: only avoid states in its (limited) memory: avoid looping paths. Graph search optimal for BFS and UCS, not for DFS. 38

Summary n n n Problem formulation usually requires abstracting away realworld details to define

Summary n n n Problem formulation usually requires abstracting away realworld details to define a state space that can feasibly be explored Variety of uninformed search strategies Iterative deepening search uses only linear space and not much more time than other uninformed algorithms http: //www. cs. rmit. edu. au/AI-Search/Product/ http: //aima. cs. berkeley. edu/demos. html (for more demos) 39