AI Lecture 4
AI Lecture 4
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
2
1 January 2013
Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end
1 January 2013
Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end
1 January 2013
Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end
1 January 2013
Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end
1 January 2013
1 January 2013
1 January 2013
We can have search graphs (instead of trees) Hence paths can go backwards, ABCB Can get paths with loops ABCDB 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.
9
1 January 2013
1 January 2013
11
A
1 10
S
15
B
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 with ourfromexpandedfront removed fromnode A. Press space to to Node Astart B has theinitial statequeue and the revealed nodes are added to the We now expand been the queue and the revealed node (node G) the revealed Node is removed node at the it is of the queue, the queue and is added We S is removed from the and expand node (nodeTheis added. again sorted path cost. Nodes withcost. Note, found G theit The queue isis Thesorted on on path cost. Note, we cheaper path cost have continue. G) queue then queue is again sorted on path have now node a queue. queue. now state but do not recognise it once is not atand front as G11.followed by node goal appears in the queue twice,will beas G10Athe once of the queue.10 is atB is C priority.In this case the queue as it Node (1), node B (5), As G Node the front of Press space. now proceed to goal state. Press space. the cheaper node. Press space. (15). the queue, we
A
5 5
10
S
15
C
Size of Queue: 0 3 1 Nodes expanded: 0 3 2 1 Queue: A,10, 11,11, C15 G B, G C S B,G Empty C
The goal state is achieved and the path S-B-G is returned. In relation to path cost, UCS has found the optimal route.
1 January 2013
14
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
15
1 January 2013
Expand deepest unexpanded node Implementation: fringe is a LIFO queue, i.e., put successors in the front
1 January 2013
16
Expand deepest unexpanded node Implementation: fringe is a LIFO queue, i.e., put successors in the front
1 January 2013
17
Expand deepest unexpanded node Implementation: fringe is a LIFO queue, i.e., put successors in the front
1 January 2013
18
Expand deepest unexpanded node Implementation: fringe is a LIFO queue, i.e., put successors in the front
1 January 2013
19
Expand deepest unexpanded node Implementation: fringe is a LIFO queue, i.e., put successors in the front
1 January 2013
20
Expand deepest unexpanded node Implementation: fringe is a LIFO queue, i.e., put successors in the front
1 January 2013
21
Expand deepest unexpanded node Implementation: fringe is a LIFO queue, i.e., put successors in the front
1 January 2013
22
1 January 2013
Depth-first search with depth limit l, i.e., nodes at depth l have no successors Recursive implementation:
1 January 2013
25
Space? O(bl)
Depth-first is a special case of depth-limited with l being infinite.
1 January 2013
26
1 January 2013
27
1 January 2013
28
1 January 2013
29
1 January 2013
30
1 January 2013
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, 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%
32
1 January 2013
Complete? Yes Time? (d+1)b0 + d b1 + (d-1)b2 + + bd = O(bd) Space? O(bd) Optimal? Yes, if step cost = 1
1 January 2013
33
1 January 2013
34
1 January 2013
35