Problem Solving by Searching Search Methods Uninformed Blind
Problem Solving by Searching Search Methods : Uninformed (Blind) search Solution of Tutorial II
Search Methods n 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. River Farmer, Wolf, Duck and Corn boat 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. 2
Search Methods n Problem formulation: n n n 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 3
Search Methods 4
Blind Search n Problem 2: Given the following state space (tree search), give the sequence of visited nodes when using BFS, DFS, and IDS. Initial state A B C D E F Goal state G H I J K L M N O P Q S T U V W X Y Z R 5
Blind Search Algorithms BFS
Node B isbacktrack expanded then removed We The then search then moves to expand to thenode firstfrom C, nodethe queue. revealed nodes arecontinue. added and in the. The queue. process Press continues. space Press to spaceto the END of the queue. Press space. B G H Q R C I S A Node A is removed from This We begin node is with then our expanded initialthe state: toqueue. reveal the Each node revealed node is added to the END space of the further labeled(unexpanded) A. Press spacenodes. continue Press queue. Press space to continue the search. D J T K U E L F M N O P Node L is located and the search returns a solution. Press space to end. Press space to begin continue thethe search Size of Queue: 010 987651 Queue: Empty A J, B, C, D, E, F, G, H, I, J, K, L, K, G, C, F, M, D, E, H, K, I, L, J, G, L, H, D, F, M, E, I, N, L, K, J, M, G, H, E, F, I, O, N, M, K, L, J, G, H, F I, N, P, O, K, M, J, L, N, H I, O, Q, P, K, L, M, JO, N, P, R, Q, LP, M, O, N, Q, S, R, Q, N O, P, R, T, S, R Q PU ST Nodes expanded: 11 9876543210 10 Current. FINISHED Action: Backtracking Expanding SEARCH Current level: 210 n/a BREADTH-FIRST SEARCH PATTERN 7
Blind Search Algorithms DFS
Nodeprocess B is expanded andtoremoved from The search then nowmoves continues the until first the node the queue. nodes added to in the goal state queue. is. Revealed achieved. Press space Press toare continue space. the FRONT of the queue. Press space. B A C D G H I J K Q S T U R Node A is with removed from the Each We begin This node is then ourexpanded initial state: toqueue. reveal the node revealed node is space addednodes. tocontinue the Press FRONT of labeled A. further (unexpanded) Press to space. the queue. Press space to continue. E L F Node L is located and the search returns a solution. Press space to end. Press space to begin continue thethe search Size of Queue: 034561 Queue: Empty A J, B, G, Q, H, R, C, I, S, J, T, D, K, U, L, D, J, C, D, E, L, H, D, C, D, E, F D, E, D, C, E, E, FF E, E, D, FFFFE, F Nodes expanded: 14 9876543210 10 11 12 13 Current. FINISHED Action: Backtracking Expanding SEARCH DEPTH-FIRST SEARCH PATTERN Current level: 2130 n/a 9
Blind Search Algorithms IDS
A We begin initial state: the node Node A iswith thenour expanded and removed labeled A. queue. This node is space. added to the from the Press queue. Press space to continue As this is the 0 th iteration of the search, we cannot search past any level greater than zero. This iteration now ends, and we begin the 1 st iteration. Press space to begin the search Size of Queue: 01 Queue: Empty A Nodes expanded: 10 Current Action: Expanding Current level: 0 n/a ITERATIVE DEEPENING SEARCH PATTERN (0 th ITERATION) 11
We Node The now B search isback expanded now track moves to and expand removed to level node one from C, of and the queue. theprocess node Press set. continues. space. Press space Presstospace. continue B C A D Node We again A is expanded, begin withthen our initial removed state: from the node queue, labeled and. A. the Note revealed that the nodes 1 st iteration are added carriestoon thefrom front the. Press 0 th, and space. therefore the ‘nodes expanded’ value is already set to 1. Press space to continue E F As this is the 1 st iteration of the search, we cannot search past any level greater than level one. This iteration now ends, and we begin a 2 nd iteration. Press space to begin continue thethe search Size of Queue: 012345 Queue: Empty A F B, C, D, E, F C, D, F E, D, E, F Nodes expanded: 7654321 Current Action: Expanding Backtracking Current level: 10 n/a ITERATIVE DEEPENING SEARCH PATTERN (1 st ITERATION) 12
Node Bexpanding ismove expanded and The search then tothe level of After node G we backtrack We now tomoves level two ofrevealed theone nodes added to the front of queue. the node set. Press space to the continue to expand node H. continue. The process then set. Press space to Press spaceuntil to continues goal state. Press space B A C G H I D J K Node We again Awe is begin removed with from our. Athe initial queue state: and Again, expand node to reveal the node each revealed labeled node A. is Note added thattothe 2 nd front of level one nodes. Press space. iteration the queue. carries Press on space. from the 1 st, and therefore the ‘nodes expanded’ value is already set to 7 (1+6). Press space to E F continue the search 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 Size of Queue: 034561 Queue: Empty A J, B, G, H, C, I, J, D, K, L, D, C, E, D, H, D, C, L, E, F D, E, D, C, E, FF E, E, D, FFFE, F Nodes expanded: 16 987 10 11 12 13 14 15 Current. SEARCH Action: Backtracking Expanding FINISHED Current level: 210 n/a ITERATIVE DEEPENING SEARCH PATTERN (2 nd ITERATION) 13
Blind Search Algorithms UCS
Consider the following problem… A 10 1 5 S B 5 G 5 15 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. Solve this problem using UCS … 15
Once Node node Astart is Sexpand is removed Bwith removed has our been from expanded the queue it isand removed and the revealed from node the nodes queue (node are and G) added the is added revealed totothe toqueue. the node queue. The We We now thefrom initial node atthe state the front and expand ofthe queue, it… A. Press space continue. The (node queue G) isisis then added. again sorted The sorted on queue on path iscost. again cost. Nodes sorted Note, with on wepath cheaper havecost. now path Note, found costnode ahave goal Gpriority. In state now appears but do this not incase recognise the queue it twice, as will it once is benot Node as at G the A 10(1), front andnode once of the Bas(5), queue. G 11 followed. As. Node G 10 B by is is atnode the cheaper front C (15). of Press node. the queue, space. Presswe space. now proceed to goal state. Press space. A 1 5 S 15 10 5 B C 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. Press space to begin the search Size of Queue: 031 Queue: Empty S 10 G A, B, G B, , G 11 C , 11 C, C 15 Nodes expanded: 3210 Current. FINISHED action: Expanding Waiting…. Backtracking SEARCH Current level: 210 n/a UNIFORM COST SEARCH PATTERN 16
- Slides: 16