Presentation is loading. Please wait.

Presentation is loading. Please wait.

Artificial Intelligence

Similar presentations


Presentation on theme: "Artificial Intelligence"— Presentation transcript:

1 Artificial Intelligence
Lecture 4 – Uninformed Search Dr. Muhammad Adnan Hashmi 6 December 2018

2 Uninformed Search Strategies
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 6 December 2018 2

3 Breadth-first search Expand shallowest unexpanded node Implementation:
fringe is a FIFO queue, i.e., new successors go at end 6 December 2018 3

4 Breadth-first search Expand shallowest unexpanded node Implementation:
fringe is a FIFO queue, i.e., new successors go at end 6 December 2018 4

5 Breadth-first search Expand shallowest unexpanded node Implementation:
fringe is a FIFO queue, i.e., new successors go at end 6 December 2018 5

6 Breadth-first search Expand shallowest unexpanded node Implementation:
fringe is a FIFO queue, i.e., new successors go at end 6 December 2018 6

7 Breadth-first search 6 December 2018 7

8 Properties of Breadth-first search
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). 6 December 2018 8

9 Preventing Loopy Paths
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. 6 December 2018 9

10 Uniform-Cost Search 6 December 2018 11

11 A S B G C 10 1 5 5 5 15 Consider the following problem…
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.

12 Once node B has been expanded it is removed from the queue and the revealed node (node G) is added. The queue is again sorted on path cost. Note, node G now appears in the queue twice, once as G10 and once as G11. As G10 is at the front of the queue, we now proceed to goal state. Press space. Node A is removed from the queue and the revealed node (node G) is added to the queue. The queue is again sorted on path cost. Note, we have now found a goal state but do not recognise it as it is not at the front of the queue. Node B is the cheaper node. Press space. We now expand the node at the front of the queue, node A. Press space to continue. 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 have priority.In this case the queue will be Node A (1), node B (5), followed by node C (15). Press space. We start with our initial state and expand it… A A 10 1 5 5 S S B B G G G G G G The goal state is achieved and the path S-B-G is returned. In relation to path cost, UCS has found the optimal route. 15 C Size of Queue: 3 Size of Queue: 0 Size of Queue: 1 Size of Queue: 0 Queue: G10, G11, C15 Queue: B, G11, C Queue: Empty Queue: S Queue: A, B, C Queue: Empty Nodes expanded: 3 Nodes expanded: 1 Nodes expanded: 2 Nodes expanded: 0 Current action: Waiting…. Current action: Expanding FINISHED SEARCH Current action: Expanding Current action: Backtracking Current level: 1 Current level: n/a Current level: 0 Current level: 0 Current level: 2 Current level: 1 UNIFORM COST SEARCH PATTERN

13 Uniform-Cost Search 6 December 2018 14

14 Uniform-Cost Search 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 6 December 2018 15

15 Depth-first search Expand deepest unexpanded node Implementation:
fringe is a LIFO queue, i.e., put successors in the front 6 December 2018 16

16 Depth-first search Expand deepest unexpanded node Implementation:
fringe is a LIFO queue, i.e., put successors in the front 6 December 2018 17

17 Depth-first search Expand deepest unexpanded node Implementation:
fringe is a LIFO queue, i.e., put successors in the front 6 December 2018 18

18 Depth-first search Expand deepest unexpanded node Implementation:
fringe is a LIFO queue, i.e., put successors in the front 6 December 2018 19

19 Depth-first search Expand deepest unexpanded node Implementation:
fringe is a LIFO queue, i.e., put successors in the front 6 December 2018 20

20 Depth-first search Expand deepest unexpanded node Implementation:
fringe is a LIFO queue, i.e., put successors in the front 6 December 2018 21

21 Depth-first search Expand deepest unexpanded node Implementation:
fringe is a LIFO queue, i.e., put successors in the front 6 December 2018 22

22 Properties of Depth-first search
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 6 December 2018 23

23 BFS or DFS

24 Depth-limited search Recursive implementation: 6 December 2018 25

25 Depth-Limited Search 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. 6 December 2018 26

26 Iterative deepening search
6 December 2018 27 27

27 Iterative deepening search l =0
6 December 2018 28

28 Iterative deepening search l =1
6 December 2018 29

29 Iterative deepening search l =2
6 December 2018 30

30 Iterative deepening search l =3
6 December 2018 31

31 Iterative Deepening search
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 = , , ,000 = 111,111 NIDS = , , ,000 = 123,456 Overhead = (123, ,111)/111,111 = 11% 6 December 2018 32

32 Properties of iterative deepening search
Complete? Yes Time? (d+1)b0 + d b1 + (d-1)b2 + … + bd = O(bd) Space? O(bd) Optimal? Yes, if step cost = 1 6 December 2018 33

33 Summary of Algorithms 6 December 2018 34

34 Questions 6 December 2018 35 35


Download ppt "Artificial Intelligence"

Similar presentations


Ads by Google