15699 exhaustive search

Post on 13-May-2017

226 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Blind search

• Types of Blind search :

– Breadth first search– Depth first search– Depth first iterative deepening(DFID)– Bidirectional search

Breadth first search

• Expands all the states one step away from the first state, expands two steps away from the start state and so on. Until a goal state is reached.

• Implemented using two steps– OPEN list- those states that are to be expanded– CLOSED lists- those states that are already

expanded.

Breadth First Search

3

Application1: Given the following state space (tree search), give the sequence of visited nodes when using BFS (assume that the nodeO is the goal state):

A

B C ED

F G H I J

K L

O

M N

Breadth First Search

4

A,

A

B C ED

Breadth First Search

5

A, B,

A

B C ED

F G

Breadth First Search

6

A, B,C

A

B C ED

F G H

Breadth First Search

7

A, B,C,D

A

B C ED

F G H I J

Breadth First Search

8

A, B,C,D,E

A

B C ED

F G H I J

Breadth First Search

9

A, B,C,D,E, F,

A

B C ED

F G H I J

Breadth First Search

10

A, B,C,D,E, F,G

A

B C ED

F G H I J

K L

Breadth First Search

11

A, B,C,D,E, F,G,H

A

B C ED

F G H I J

K L

Breadth First Search

12

A, B,C,D,E, F,G,H,I

A

B C ED

F G H I J

K L M

Breadth First Search

13

A, B,C,D,E, F,G,H,I,J,

A

B C ED

F G H I J

K L M N

Breadth First Search

14

A, B,C,D,E, F,G,H,I,J, K, A

B C ED

F G H I J

K L M N

Breadth First Search

15

A, B,C,D,E, F,G,H,I,J, K,L A

B C ED

F G H I J

K L

O

M N

Breadth First Search

16

A, B,C,D,E, F,G,H,I,J, K,L, M, A

B C ED

F G H I J

K L

O

M N

Breadth First Search

17

A, B,C,D,E, F,G,H,I,J, K,L, M,N, A

B C ED

F G H I J

K L

O

M N

Breadth First Search

18

A, B,C,D,E, F,G,H,I,J, K,L, M,N, Goal state: O

A

B C ED

F G H I J

K L

O

M N

Breadth First Search

19

The returned solution is the sequence of operators in the path:A, B, G, L, O

A

B C ED

F G H I J

K L

O

M N

Water Jug problem using BFS

What Criteria are used to Compare different search techniques ?

21

• Completeness: Is the technique guaranteed to find an answer (if there is one).

• Optimality :Highest quality solution when there are several solution are there for the problem

• Time Complexity: How long does it take to find a solution.

• Space Complexity: How much memory does it take to find a solution.

Time and space complexity are measured in terms of:

• The (maximum) branching factor b is defined as the maximum nodes created when a new node is expanded.

• The length of a path to a goal is the depth d.

• The maximum length of any path in the state space m.

Breadth First Search (BFS)

22

• Complete? Yes.• Optimal? Yes(unit cost)• Time Complexity: O(bd) • Space Complexity: O(bd)

Algorithm• Input: START and GOAL states• Local variables: OPEN, CLOSED, STATE-X, SUCCs, FOUND;• OUTPUT: Yes Or No• Method:Initalize OPEN list with START and CLOSED=ᵩ;FOUND= false;While(OPEN≠ᵩ and FOUND= false) do{Remove the first state from OPEN and call it STATE-X;Put STATE-X in the front of closed list{maintained as stack};If STATE-X=GOAL then FOUND= true else{Perform EXPAND operation on STATE-X, producing a list of SUCCs;Remove the successors from those states, if any that are in the CLOSED list;Append SUCCs at the end of OPEN list; /*queue*/}} /* end of while*/If FOUND= true then return Yes else return NoStop

Depth First Search (DFS)

24

Depth First Search (DFS)

25

Application2: Given the following state space (tree search), give the sequence of visited nodes when using DFS (assume that the nodeO is the goal state):

