Artificial Intelligence Problem solving by searching CSC 361 Prof. Mohamed Batouche Computer Science Department CCIS – King Saud University Riyadh, Saudi.

Slides:



Advertisements
Similar presentations
Lecture 02 – Part A Problem Solving by Searching Search Methods :
Advertisements

Problem Solving Well-formed predicate calculus expressions provide a means of describing objects and relations in a problem domain and inference rule.
Comp 307 Problem Solving and Search Formalize a problem as State Space Search Blind search strategies Heuristic search.
Solving Problems by Searching Currently at Chapter 3 in the book Will finish today/Monday, Chapter 4 next.
CS 480 Lec 3 Sept 11, 09 Goals: Chapter 3 (uninformed search) project # 1 and # 2 Chapter 4 (heuristic search)
G5BAIM Artificial Intelligence Methods Graham Kendall Blind Searches.
Blind Search1 Solving problems by searching Chapter 3.
CPSC 322, Lecture 5Slide 1 Uninformed Search Computer Science cpsc322, Lecture 5 (Textbook Chpt 3.4) January, 14, 2009.
Search Strategies Reading: Russell’s Chapter 3 1.
Uniform Cost Search Introduction to AI. Uniform cost search A breadth-first search finds the shallowest goal state and will therefore be the cheapest.
Touring problems Start from Arad, visit each city at least once. What is the state-space formulation? Start from Arad, visit each city exactly once. What.
CSC 423 ARTIFICIAL INTELLIGENCE
Artificial Intelligence (CS 461D)
UNINFORMED SEARCH Problem - solving agents Example : Romania  On holiday in Romania ; currently in Arad.  Flight leaves tomorrow from Bucharest.
Artificial Intelligence Lecture No. 7 Dr. Asad Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
SEARCH TECHNIQUES.
Lecture 3 Note: Some slides and/or pictures are adapted from Lecture slides / Books of Dr Zafar Alvi. Text Book - Aritificial Intelligence Illuminated.
Artificial Intelligence Problem solving by searching CSC 361
CSC-470: ARTIFICIAL INTELLIGENCE
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Blind State-Space Search Notes for Ch.11 of Bratko For CSCE 580 Sp03 Marco.
Breadth-First Searches Introduction to AI. Breadth-First Search Using a breadth-first strategy we expand the root level first and then we expand all those.
Toy Problem: Missionaries and Cannibals
Artificial Intelligence Problem solving by searching CSC 361
Problem solving by Searching Problem Formulation.
Artificial Intelligence Chapter 3: Solving Problems by Searching
1 Solving Problems by Searching. 2 Terminology State State Space Initial State Goal Test Action Step Cost Path Cost State Change Function State-Space.
Iterative Deepening Search Introduction to AI. Iterative deepening search The problem with depth-limited search is deciding on a suitable depth parameter.
Dr Eleni Mangina – COURSE: LOGIC PROGRAMMING (during a joint degree with Fudan University in Software Engineering) DEPT. OF COMPUTER SCIENCE UCD Problem.
Using Search in Problem Solving
Artificial Intelligence Problem solving by searching CSC 361
Artificial Intelligence Problem solving by searching CSC 361 Prof. Mohamed Batouche Computer Science Department CCIS – King Saud University Riyadh, Saudi.
Artificial Intelligence Problem solving by searching CSC 361 Prof. Mohamed Batouche Computer Science Department CCIS – King Saud University Riyadh, Saudi.
Solving Problems by Searching
State-Space Searches.
Artificial Intelligence Problem solving by searching CSC 361
Artificial Intelligence Course outline Introduction Problem solving Generic algorithms Knowledge Representation and Reasoning Expert Systems Uncertainty.
Review: Search problem formulation Initial state Actions Transition model Goal state (or goal test) Path cost What is the optimal solution? What is the.
Artificial Intelligence Search Problem. Search is a problem-solving technique to explores successive stages in problem-solving process.
State-Space Searches. 2 State spaces A state space consists of A (possibly infinite) set of states The start state represents the initial problem Each.
CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 02 : Search.
Artificial Intelligence
Lecture 3: Uninformed Search
Search CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Problem solving by search Department of Computer Science & Engineering Indian Institute of Technology Kharagpur.
Introduction to Artificial Intelligence (G51IAI) Dr Rong Qu Blind Searches.
Basic Problem Solving Search strategy  Problem can be solved by searching for a solution. An attempt is to transform initial state of a problem into some.
Goal-based Problem Solving Goal formation Based upon the current situation and performance measures. Result is moving into a desirable state (goal state).
Problem Solving as Search. Problem Types Deterministic, fully observable  single-state problem Non-observable  conformant problem Nondeterministic and/or.
CPSC 322, Lecture 6Slide 1 Uniformed Search (cont.) Computer Science cpsc322, Lecture 6 (Textbook finish 3.5) Sept, 17, 2012.
1/16 Problem solving by Searching Problem Formulation.
Artificial Intelligence Search Problem. Search is a problem-solving technique to explores successive stages in problem- solving process.
Brian Williams, Fall 041 Analysis of Uninformed Search Methods Brian C. Williams Sep 21 st, 2004 Slides adapted from: Tomas Lozano Perez,
SEARCH TECHNIQUES. SEARCH TECHNIQUES Search techniques BlindHeuristic Depth first Search ( DFS ) Breadth first Search ( BFS ) Hill climbing Search A*
Depth-First Searches G5AIAI – Introduction to AI.
ARTIFICIAL INTELLIGENCE
Uninformed (also called blind) search algorithms)
Problem solving by Searching
Iterative Deepening Search
G5AIAI – Introduction to AI
Artificial Intelligence (CS 370D)
Breadth-First Searches
Iterative Deepening Search
Artificial Intelligence
Breadth-First Searches
Depth-First Searches Introduction to AI.
Artificial Intelligence Problem solving by searching CSC 361
Problem Solving by Searching Search Methods :
ARTIFICIAL INTELLIGENCE
Problem Solving by Searching Search Methods :
Depth-First Searches.
Presentation transcript:

Artificial Intelligence Problem solving by searching CSC 361 Prof. Mohamed Batouche Computer Science Department CCIS – King Saud University Riyadh, Saudi Arabia

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

3 Search Methods 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

4 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

5 Search Methods

6 Blind Search Search Problem 2: Given the following state space (tree search), give the sequence of visited nodes when using BFS, DFS, and IDS. A CDEFB GHIJKLMNOP QRSTUVWXYZ Initial state Goal state A L

Blind Search Algorithms BFS

8 A CDEFB GHIJKL QRSTU A BCD 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 END of the queue. Press space to continue the search. The search then moves to the first node in the queue. 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. Size of Queue: 0 Nodes expanded: 0Current Action:Current level: n/a Queue: EmptyQueue: ASize of Queue: 1 Nodes expanded: 1 Queue: B, C, D, E, F Press space to begin the search Size of Queue: 5 Current level: 0Current Action: Expanding Queue: C, D, E, F, G, HSize of Queue: 6 Nodes expanded: 2Current level: 1 We then backtrack to expand node C, and the process continues. Press space Current Action: BacktrackingCurrent level: 0Current level: 1 Queue: D, E, F, G, H, I, JSize of Queue: 7 Nodes expanded: 3Current Action: ExpandingCurrent Action: BacktrackingCurrent level: 0Current level: 1 Queue: E, F, G, H, I, J, K, LSize of Queue: 8 Nodes expanded: 4Current Action: ExpandingCurrent Action: BacktrackingCurrent level: 0Current level: 1Current Action: Expanding NM Queue: F, G, H, I, J, K, L, M, NSize of Queue: 9 Nodes expanded: 5 E Current Action: BacktrackingCurrent level: 0Current Action: ExpandingCurrent level: 1 OP Queue: G, H, I, J, K, L, M, N, O, PSize of Queue: 10 Nodes expanded: 6 F Current Action: BacktrackingCurrent level: 0Current level: 1Current level: 2Current Action: Expanding Queue: H, I, J, K, L, M, N, O, P, Q Nodes expanded: 7 G Current Action: BacktrackingCurrent level: 1Current Action: Expanding Queue: I, J, K, L, M, N, O, P, Q, R Nodes expanded: 8 H Current Action: BacktrackingCurrent level: 2Current level: 1Current level: 0Current level: 1Current level: 2Current Action: Expanding Queue: J, K, L, M, N, O, P, Q, R, S Nodes expanded: 9 I Current Action: BacktrackingCurrent level: 1Current level: 2Current Action: Expanding Queue: K, L, M, N, O, P, Q, R, S, T Nodes expanded: 10 J Current Action: BacktrackingCurrent level: 1Current level: 0Current level: 1Current level: 2Current Action: Expanding Queue: L, M, N, O, P, Q, R, S, T, U Nodes expanded: 11 K Current Action: BacktrackingCurrent level: 1 LLLL Node L is located and the search returns a solution. Press space to end. FINISHED SEARCH Queue: EmptySize of Queue: 0 Current level: 2 BREADTH-FIRST SEARCH PATTERN L Press space to continue the search

