AI Lecture 4
AI Lecture 4
AI Lecture 4
Breadth-first search
Uniform-cost search
Depth-first search
Depth-limited search
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.
Once
Node
WeNode
Wenow
A
node
start
is
Sexpand
removed
isBwith
removed
hasour
the
been
from
initial
node
from
expanded
the
state
at
the
queue
the
queue
and
front
it and
is
expand
and
removed
ofthe
the
the
revealed
queue,
revealed
fromnode
the
node
nodes
queue
A.
(node
Press
areand
G)added
space
the
is added
revealed
totothe
to
the
node
continue.
queue.
it…
queue.
(node The
The
G)queue
isqueue
added.
isisthen
The
again
sorted
queue
sortedonisonpath
again
path
cost.
sorted
cost.
Nodes
Note,
on path
with
wecost.
cheaper
haveNote,now path
found
node cost
Ga have
goal
nowpriority.In
appears
state but this
indothe
case
notqueue
recognise
the queue
twice,itwill
once
as beit is
as
Node
not
G10atAand
the
(1),once
front
nodeof
asBthe
G(5),
11queue.
. followed
As G10 Node
isbyatnode
Bthe
is C
the(15).
frontcheaper
of Press
the queue,
node.
space. Press
we now space.
proceed to goal state. Press space.
A
1 10
5 5
S B G
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
Time? O(bl)
Space? O(bl)
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%
September 24, 2023 32
Complete? Yes
Space? O(bd)