Presentation is loading. Please wait.

Presentation is loading. Please wait.

Problem Solving by Searching Search Methods :

Similar presentations


Presentation on theme: "Problem Solving by Searching Search Methods :"— Presentation transcript:

1 Problem Solving by Searching Search Methods :
Problem Solving by Searching Search Methods : Uninformed (Blind) search Solution of Tutorial II

2 Search Methods River boat Farmer, Wolf, Duck and Corn
Consider the River Problem: A farmer wishes to carry a wolf, a duck and corn across a river, from the south to the north shore. The farmer is the proud owner of a small rowing boat called Bounty which he feels is easily up to the job. Unfortunately the boat is only large enough to carry at most the farmer and one other item. Worse again, if left unattended the wolf will eat the duck and the duck will eat the corn. How can the farmer safely transport the wolf, the duck and the corn to the opposite shore? Solve this problem using BFS. Do not expand repeated stated. Farmer, Wolf, Duck and Corn boat River

3 (F-Takes-W, F-Takes-D, F-Takes-C, F-Takes-Self [himself only])
Search Methods Problem formulation: State representation: location of farmer and items in both sides of river [items in South shore / items in North shore] : (FWDC/-, FD/WC, C/FWD …) Initial State: farmer, wolf, duck and corn in the south shore FWDC/- Goal State: farmer, duck and corn in the north shore -/FWDC Operators: the farmer takes in the boat at most one item from one side to the other side (F-Takes-W, F-Takes-D, F-Takes-C, F-Takes-Self [himself only]) Path cost: the number of crossings

4 Search Methods

5 Blind Search Search A C D E F B G H I J K L M N O P Q R S T U V W X Y
Problem 2: Given the following state space (tree search), give the sequence of visited nodes when using BFS, DFS, and IDS. A C D E F B G H I J K L M N O P Q R S T U V W X Y Z Initial state Goal state

6 Blind Search Algorithms
BFS

7 A A B B C C D D E E F F G G H H I I J J K K L L L L L L M N O P Q R S
This node is then expanded to reveal further (unexpanded) nodes. Press space Node A is removed from the queue. Each revealed node is added to the END of the queue. Press space to continue the search. We begin with our initial state: the node labeled A. Press space to continue Node B is expanded then removed from the queue. The revealed nodes are added to the END of the queue. Press space. We then backtrack to expand node C, and the process continues. Press space The search then moves to the first node in the queue. Press space to continue. A A B B C C D D E E F F G G H H I I J J K K L L L L L L M N O P Node L is located and the search returns a solution. Press space to end. Q R S T U Press space to begin the search Press space to continue the search Press space to continue the search Press space to continue the search Press space to continue the search Press space to continue the search Press space to continue the search Press space to continue the search Press space to continue the search Press space to continue the search Size of Queue: 0 Size of Queue: 10 Size of Queue: 9 Size of Queue: 6 Size of Queue: 8 Size of Queue: 1 Size of Queue: 0 Size of Queue: 7 Size of Queue: 5 Queue: Empty Queue: G, H, I, J, K, L, M, N, O, P Queue: A Queue: I, J, K, L, M, N, O, P, Q, R Queue: L, M, N, O, P, Q, R, S, T, U Queue: Empty Queue: E, F, G, H, I, J, K, L Queue: D, E, F, G, H, I, J Queue: J, K, L, M, N, O, P, Q, R, S Queue: K, L, M, N, O, P, Q, R, S, T Queue: F, G, H, I, J, K, L, M, N Queue: B, C, D, E, F Queue: H, I, J, K, L, M, N, O, P, Q Queue: C, D, E, F, G, H Nodes expanded: 8 Nodes expanded: 9 Nodes expanded: 10 Nodes expanded: 11 Nodes expanded: 7 Nodes expanded: 4 Nodes expanded: 5 Nodes expanded: 3 Nodes expanded: 6 Nodes expanded: 2 Nodes expanded: 0 Nodes expanded: 1 Current Action: Backtracking Current Action: Backtracking Current Action: Expanding Current Action: Current Action: Expanding Current Action: Expanding Current Action: Backtracking Current Action: Backtracking Current Action: Backtracking Current Action: Expanding Current Action: Expanding Current Action: Expanding FINISHED SEARCH Current Action: Backtracking Current Action: Backtracking Current Action: Backtracking Current Action: Backtracking Current Action: Expanding Current Action: Expanding Current Action: Expanding Current Action: Backtracking Current Action: Expanding Current level: 2 Current level: 1 Current level: 0 Current level: 0 Current level: 1 Current level: 1 Current level: 1 Current level: 0 Current level: 0 Current level: 1 Current level: n/a Current level: 0 Current level: 1 Current level: 0 Current level: 1 Current level: 2 Current level: 2 Current level: 1 Current level: 1 Current level: 0 Current level: 1 Current level: 2 Current level: 1 Current level: 1 Current level: 2 Current level: 1 Current level: 2 Current level: 0 BREADTH-FIRST SEARCH PATTERN