Blind Search Algorithms DFS

10 A CDEFB GHIJKL QRSTU A B G Q H R C I S J T D K U LLLLL 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. The search then moves to the first node in the queue. Press space to continue Node B is expanded and removed from the queue. Revealed nodes are added to the FRONT of the queue. Press space. Size of Queue: 0 Nodes expanded: 0Current Action:Current level: n/a Queue: EmptyQueue: ASize of Queue: 1 Current level: 0Nodes expanded: 1 Queue: B, C, D, E, F Current Action: ExpandingCurrent level: 1 Queue: G, H, C, D, E, FSize of Queue: 5Size of Queue: 6 Nodes expanded: 2Current level: 2Nodes expanded: 3 Queue: Q, H, C, D, E, FSize of Queue: 5 Nodes expanded: 4 Queue: H, C, D, E, F Current level: 3Current Action: BacktrackingCurrent level: 2Current level: 1Current level: 2Current Action: Expanding Queue: R, C, D, E, F Nodes expanded: 5 Queue: C, D, E, FSize of Queue: 4 Nodes expanded: 6Current level: 3Current Action: BacktrackingCurrent level: 2Current level: 1Current level: 0Current Action: Expanding Queue: I, J, D, E, FSize of Queue: 5 Nodes expanded: 7Current level: 1 Queue: S, J, D, E, F Nodes expanded: 8Current level: 2 Queue: J, D, E, FSize of Queue: 4 Nodes expanded: 9Current level: 3Current Action: BacktrackingCurrent level: 2Current level: 1Current Action: Expanding Queue: T, D, E, F Nodes expanded: 10Current level: 2 Queue: D, E, FSize of Queue: 3 Nodes expanded: 11Current level: 3Current Action: BacktrackingCurrent level: 2Current level: 1Current level: 0Current Action: Expanding Queue: K, L, E, FSize of Queue: 4 Nodes expanded: 12Current level: 1 Queue: U, L, E, F Nodes expanded: 13Current level: 2 Queue: L, E, FSize of Queue: 3 Nodes expanded: 14Current level: 3Current Action: BacktrackingCurrent level: 2Current level: 1 Size of Queue: 0Queue: Empty FINISHED SEARCHCurrent level: 2 Node L is located and the search returns a solution. Press space to end. Press space to begin the search DEPTH-FIRST SEARCH PATTERN The process now continues until the goal state is achieved. Press space. Press space to continue the search LL

Blind Search Algorithms IDS

12 AA We begin with our initial state: the node labeled A. This node is added to the queue. Press space to continue Size of Queue: 0 Nodes expanded: 0Current Action: ExpandingCurrent level: n/a Queue: EmptyQueue: ASize of Queue: 1 Current level: 0Nodes expanded: 1 Queue: EmptySize of Queue: 0 Press space to begin the search 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. ITERATIVE DEEPENING SEARCH PATTERN (0 th ITERATION) Node A is then expanded and removed from the queue. Press space.

