0% found this document useful (0 votes)
73 views

AI Lecture 4

The document discusses different uninformed search strategies including breadth-first search, uniform-cost search, depth-first search, depth-limited search, and iterative deepening search. It provides details on the implementation, completeness, time and space complexity of each strategy.

Uploaded by

Arsalan Ahmed
Copyright
© Attribution Non-Commercial (BY-NC)
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)
73 views

AI Lecture 4

The document discusses different uninformed search strategies including breadth-first search, uniform-cost search, depth-first search, depth-limited search, and iterative deepening search. It provides details on the implementation, completeness, time and space complexity of each strategy.

Uploaded by

Arsalan Ahmed
Copyright
© Attribution Non-Commercial (BY-NC)
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

Dr. Muhammad Adnan Hashmi


1 January 2013

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

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).
8

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

Consider the following problem

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.

Current action: Waiting. FINISHED SEARCH Backtracking Expanding

Current level: n/a 2 1 0

UNIFORM COST SEARCH PATTERN

1 January 2013

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
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

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


23

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

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.

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

You might also like