A

B C ED

F G H I J

K L

O

M N

Depth First Search

26

A,

A

B C ED

Depth First Search

27

A,B,

A

B C ED

F G

Depth First Search

28

A,B,F,

A

B C ED

F G

Depth First Search

29

A,B,F, G,

A

B C ED

F G

K L

Depth First Search

30

A,B,F, G,K,

A

B C ED

F G

K L

Depth First Search

31

A,B,F, G,K, L,

A

B C ED

F G

K L

O

Depth First Search

32

A,B,F, G,K, L, O: Goal State

A

B C ED

F G

K L

O

Depth First Search

33

The returned solution is the sequence of operators in the path: A, B, G, L, O

A

B C ED

F G

K L

O

Depth First Search (DFS)

34

• Complete? No (Yes on finite trees, with no loops).

• Optimal? No

• Time Complexity: O(bd), where m is the maximum depth.

• Space Complexity: O(d), where m is the maximum depth.

Main idea: Expand node at the deepest level (breaking ties left to right).

Depth First Iterative Deepening Search (DFID)

DFID combines the benefits of BFS and DFS: Like DFS the memory requirements are very modest (O(d)). Like BFS, it is complete when the branching factor is finite.

In general, iterative deepening is the preferred uninformed search method when there is a large search space and the depth of the solution is not known.

Depth First Iterative Deepening Search

36

Given the following state space (tree search), give the sequence of visited nodes when using IDS:

A

B C ED

F G H I J

K L

O

M N

Limit = 0

Limit = 1

Limit = 2

Limit = 3

Limit = 4

DLS with bound = 0

Depth First Iterative Deepening Search

Depth First Iterative Deepening Search

38

A,

ALimit = 0

Depth First Iterative Deepening Search

39

A, Failure

ALimit = 0

DLS with bound = 1

Depth First Iterative Deepening Search

Depth First Iterative Deepening Search

41

A,

A

B C EDLimit = 1

Depth First Iterative Deepening Search

42

A,B,

A

B C EDLimit = 1

Depth First Iterative Deepening Search

43

A,B, C,

A

B C EDLimit = 1

Depth First Iterative Deepening Search

44

A,B, C, D,

A

B C EDLimit = 1

Depth First Iterative Deepening Search

45

A,B C, D, E, A

B C EDLimit = 1

Depth First Iterative Deepening Search

46

A,B, C, D, E, Failure A

B C EDLimit = 1

Depth First Iterative Deepening Search

47

A,

A

B C ED

Limit = 2

Depth First Iterative Deepening Search

48

A,B,

A

B C ED

F GLimit = 2

Depth First Iterative Deepening Search

49

A,B,F,

A

B C ED

F GLimit = 2

Depth First Iterative Deepening Search

50

A,B,F, G,

A

B C ED

F GLimit = 2

Depth First Iterative Deepening Search

51

A,B,F, G, C,

A

B C ED

F G HLimit = 2

Depth First Iterative Deepening Search

52

A,B,F, G, C,H,

A

B C ED

F G HLimit = 2

Depth First Iterative Deepening Search

53

A,B,F, G, C,H, D, A

B C ED

F G H I JLimit = 2

Depth First Iterative Deepening Search

54

A,B,F, G, C,H, D,I A

B C ED

F G H I JLimit = 2

Depth First Iterative Deepening Search

55

A,B,F, G, C,H, D,I J,

A

B C ED

F G H I JLimit = 2

Depth First Iterative Deepening Search

56

A,B,F, G, C,H, D,I J, E

A

B C ED

F G H I JLimit = 2

Depth First Iterative Deepening Search

57

A,B,F, G, C,H, D,I J, E, Failure

A

B C ED

F G H I J

K L

O

M N

Limit = 2

DLS with bound = 3

Depth First Iterative Deepening Search

Depth First Iterative Deepening Search

59

A,

A

B C ED

Limit = 3

Depth First Iterative Deepening Search

60

A,B,

A

B C ED

F G

Limit = 3

