Ch 03
Problem Solving
1
Prof. Poonam Narkhede
Measuring Performance of Problem Solving
Agent
2
Factors for evaluating performance:
[Link]
[Link]
[Link] Complexity
[Link] Complexity
Complexity is expressed in terms of 3
quantities:
1.b: Branching factor
2.d: depth of goal
3.m: Maximum depth in search tree
CMPT 310 - Blind Search
Node representation in search tree
3
Fig 3.1 Node Representation
State/ Value
Parent Node
Number of Child
Path cost
Uninformed search strategies
4
Uninformed search strategies use only the
information available in the problem definition
Breadth-first search
Depth-first search
Uniform cost search
Depth-limited search
Iterative deepening search
Breadth-first search
5
Expand shallowest unexpanded node
Implementation:
Frontier or fringe is a FIFO queue, i.e., new
successors go at end
CMPT 310 - Blind Search
Breadth-first search
6
Expand shallowest unexpanded node
Implementation:
frontier is a FIFO queue, i.e., new successors go at
end
CMPT 310 - Blind Search
Breadth-first search
7
Expand shallowest unexpanded node
Implementation:
frontier is a FIFO queue, i.e., new successors go at
end
CMPT 310 - Blind Search
Breadth-first search
8
Expand shallowest unexpanded node
Implementation:
frontier is a FIFO queue, i.e., new successors go at
end
CMPT 310 - Blind Search
Properties of breadth-first
search
9
Complete? Time? Space?Optimal?
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)
CMPT 310 - Blind Search
Depth-first search
10
Expand deepest unexpanded node
Implementation:
frontier = LIFO queue, i.e., put successors at
front
CMPT 310 - Blind Search
Depth-first search
11
Expand deepest unexpanded node
Implementation:
frontier = LIFO queue, i.e., put successors at
front
CMPT 310 - Blind Search
Depth-first search
12
Expand deepest unexpanded node
Implementation:
frontier = LIFO queue, i.e., put successors at
front
CMPT 310 - Blind Search
Depth-first search
13
Expand deepest unexpanded node
Implementation:
frontier = LIFO queue, i.e., put successors at
front
CMPT 310 - Blind Search
Depth-first search
14
Expand deepest unexpanded node
Implementation:
frontier = LIFO queue, i.e., put successors at
front
CMPT 310 - Blind Search
Depth-first search
15
Expand deepest unexpanded node
Implementation:
frontier = LIFO queue, i.e., put successors at
front
CMPT 310 - Blind Search
Depth-first search
16
Expand deepest unexpanded node
Implementation:
frontier = LIFO queue, i.e., put successors at
front
CMPT 310 - Blind Search
Depth-first search
17
Expand deepest unexpanded node
Implementation:
frontier = LIFO queue, i.e., put successors at
front
CMPT 310 - Blind Search
Depth-first search
18
Expand deepest unexpanded node
Implementation:
frontier = LIFO queue, i.e., put successors at
front
CMPT 310 - Blind Search
Depth-first search
19
Expand deepest unexpanded node
Implementation:
frontier = LIFO queue, i.e., put successors at
front
CMPT 310 - Blind Search
Depth-first search
20
Expand deepest unexpanded node
Implementation:
frontier = LIFO queue, i.e., put successors at
front
CMPT 310 - Blind Search
Depth-first search
21
Expand deepest unexpanded node
Implementation:
frontier = LIFO queue, i.e., put successors at
front
CMPT 310 - Blind Search
Properties of depth-first search
22
Complete? Time? Space?Optimal?
Complete? No: fails in infinite-depth spaces, spaces with
loops
Modify to avoid repeated states along path (graph search)
complete in finite spaces
Time? O(bm): terrible if maximum depth m is much larger
than solution depth d
but if solutions are dense, may be much faster than breadth-first
Space? O(bm), i.e., linear space! Store single path with
unexpanded siblings.
Seems to be common in animals and humans.
Optimal? No.
Important for exploration (on-line search).
CMPT 310 - Blind Search
Uniform Cost Search (UCS)
23
BFS with same path cost.
Optimal with any path cost.
Nosed with lowest path cost will expand first.
Implementation:
Based on priority queue
Priority queue is maintained based on path cost
Node with greater cost never expand
Nodes in queue have same cost thus name “UCS”
CMPT 310 - Blind Search
Properties of Uniform cost search
24
Complete? Time? Space?Optimal?
Complete? Yes with cost
Time? O(bc*/ε*)
Space? O(bc*/ε*)
Optimal? Yes in order with their path cost
CMPT 310 - Blind Search
Depth-limited search
25
depth-first search with depth limit l,
i.e., nodes at depth l have no successors
Solves infinite loop problem
Common AI strategy: let user choose search/resource bound.
Time? O(bl):
Space? O(bl), i.e., linear space!
Optimal? No if l > b
Complete? No if l < d:
CS 3243 - Blind Search
Iterative deepening search
26
CMPT 310 - Blind Search
Iterative deepening search l =0
27
CMPT 310 - Blind Search
Iterative deepening search l =1
28
CMPT 310 - Blind Search
Iterative deepening search l =2
29
CMPT 310 - Blind Search
Iterative deepening search l =3
30
CMPT 310 - Blind Search
Properties of iterative deepening
search
31
Complete? Yes
Time? (d+1)b0 + d b1 + (d-1)b2 + … + bd =
O(bd)
Space? O(bd)
Optimal? Yes, if step cost = 1
CMPT 310 - Blind Search
Summary of algorithms
32
CMPT 310 - Blind Search
Difference between BFS and DFS
33
Sr. No. BFS DFS
1 Breadth First search Depth First search
2 Traverse Branch level Traverse Depth wise
3 Uses FIFO Uses LIFO
4 Single step algorithm Two step algorithm
5 More memory space compare Less memory space compare
to DFS to DFS
6 Shallowest path solution Does not guarantee
7 No backtracking Backtracking
8 Optimal and complete Neither optimal not complete
9 No infinite loop Stucked in infinite loop
10 Applications: Shortest path, Applications: Connectivity
Spanning tree testing, cycle detection
11 E.g E.g
34
CMPT 310 - Blind Search