0% found this document useful (0 votes)
119 views39 pages

Lecture 3 - Uninformed Search II

The document discusses several uninformed search strategies for solving problems by searching state spaces. It describes breadth-first search, uniform-cost search, depth-first search, depth-limited search, and iterative deepening search. For each strategy, it covers properties like completeness, time complexity, space complexity, and optimality. It also provides examples and analysis of depth-first search and iterative deepening search. Finally, it introduces the concept of bidirectional search, which simultaneously searches forward from the starting state and backward from the goal state.

Uploaded by

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

Lecture 3 - Uninformed Search II

The document discusses several uninformed search strategies for solving problems by searching state spaces. It describes breadth-first search, uniform-cost search, depth-first search, depth-limited search, and iterative deepening search. For each strategy, it covers properties like completeness, time complexity, space complexity, and optimality. It also provides examples and analysis of depth-first search and iterative deepening search. Finally, it introduces the concept of bidirectional search, which simultaneously searches forward from the starting state and backward from the goal state.

Uploaded by

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

Solving problems by searching

Chapter 3

3/4/2020 CS 3243 - Blind Search 1


Search strategies
 A search strategy is defined by picking the order of node
expansion
 Strategies are evaluated along the following dimensions:
 completeness: does it always find a solution if one exists?
 time complexity: number of nodes generated
 space complexity: maximum number of nodes in memory
 optimality: does it always find a least-cost solution?

 Time and space complexity are measured in terms of


 b: maximum branching factor of the search tree
 d: depth of the least-cost solution
 m: maximum depth of the state space (may be ∞)

3/4/2020 CS 3243 - Blind Search 2


Uninformed search strategies
 Uninformed search strategies use only the information available in the problem
definition
 Breadth-first search
 Uniform-cost search
 Depth-first search
 Depth-limited search
 Iterative deepening search

3/4/2020 CS 3243 - Blind Search 3


Breadth-first search
 Expand shallowest unexpanded node
 Implementation:
 USE is a FIFO queue, i.e., new successors go at
end

3/4/2020 CS 3243 - Blind Search 4


Breadth-first search
 Expand shallowest unexpanded node

 Implementation:
 fringe is a FIFO queue, i.e., new successors go
at end

3/4/2020 CS 3243 - Blind Search 5


Breadth-first search
 Expand shallowest unexpanded node

 Implementation:
 fringe is a FIFO queue, i.e., new successors go
at end

3/4/2020 CS 3243 - Blind Search 6


Breadth-first search
 Expand shallowest unexpanded node

 Implementation:
 fringe is a FIFO queue, i.e., new successors go at end

3/4/2020 CS 3243 - Blind Search 7


Properties of breadth-first search
 Complete? Yes (if b is finite)
 Time? 1+b+b2+b3+… +bd + b(bd-1) = O(bd+1)
 Space? O(bd+1) (keeps every node in memory)
 Optimal? Yes (if cost = 1 per step)
 Space is the bigger problem (more than time)

3/4/2020 CS 3243 - Blind Search 8


Uniform Cost Search
3/4/2020 CS 3243 - Blind Search 10
Optimality of Uniform Cost Search?
 Assume that every step costs at least e > 0

 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 in a finite number of steps.

 Proof of Optimality given Completeness:


 Assume UCS is not optimal.
 Then there must be a goal state with path cost smaller than the goal state which was found
(invoking completeness)
 However, this is impossible because UCS would have expanded that node first by definition.
 Contradiction.
Complexity of Uniform Cost
 Let C* be the cost of the optimal solution

 Assume that every step costs at least e > 0

 Worst-case time and space complexity is:

O( b [1 + floor(C*/e)] )

Why?
floor(C*/e) ~ depth of solution if all costs are
approximately equal
Uniform-cost search
 Expand least-cost unexpanded node
 Implementation:
queue ordered by path cost
 Equivalent to breadth-first if step costs all equal
 Complete? Yes, if step cost ≥ ε
 Time? # of nodes with g ≤ cost of optimal solution, O(b ceiling(C*/ ε))
where C* is the cost of the optimal solution
 Space? #of nodes with g ≤ cost of optimal solution, O(bceiling(C*/ ε))
 Optimal? Yes – nodes expanded in increasing order of g(n)

3/4/2020 CS 3243 - Blind Search 13


Depth-first search
 Expand deepest unexpanded node
 Implementation:
LIFO queue, i.e., put successors at front

3/4/2020 CS 3243 - Blind Search 14


Depth-first search
 Expand deepest unexpanded nodeLIFO queue, i.e.,
put successors at front

3/4/2020 CS 3243 - Blind Search 15


Depth-first search
 Expand deepest unexpanded node
 Implementation:
LIFO queue, i.e., put successors at front

3/4/2020 CS 3243 - Blind Search 16


Depth-first search
 Expand deepest unexpanded node

3/4/2020 CS 3243 - Blind Search 17


Depth-first search
 Expand deepest unexpanded node

3/4/2020 CS 3243 - Blind Search 18


Depth-first search
 Expand deepest unexpanded node

3/4/2020 CS 3243 - Blind Search 19


Depth-first search
 Expand deepest unexpanded node

3/4/2020 CS 3243 - Blind Search 20


Depth-first search
 Expand deepest unexpanded node

3/4/2020 CS 3243 - Blind Search 21


Depth-first search
 Expand deepest unexpanded node

3/4/2020 CS 3243 - Blind Search 22


Depth-first search
 Expand deepest unexpanded node

3/4/2020 CS 3243 - Blind Search 23


Depth-first search
 Expand deepest unexpanded node

3/4/2020 CS 3243 - Blind Search 24


Depth-first search
 Expand deepest unexpanded node

3/4/2020 CS 3243 - Blind Search 25


Examples of Time and Memory Requirements for Depth-First
Search

Assuming b=10, m = 12, 10000 nodes/sec, 1kbyte/node

Depth of Nodes
Solution Generated Time Memory

2 1012 3 years 120kb

4 1012 3 years 120kb

8 1012 3 years 120kb

12 1012 3 years 120kb


Properties of depth-first search
 Complete? No: fails in infinite-depth spaces, spaces with loops
 Modify to avoid repeated states along path
  complete in finite spaces
 Time? O(bm): terrible if m is much larger than d
 but if solutions are dense, may be much faster than breadth-first
 Space? O(bm), i.e., linear space!
 Optimal? No

3/4/2020 CS 3243 - Blind Search 27


Depth-limited search
= depth-first search with depth limit l,
i.e., nodes at depth l have no successors

implementation:

3/4/2020 CS 3243 - Blind Search 28


DFS with a depth-limit L
 Standard DFS, but tree is not explored below some depth-limit L

 Solves problem of infinitely deep paths with no solutions


 But will be incomplete if solution is below depth-limit

 Depth-limit L can be selected based on problem knowledge


 E.g., diameter of state-space:
 E.g., max number of steps between 2 cities

 But typically not known ahead of time in practice


Iterative deepening search

3/4/2020 CS 3243 - Blind Search 30


Iterative deepening search l =0

3/4/2020 CS 3243 - Blind Search 31


Iterative deepening search l =1

3/4/2020 CS 3243 - Blind Search 32


Iterative deepening search l =2

3/4/2020 CS 3243 - Blind Search 33


Iterative deepening search l =3

3/4/2020 CS 3243 - Blind Search 34


Iterative deepening search
 Number of nodes generated in a depth-limited search to depth d with branching
factor b:
NDLS = b0 + b1 + b2 + … + bd-2 + bd-1 + bd

 Number of nodes generated in an iterative deepening search to depth d with


branching factor b:
NIDS = (d+1)b0 + d b^1 + (d-1)b^2 + … + 3bd-2 +2bd-1 + 1bd

 For b = 10, d = 5,
 NDLS = 1 + 10 + 100 + 1,000 + 10,000 + 100,000 = 111,111
 NIDS = 6 + 50 + 400 + 3,000 + 20,000 + 100,000 = 123,456

 Overhead = (123,456 - 111,111)/111,111 = 11%

3/4/2020 CS 3243 - Blind Search 35


Properties of iterative
deepening search
 Complete? Yes

 Time?

 Space? O(bd)
 Optimal? Yes, if step cost = 1

3/4/2020 CS 3243 - Blind Search 36


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 at best is: O(2 b(d/2)) = O(b (d/2))

 memory complexity is the same


Bi-Directional Search
Summary of algorithms

3/4/2020 CS 3243 - Blind Search 39

You might also like