8 Blind Search Algorithms
DFS

9 A A B B C C D D E F G G H H I I J J K K L L L L L L L L Q Q R R S S T
The process now continues until the goal state is achieved. Press space. Node B is expanded and removed from the queue. Revealed nodes are added to the FRONT of the queue. Press space. The search then moves to the first node in the queue. Press space to continue We begin with our initial state: the node labeled A. Press space to continue This node is then expanded to reveal further (unexpanded) nodes. Press space. Node A is removed from the queue. Each revealed node is added to the FRONT of the queue. Press space to continue. A A B B C C D D E F G G H H I I J J K K L L L L L L L L Node L is located and the search returns a solution. Press space to end. Q Q R R S S T T U U Press space to begin the search Press space to continue the search Press space to continue the search Press space to continue the search Press space to continue the search Press space to continue the search Press space to continue the search Press space to continue the search Press space to continue the search Press space to continue the search Press space to continue the search Press space to continue the search Press space to continue the search Size of Queue: 4 Size of Queue: 5 Size of Queue: 3 Size of Queue: 4 Size of Queue: 4 Size of Queue: 0 Size of Queue: 3 Size of Queue: 6 Size of Queue: 1 Size of Queue: 5 Size of Queue: 0 Size of Queue: 5 Queue: S, J, D, E, F Queue: T, D, E, F Queue: J, D, E, F Queue: I, J, D, E, F Queue: L, E, F Queue: U, L, E, F Queue: K, L, E, F Queue: Empty Queue: D, E, F Queue: C, D, E, F Queue: Empty Queue: R, C, D, E, F Queue: G, H, C, D, E, F Queue: B, C, D, E, F Queue: Q, H, C, D, E, F Queue: A Queue: H, C, D, E, F Nodes expanded: 14 Nodes expanded: 11 Nodes expanded: 6 Nodes expanded: 2 Nodes expanded: 3 Nodes expanded: 10 Nodes expanded: 12 Nodes expanded: 4 Nodes expanded: 13 Nodes expanded: 5 Nodes expanded: 7 Nodes expanded: 8 Nodes expanded: 9 Nodes expanded: 1 Nodes expanded: 0 Current Action: Backtracking Current Action: Backtracking Current Action: FINISHED SEARCH Current Action: Expanding Current Action: Expanding Current Action: Expanding Current Action: Backtracking Current Action: Expanding Current Action: Backtracking Current Action: Backtracking Current Action: Expanding Current level: 3 Current level: 0 Current level: 2 Current level: n/a Current level: 2 Current level: 1 Current level: 2 Current level: 2 Current level: 1 Current level: 3 Current level: 2 Current level: 3 Current level: 2 Current level: 0 Current level: 1 Current level: 1 Current level: 2 Current level: 3 Current level: 2 Current level: 1 Current level: 2 Current level: 3 Current level: 2 Current level: 1 Current level: 1 Current level: 0 Current level: 1 Current level: 2 DEPTH-FIRST SEARCH PATTERN

10 Blind Search Algorithms
IDS

11 Press space to begin the search
We begin with our initial state: the node labeled A. This node is added to the queue. Press space to continue Node A is then expanded and removed from the queue. Press space. A A As this is the 0th iteration of the search, we cannot search past any level greater than zero. This iteration now ends, and we begin the 1st iteration. Press space to begin the search Size of Queue: 1 Size of Queue: 0 Size of Queue: 0 Queue: Empty Queue: A Queue: Empty Nodes expanded: 1 Nodes expanded: 0 Current Action: Expanding Current level: n/a Current level: 0 ITERATIVE DEEPENING SEARCH PATTERN (0th ITERATION)

