0% found this document useful (0 votes)
12 views

Lec 4 5 Uninformed Search II

Uploaded by

wyneharis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Lec 4 5 Uninformed Search II

Uploaded by

wyneharis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 45

Uninformed Search-II

Depth First Search and its Variants


Previous Lecture
• Breadth First Search (BFS)
• Uniform Cost Search (UCS)
Depth-Limited Search (DLS)
• DFS with a depth bound
• Searching is not permitted beyond the depth bound.

• Works well if we know what is the depth of the solution.

• 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)

• Optimal? Yes, (if step cost = 1 i.e. identical step cost)

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. …..

• Isn’t that wastefully redundant?


• Generally most work happens in the lowest
level searched, so not so bad!
Uniform Cost Search
Uniform Cost Search
• Breadth-First Search find the shallowest goal state, but this may not
always be the least-cost solution.
• Uniform-Cost Search modifies the Breadth-First Search strategy by
always expanding the lowest path cost g(n) node on the fringe.
• Frontier is a priority queue, i.e., new successors are merged into the
queue sorted by g(n).
• Can remove successors already on queue w/higher g(n).
• Saves memory, costs time; another space-time trade-off.
Uniform Cost Search
2 a G
Strategy: expand a b c
cheapest node first: 1 8 2
2 e
3 d
Fringe is a priority 9 2 f
S h 8
queue (priority: 1
cumulative cost) 1 p q r
1
5
S 0

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 ∅

• Found the path: A -> D -> F -> G.


36
• *B is not added to the frontier because it is found in the explored set.
Uniform Cost Search
Uniform Cost Search
Uniform Cost Search
Uniform Cost Search (UCS)
Properties
• What nodes does UCS expand?
b c1
• Processes all nodes with cost less than cheapest …
solution! c2
C*/ “tiers”
• If that solution costs C* and arcs cost at least  , then the
c3
“effective depth” is roughly C*/
• Takes time O(bC*/) (exponential in effective depth)

• How much space does the fringe take?


• Has roughly the last tier, so O(bC*/)

• 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
… c1
• Remember: UCS explores increasing cost contours c2
c3

• The good: UCS is complete and optimal!

• The bad:
• Explores options in every “direction”
• No information about goal location
Start Goal

• We’ll fix that soon!


Uniform Cost Search

• 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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy