0% found this document useful (0 votes)
26 views34 pages

AI Lecture 4

Uploaded by

dabaci3568
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)
26 views34 pages

AI Lecture 4

Uploaded by

dabaci3568
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/ 34

Lecture 4 – Uninformed Search

November 7, 2024 1
 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

November 7, 2024 2
 Expand shallowest unexpanded node
 Implementation:
 fringe is a FIFO queue, i.e., new successors go
at end

November 7, 2024 3
 Expand shallowest unexpanded node
 Implementation:
 fringe is a FIFO queue, i.e., new successors go
at end

November 7, 2024 4
 Expand shallowest unexpanded node
 Implementation:
 fringe is a FIFO queue, i.e., new successors go
at end

November 7, 2024 5
 Expand shallowest unexpanded node
 Implementation:
 fringe is a FIFO queue, i.e., new successors go
at end

November 7, 2024 6
November 7, 2024 7
 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).
November 7, 2024 8
 We can have search graphs (instead of trees)
 Hence paths can go backwards, ABCB
 Can get paths with loops ABCDB

 We can also have multiple paths to a node


 From them, we are interested in the min-cost
path

 The Loop problem is that we “rediscover” nodes


that the search has already discovered

 Need to consider methods to suppress nodes that


have already been visited.

November 7, 2024 9
November 7, 2024 11
Consider the following
problem…

A
1 10

5 5
S B G

15 5
C

We wish to find the shortest route from node S to node G; that is, node S is the
initial state and node G is the goal state. In terms of path cost, we can clearly
see that the route SBG is the cheapest route. However, if we let breadth-first
search loose on the problem it will find the non-optimal path SAG, assuming
that A is the first node to be expanded at level 1.
We start with our initial state and expand
it… Node S is removed from the queue and the revealed nodes are added to the
queue. The queue is then sorted on path cost. Nodes with cheaper path cost hav
priority.In this case the queue will be Node A (1), node B (5), followed by node C
(15). Press space.
A 10
1

5 5
S B G

The goal state is achieved and the


15 path S-B-G is returned. In relation
C to path cost, UCS has found the
optimal route.

Size of Queue: 0
1
3 Queue: Empty
S 10G
A,
B,
G B,
, 11
GC,11C, C15

Nodes expanded: 3
0
1
2 CurrentFINISHED
action: Expanding
Waiting….
Backtracking
SEARCH Current level: 2
n/a
0
1

UNIFORM COST SEARCH PATTERN


November 7, 2024 14
 Expand least-cost unexpanded node
 Implementation:
 fringe = queue ordered by path cost
 Equivalent to breadth-first if step costs all equal
 Complete? Yes, if step cost ≥ ε
 Time? O(bceiling(C*/ ε)) where C* is the cost of the
optimal solution
 Space? O(bceiling(C*/ ε))
 Optimal? Yes – given the condition of
completeness – you always expand the node
with lowest cost
 O(bceiling(C*/ ε)) can be greater than Ob/d

November 7, 2024 15
 Expand deepest unexpanded node
 Implementation:
 fringe is a LIFO queue, i.e., put successors in
the front

November 7, 2024 16
 Expand deepest unexpanded node
 Implementation:
 fringe is a LIFO queue, i.e., put successors in
the front

November 7, 2024 17
 Expand deepest unexpanded node
 Implementation:
 fringe is a LIFO queue, i.e., put successors in
the front

November 7, 2024 18
 Expand deepest unexpanded node
 Implementation:
 fringe is a LIFO queue, i.e., put successors in
the front

November 7, 2024 19
 Expand deepest unexpanded node
 Implementation:
 fringe is a LIFO queue, i.e., put successors in
the front

November 7, 2024 20
 Expand deepest unexpanded node
 Implementation:
 fringe is a LIFO queue, i.e., put successors in
the front

November 7, 2024 21
 Expand deepest unexpanded node
 Implementation:
 fringe is a LIFO queue, i.e., put successors in
the front

November 7, 2024 22
 Complete? No: fails in infinite-depth
spaces, spaces with loops
 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

November 7, 2024 23
 Depth-first search with depth limit l, i.e., nodes
at depth l have no successors
 Recursive implementation:

November 7, 2024 25
 Complete? NO. Why? (l < d OR l > d)

 Time? O(bl)

 Space? O(bl)

 Depth-first is a special case of depth-limited


with l being infinite.

November 7, 2024 26
November 7, 2024 27
November 7, 2024 28
November 7, 2024 29
November 7, 2024 30
November 7, 2024 31
 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 b1 + (d-1)b2 + … + 3bd-2
+2bd-1 + 1bd
 For b = 10, d = 5,
N
DLS = 1 + 10 + 100 + 1,000 + 10,000 +
100,000 = 111,111
N
IDS = 6 + 50 + 400 + 3,000 + 20,000 +
100,000 = 123,456
 Overhead = (123,456 - 111,111)/111,111 =
11%
November 7, 2024 32
 Complete? Yes

 Time? (d+1)b0 + d b1 + (d-1)b2 + … + bd = O(bd)

 Space? O(bd)

 Optimal? Yes, if step cost = 1

November 7, 2024 33
November 7, 2024 34
November 7, 2024 35

You might also like