12 Node A is expanded, then removed from the queue, and the revealed nodes are added to the front . Press space. We again begin with our initial state: the node labeled A. Note that the 1st iteration carries on from the 0th, and therefore the ‘nodes expanded’ value is already set to 1. Press space to continue Node B is expanded and removed from the queue. Press space. We now back track to expand node C, and the process continues. Press space. The search now moves to level one of the node set. Press space to continue A A B B C C D D E E F F As this is the 1st iteration of the search, we cannot search past any level greater than level one. This iteration now ends, and we begin a 2nd iteration. Press space to begin the search Press space to continue the search Press space to continue the search Press space to continue the search Size of Queue: 4 Size of Queue: 2 Size of Queue: 0 Size of Queue: 3 Size of Queue: 0 Size of Queue: 5 Size of Queue: 1 Size of Queue: 1 Queue: E, F Queue: F Queue: Empty Queue: D, E, F Queue: B, C, D, E, F Queue: C, D, E, F Queue: A Queue: Empty Nodes expanded: 5 Nodes expanded: 4 Nodes expanded: 1 Nodes expanded: 6 Nodes expanded: 2 Nodes expanded: 7 Nodes expanded: 3 Current Action: Current Action: Expanding Current Action: Expanding Current Action: Backtracking Current Action: Backtracking Current Action: Backtracking Current Action: Expanding Current Action: Backtracking Current Action: Expanding Current Action: Expanding Current level: 1 Current level: n/a Current level: 0 Current level: 0 Current level: 1 Current level: 1 Current level: 0 Current level: 1 Current level: 1 Current level: 0 Current level: 1 Current level: 0 Current level: 0 ITERATIVE DEEPENING SEARCH PATTERN (1st ITERATION)

13 A A B B C C D D E F G G H H I I J J K K L L L L L L
The search then moves to level one of the node set. Press space to continue Node B is expanded and the revealed nodes added to the front of the queue. Press space to continue. Again, we expand node A to reveal the level one nodes. Press space. We again begin with our initial state: the node labeled A. Note that the 2nd iteration carries on from the 1st, and therefore the ‘nodes expanded’ value is already set to 7 (1+6). Press space to continue the search Node A is removed from the queue and each revealed node is added to the front of the queue. Press space. We now move to level two of the node set. Press space to continue. After expanding node G we backtrack to expand node H. The process then continues until goal state. Press space A A B B C C D D E F G G H H I I J J K K L L L L L L Node L is located on the second level and the search returns a solution on its second iteration. Press space to end. Press space to continue the search Press space to continue the search Press space to continue the search Press space to continue the search Press space to continue the search Press space to continue the search Size of Queue: 5 Size of Queue: 0 Size of Queue: 4 Size of Queue: 3 Size of Queue: 5 Size of Queue: 6 Size of Queue: 0 Size of Queue: 4 Size of Queue: 5 Size of Queue: 4 Size of Queue: 3 Size of Queue: 1 Queue: Empty Queue: L, E, F Queue: K, L, E, F Queue: J, D, E, F Queue: D, E, F Queue: I, J, D, E, F Queue: A Queue: G, H, C, D, E, F Queue: C, D, E, F Queue: H, C, D, E, F Queue: Empty Queue: B, C, D, E, F Nodes expanded: 7 Nodes expanded: 16 Nodes expanded: 14 Nodes expanded: 9 Nodes expanded: 15 Nodes expanded: 12 Nodes expanded: 11 Nodes expanded: 13 Nodes expanded: 10 Nodes expanded: 8 SEARCH FINISHED Current Action: Expanding Current Action: Expanding Current Action: Backtracking Current Action: Current Action: Expanding Current Action: Backtracking Current Action: Expanding Current Action: Backtracking Current Action: Expanding Current Action: Backtracking Current Action: Backtracking Current Action: Expanding Current level: 0 Current level: 2 Current level: 0 Current level: 1 Current level: 1 Current level: n/a Current level: 2 Current level: 1 Current level: 1 Current level: 1 Current level: 0 Current level: 2 Current level: 2 Current level: 2 Current level: 1 Current level: 1 Current level: 2 Current level: 1 ITERATIVE DEEPENING SEARCH PATTERN (2nd ITERATION)

14 Blind Search Algorithms
UCS

15 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. Solve this problem using UCS …

16 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. 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. 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. Press space to end. 15 C Press space to begin the search Size of Queue: 3 Size of Queue: 1 Size of Queue: 0 Size of Queue: 0 Queue: B, G11, C Queue: G10, G11, C15 Queue: Empty Queue: A, B, C Queue: Empty Queue: S Nodes expanded: 3 Nodes expanded: 1 Nodes expanded: 2 Nodes expanded: 0 Current action: Expanding FINISHED SEARCH Current action: Waiting…. 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


Download ppt "Problem Solving by Searching Search Methods :"

Similar presentations


Ads by Google