Depth First Iterative Deepening Search

61

A,B,F,

A

B C ED

F G

Limit = 3

Depth First Iterative Deepening Search

62

A,B,F, G,

A

B C ED

F G

K LLimit = 3

Depth First Iterative Deepening Search

63

A,B,F, G,K,

A

B C ED

F G

K LLimit = 3

Depth First Iterative Deepening Search

64

A,B,F, G,K, L,

A

B C ED

F G

K LLimit = 3

Depth First Iterative Deepening Search

65

A,B,F, G,K, L, C, A

B C ED

F G H

K LLimit = 3

Depth First Iterative Deepening Search

66

A,B,F, G,K, L, C,H, A

B C ED

F G H

K LLimit = 3

Depth First Iterative Deepening Search

67

A,B,F, G,K, L, C,H, D,

A

B C ED

F G H I J

K LLimit = 3

Depth First Iterative Deepening Search

68

A,B,F, G,K, L, C,H, D,I,

A

B C ED

F G H I J

K L MLimit = 3

Depth First Iterative Deepening Search

69

A,B,F, G,K, L, C,H, D,I,M,

A

B C ED

F G H I J

K L MLimit = 3

Depth First Iterative Deepening Search

70

A,B,F, G,K, L, C,H, D,I,M, J,

A

B C ED

F G H I J

K L M NLimit = 3

Depth First Iterative Deepening Search

71

A,B,F, G,K, L, C,H, D,I,M, J,N,

A

B C ED

F G H I J

K L M NLimit = 3

Depth First Iterative Deepening Search

72

A,B,F, G,K, L, C,H, D,I,M, J,N, E,

A

B C ED

F G H I J

K L M NLimit = 3

Depth First Iterative Deepening Search

73

A,B,F, G,K, L, C,H, D,I,M, J,N, E,Failure

A

B C ED

F G H I J

K L

O

M NLimit = 3

DLS with bound = 4

Depth First Iterative Deepening Search

Depth First Iterative Deepening Search

75

A,

A

B C ED

Limit = 4

Depth First Iterative Deepening Search

76

A,B,

A

B C ED

F G

Limit = 4

Depth First Iterative Deepening Search

77

A,B,F,

A

B C ED

F G

Limit = 4

Depth First Iterative Deepening Search

78

A,B,F, G,

A

B C ED

F G

K L

Limit = 4

Depth First Iterative Deepening Search

79

A,B,F, G,K,

A

B C ED

F G

K L

Limit = 4

Depth First Iterative Deepening Search

80

A,B,F, G,K, L,

A

B C ED

F G

K L

OLimit = 4

Depth First Iterative Deepening Search

81

A,B,F, G,K, L, O: Goal State

A

B C ED

F G

K L

OLimit = 4

Depth First Iterative Deepening Search

82

The returned solution is the sequence of operators in the path: A, B, G, L, O

A

B C ED

F G

K L

O

Depth First Iterative Deepening Search

• Advantage:

It gives the best solution by combining BFS and DFS.

• Disadvantage:

It performs wasted computation before reaching the goal depth

Bi-directional Search (BDS)

84

• Main idea: Start searching from both the initial state and the goal state, meet in the middle.

• Complete? Yes• Optimal? Yes• Time Complexity: O(bd/2), where d is

the depth of the solution.• Space Complexity: O(bd/2), where d is

the depth of the solution.

Bi-directional Search (BDS)ADVANTAGES• The merit of bidirectional search is its speed. Sum of the

time taken by two searches (forward and backward) is much less than the O(bd) complexity.

• It requires less memory.DISADVANTAGES• Implementation of bidirectional search algorithm is difficult

because additional logic must be included to decide which search tree to extend at each step.

• One should have known the goal state in advance.• The algorithm must be too efficient to find the intersection

of the two search trees.

Comparison of search algorithms

Basic Search Algorithms

Comparison of search algorithms

87

b: Branching factord: Depth of solutionm: Maximum depth

l : Depth Limit

top related