13 A CDEFB A BCD We again begin with our initial state: the node labeled A. Note that the 1 st iteration carries on from the 0 th, and therefore the ‘nodes expanded’ value is already set to 1. Press space to continue Node A is expanded, then removed from the queue, and the revealed nodes are added to the front. Press space. The search now moves to level one of the node set. Press space to continue Node B is expanded and removed from the queue. Press space. Size of Queue: 0 Nodes expanded: 1Current Action:Current level: n/a Queue: EmptyQueue: ASize of Queue: 1 Nodes expanded: 2 Queue: B, C, D, E, F Press space to begin the search Size of Queue: 5 Current level: 0Current Action: Expanding Queue: C, D, E, FSize of Queue: 4 Nodes expanded: 3Current level: 1Current Action: BacktrackingCurrent level: 0Current level: 1 Queue: D, E, FSize of Queue: 3 Nodes expanded: 4Current Action: ExpandingCurrent Action: BacktrackingCurrent level: 0Current level: 1 Queue: E, FSize of Queue: 2 Nodes expanded: 5Current Action: ExpandingCurrent Action: BacktrackingCurrent level: 0Current level: 1Current Action: Expanding Queue: F E Current Action: BacktrackingCurrent level: 0Current Action: ExpandingCurrent level: 1 Queue: Empty F Current level: 0Current level: 1 Press space to continue the search ITERATIVE DEEPENING SEARCH PATTERN (1 st ITERATION) Size of Queue: 1Size of Queue: 0 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. Nodes expanded: 6Nodes expanded: 7 We now back track to expand node C, and the process continues. Press space.

14 A CDEFB GHIJKL A B G We again begin with our initial state: the node labeled A. Note that the 2 nd iteration carries on from the 1 st, and therefore the ‘nodes expanded’ value is already set to 7 (1+6). Press space to continue the search Again, we expand node A to reveal the level one nodes. Press space. Node A is removed from the queue and each revealed node is added to the front of the queue. Press space. 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. Size of Queue: 0 Nodes expanded: 7Current Action:Current level: n/a Queue: EmptyQueue: ASize of Queue: 1 Current level: 0Nodes expanded: 8 Queue: B, C, D, E, F Current level: 1 Queue: G, H, C, D, E, F Nodes expanded: 9Current level: 2 ITERATIVE DEEPENING SEARCH PATTERN (2 nd ITERATION) Size of Queue: 5 Current Action: Expanding 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 Queue: H, C, D, E, F Nodes expanded: 10Current Action: BacktrackingCurrent Action: Expanding Queue: C, D, E, FSize of Queue: 6 Nodes expanded: 11 H Press space to continue the search Size of Queue: 5Size of Queue: 4 Current Action: BacktrackingCurrent Action: Expanding Queue: I, J, D, E, FSize of Queue: 5 Nodes expanded: 12 Press space to continue the search C Current level: 1Current level: 2Current level: 1Current level: 0Current level: 1Current level: 2 Queue: J, D, E, FSize of Queue: 4 Nodes expanded: 13 I Press space to continue the search Current Action: BacktrackingCurrent level: 1Current level: 2 Queue: D, E, F Current Action: Expanding Size of Queue: 3 Nodes expanded: 14 J Press space to continue the search Current Action: BacktrackingCurrent level: 1Current level: 0Current level: 1Current Action: Expanding Queue: K, L, E, FSize of Queue: 4 Nodes expanded: 15 D Press space to continue the search Current level: 2 Queue: L, E, FSize of Queue: 3 Nodes expanded: 16 K Press space to continue the search Current Action: ExpandingCurrent level: 1Current level: 2 LLLLL Current Action: Backtracking Queue: EmptySize of Queue: 0 Node L is located on the second level and the search returns a solution on its second iteration. Press space to end. SEARCH FINISHED

Blind Search Algorithms UCS

16 Consider the following problem… B C SG A 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 …

17 S Size of Queue: 0 Nodes expanded: 0 Queue: Empty Current action: Waiting….Current level: n/a UNIFORM COST SEARCH PATTERN Press space to begin the search Current action: ExpandingCurrent level: 0 Queue: SSize of Queue: 1 A B C Size of Queue: 3Queue: A, B, C We start with our initial state and expand it…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 now expand the node at the front of the queue, node A. Press space to continue. Nodes expanded: 1 S Current level: 1 G 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. 10 A Nodes expanded: 2 Queue: B, G 11, C Current action: BacktrackingCurrent level: 0Current level: 1Current action: Expanding 5 Nodes expanded: 3 Queue: G 10, G 11, C 15 B 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 G 10 and once as G 11. As G 10 is at the front of the queue, we now proceed to goal state. Press space. Current level: 2 Queue: EmptySize of Queue: 0 FINISHED SEARCH GGGGG 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.