Lec 4 5 Uninformed Search II
Lec 4 5 Uninformed Search II
• If the solution is beneath the depth bound, the search cannot find the
goal (hence this search algorithm is incomplete).
Depth-Limited Search (DLS)
• Main idea:
• Expand node at the deepest level, but limit depth to D.
• Implementation:
• Enqueue nodes in LIFO (last-in, first-out) order. But limit depth to D
• Complete?
• No
• Yes: if there is a goal state at a depth less than D
• Optimal?
• No
• Time Complexity:
• , where D is the cutoff.
• Space Complexity:
• , where D is the cutoff.
Iterative Deepening Search
• To avoid the infinite depth problem of DFS:
• Only search until depth L
• i.e, don’t expand nodes beyond depth L
• Depth-Limited Search
• What if solution is deeper than L?
• Increase depth iteratively
• Iterative Deepening Search
• IDS
• Inherits the memory advantage of depth-first search
• Has the completeness property of breadth-first search
Iterative deepening search l =0
6
6
Iterative deepening search l =1
7
7
Iterative deepening search l =2
8
8
Iterative deepening search l =3
9
9
Depth Bound = 0
Depth Bound = 1
Depth Bound = 1
Depth 2
Properties of Iterative Deepening
Search
• Complete? Yes (in finite spaces)
• Time? O(bd)
• Space? O(bd)
20
20
Example A
D B
Do it on notebook F E
C
• Start Node: A
G B
G E
• Goal Node: G
Step Frontier Expand[*] Explored: a set of nodes
21
Iterative Deepening Search
• Idea: get DFS’s space advantage with b
BFS’s time / shallow-solution advantages …
• Run a DFS with depth limit 1. If no solution…
• Run a DFS with depth limit 2. If no solution…
• Run a DFS with depth limit 3. …..
d 3 e 9 p 1
b 4 c e 5 h 1 r 1 q 1
1 7 1 6
Cost a 6 a 1h 1 r 7 p q f
contou 3
rs p q f 8 q c G
q 1 c G 1 a
1 0
a
Uniform Cost Search
(UCS)
A
5 2
[5] B C [2]
1 4 1 7
D
[6] [3] F G [9]
Goal state
[9] E
4 5
[x] = g(n) [7] H I [8]
path cost of node n
29
Uniform Cost Search (UCS)
A
5 2
[5] B C [2]
30
Uniform Cost Search (UCS)
A
5 2
[5] B C [2]
1 7
[3] F G [9]
31
Uniform Cost Search (UCS)
A
5 2
[5] B C [2]
1 7
[3] F G [9]
4 5
[7] H I [8]
32
Uniform Cost Search (UCS)
A
5 2
[5] B C [2]
1 4 1 7
D
[6] [3] F G [9]
[9] E
4 5
[7] H I [8]
33
Uniform Cost Search (UCS)
A
5 2
[5] B C [2]
Goal state 1
4 1 7
path cost
g(n)=[6] D [3] F G [9]
[9] E
4 5
[7] H I [8]
34
Uniform Cost Search (UCS)
A
5 2
[5] B C [2]
1 4 1 7
D
[6] [3] F G [9]
[9] E
4 5
[7] H I [8]
35
• Start Node: A
• Goal Node: G
Step Frontier Expand[*] Explored: a set of nodes
1 {(A,0)} A ∅
2 {(A-D,3),(A-B,5)} D {A}
3 {(A-B,5),(A-D-E,5),(A-D-F,5)} B {A,D}
4 {(A-D-E,5),(A-D-F,5),(A-B-C,6)} E {A,D,B}
5 {(A-D-F,5),(A-B-C,6)}[*] F {A,D,B,E}
6 {(A-B-C,6),(A-D-F-G,8)} C {A,D,B,E,F}
7 (A-D-F-G,8)} G {A,D,B,E,F,C}
8 ∅
• Is it complete?
• Assuming best solution has a finite cost and minimum
arc cost is positive, yes!
• Is it optimal?
• Yes! (Proof next lecture via A*)
Uniform Cost Issues
… c1
• Remember: UCS explores increasing cost contours c2
c3
• The bad:
• Explores options in every “direction”
• No information about goal location
Start Goal
• 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.
Frontier Expand Explored
1 S S Empty
2 (S-C,1) (S-B,2)(S-A,3) C S
3 (S-B,2)(S-A,3)(S-C-G,21) B S,C
4 (S-A,3)(S-C-G,21)(S-B-E,6) A S,C,B
5 (S-C-G,21)(S-B-E,6)(S-A-D,9) E S,C,B,A
6 (S-C-G,21) (S-A-D,9) (S-B-E-G,14) D S,C,B,A,E
7 (S-C-G,21) (S-B-E-G,14) (S-A-D-F,10) F S,C,B,A,E,D
8 (S-C-G,21) (S-B-E-G,14) (S-A-D-F-G,11)
9 S-A-D-F-G,11 Goal Found S,C,B,A,E,D,F,G
Step Frontier Expand Explored: a set of Nodes
1
(S,0) S Ø
2
(S-C,2) (S-D,2) (S-A,3) C S
3
(S-D,2) (S-A,3)(S-C-F,3) D S,C
4
(S-A,3)(S-C-F,3)(S-D-B,5)(S-D-G,10) A S,C,D
5
(S-C-F,3)(S-D-B,5)(S-D-G,10) F S,C,D,A
6
(S-D-B,5)(S-D-G,10)(S-C-F-E,3)(S-C-F-G,7) E S,C,D,A,F
7
(S-D-B,5)(S-D-G,10) (S-C-F-G,7) (S-C-F-E-G,5) B S,C,D,A,F,E
8
(S-D-G,10) (S-C-F-G,7) (S-C-F-E-G,5)(S-D-B-E,7) G S,C,D,A,F,E,B
9
(S-C-F-E-G,5) Goal Found
Bidirectional Search
• Idea
• 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
• need a way to specify the predecessors of G
• this can be difficult,
• e.g., predecessors of checkmate in chess?
• what if there are multiple goal states?
• what if there is only a goal test, no explicit list?
• Complexity
• Time complexity is best:
• memory complexity is the same
Bidirectional Search
Summary of Algorithms
b branching factor
d depth of the shallowest solution
m maximum depth of the search tree
l depth limit
Superscripts:
a complete if b is finite
b complete if step costs ≥ epsilon for +ve epsilon
c optimal if step costs are all identical 47
47
Summary of Algorithms