University College Cork (Ireland) Department of Civil and Environmental Engineering Course: Engineering Artificial Intelligence Dr. Radu Marinescu Lecture.

Slides:



Advertisements
Similar presentations
Solving problems by searching Chapter 3. Outline Problem-solving agents Problem types Problem formulation Example problems Basic search algorithms.
Advertisements

Additional Topics ARTIFICIAL INTELLIGENCE
Solving problems by searching
Announcements Course TA: Danny Kumar
Artificial Intelligence Solving problems by searching
Problem Solving by Searching Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 3 Spring 2007.
January 26, 2003AI: Chapter 3: Solving Problems by Searching 1 Artificial Intelligence Chapter 3: Solving Problems by Searching Michael Scherger Department.
Artificial Intelligence Problem Solving Eriq Muhammad Adams
Blind Search1 Solving problems by searching Chapter 3.
May 12, 2013Problem Solving - Search Symbolic AI: Problem Solving E. Trentin, DIISM.
1 Chapter 3 Solving Problems by Searching. 2 Outline Problem-solving agentsProblem-solving agents Problem typesProblem types Problem formulationProblem.
Solving Problem by Searching Chapter 3. Outline Problem-solving agents Problem formulation Example problems Basic search algorithms – blind search Heuristic.
Solving problems by searching Chapter 3. Outline Problem-solving agents Problem types Problem formulation Example problems Basic search algorithms.
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.
Artificial Intelligence for Games Uninformed search Patrick Olivier
14 Jan 2004CS Blind Search1 Solving problems by searching Chapter 3.
EIE426-AICV 1 Blind and Informed Search Methods Filename: eie426-search-methods-0809.ppt.
UNINFORMED SEARCH Problem - solving agents Example : Romania  On holiday in Romania ; currently in Arad.  Flight leaves tomorrow from Bucharest.
14 Jan 2004CS Blind Search1 Solving problems by searching Chapter 3.
1 Solving problems by searching Chapter 3. 2 Why Search? To achieve goals or to maximize our utility we need to predict what the result of our actions.
CHAPTER 3 CMPT Blind Search 1 Search and Sequential Action.
An Introduction to Artificial Intelligence Lecture 3: Solving Problems by Sorting Ramin Halavati In which we look at how an agent.
Problem Solving and Search in AI Part I Search and Intelligence Search is one of the most powerful approaches to problem solving in AI Search is a universal.
CS 380: Artificial Intelligence Lecture #3 William Regli.
1 Solving problems by searching Chapter 3. 2 Why Search? To achieve goals or to maximize our utility we need to predict what the result of our actions.
Artificial Intelligence Chapter 3: Solving Problems by Searching
Uninformed Search Reading: Chapter 3 by today, Chapter by Wednesday, 9/12 Homework #2 will be given out on Wednesday DID YOU TURN IN YOUR SURVEY?
Solving problems by searching
1 Solving problems by searching Chapter 3. 2 Why Search? To achieve goals or to maximize our utility we need to predict what the result of our actions.
Solving problems by searching This Lecture Read Chapters 3.1 to 3.4 Next Lecture Read Chapter 3.5 to 3.7 (Please read lecture topic material before and.
Review: Search problem formulation Initial state Actions Transition model Goal state (or goal test) Path cost What is the optimal solution? What is the.
Solving Problems by Searching CPS Outline Problem-solving agents Example problems Basic search algorithms.
1 Solving problems by searching This Lecture Chapters 3.1 to 3.4 Next Lecture Chapter 3.5 to 3.7 (Please read lecture topic material before and after each.
Introduction to search Chapter 3. Why study search? §Search is a basis for all AI l search proposed as the basis of intelligence l inference l all learning.
Dr.Abeer Mahmoud ARTIFICIAL INTELLIGENCE (CS 461D) Dr. Abeer Mahmoud Computer science Department Princess Nora University Faculty of Computer & Information.
AI in game (II) 권태경 Fall, outline Problem-solving agent Search.
Lecture 3: Uninformed Search
1 Solving problems by searching 171, Class 2 Chapter 3.
An Introduction to Artificial Intelligence Lecture 3: Solving Problems by Sorting Ramin Halavati In which we look at how an agent.
SOLVING PROBLEMS BY SEARCHING Chapter 3 August 2008 Blind Search 1.
A General Introduction to Artificial Intelligence.
Solving problems by searching 1. Outline Problem formulation Example problems Basic search algorithms 2.
CPSC 420 – Artificial Intelligence Texas A & M University Lecture 3 Lecturer: Laurie webster II, M.S.S.E., M.S.E.e., M.S.BME, Ph.D., P.E.
1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further.
Artificial Intelligence Lecture No. 6 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Introduction to Artificial Intelligence (G51IAI) Dr Rong Qu Blind Searches - Introduction.
Solving problems by searching A I C h a p t e r 3.
G5AIAI Introduction to AI
Lecture 2: Problem Solving using State Space Representation CS 271: Fall, 2008.
Brian Williams, Fall 041 Analysis of Uninformed Search Methods Brian C. Williams Sep 21 st, 2004 Slides adapted from: Tomas Lozano Perez,
WEEK 5 LECTURE -A- 23/02/2012 lec 5a CSC 102 by Asma Tabouk Introduction 1 CSC AI Basic Search Strategies.
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
Artificial Intelligence Solving problems by searching.
Solving problems by searching Chapter 3. Types of agents Reflex agent Consider how the world IS Choose action based on current percept Do not consider.
Lecture 3: Uninformed Search
Solving problems by searching
EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS
ECE 448 Lecture 4: Search Intro
Problem Solving by Searching
Artificial Intelligence
Solving problems by searching
Solving problems by searching
Artificial Intelligence
Solving problems by searching
Solving problems by searching
Solving problems by searching
Solving Problems by Searching
Solving problems by searching
Presentation transcript:

University College Cork (Ireland) Department of Civil and Environmental Engineering Course: Engineering Artificial Intelligence Dr. Radu Marinescu Lecture 2

University College Cork (Ireland) Department of Civil and Environmental Engineering Fundamental issues for most AI problems o Representation o Search o Inference o Planning o Learning R. Marinescu October-2009page 2

University College Cork (Ireland) Department of Civil and Environmental Engineering Representation o Facts about the world have to be represented in some way, e.g., mathematical logic o Deals with: What to represent and how to represent? How to structure knowledge? What is explicit and what must be inferred? How to encode “rules”? How to deal with incomplete, inconsistent and probabilistic knowledge? What kinds of knowledge are required to solve problems? R. Marinescu October-2009page 3

University College Cork (Ireland) Department of Civil and Environmental Engineering Search o Many tasks can be viewed as searching a very large problem space for a solution For example, Tic-Tac-Toe has 765 states, Chess has about 2 50 states, while Go has about states R. Marinescu October-2009page 4

University College Cork (Ireland) Department of Civil and Environmental Engineering Inference o From some facts others can be inferred (related to search) For example, knowing "All elephants have trunks" and "Clyde is an elephant," can we answer the question "Does Clyde have a trunk?" What about "Peanuts has a trunk, is it an elephant?" Or "Peanuts lives in a tree and has a trunk, is it an elephant?” R. Marinescu October-2009page 5

University College Cork (Ireland) Department of Civil and Environmental Engineering Learning and planning o Learning Learn new facts about the world: e.g., machine learning o Planning Starting with general facts about the world, facts about the effects of basic actions, facts about a particular situation, and a statement of a goal generate a strategy for achieving that goal in terms of a sequence of primitive steps or actions R. Marinescu October-2009page 6

University College Cork (Ireland) Department of Civil and Environmental Engineering Fundamental issues for most AI problems o Representation o Search o Inference o Planning o Learning R. Marinescu October-2009page 7

University College Cork (Ireland) Department of Civil and Environmental Engineering Search o Main idea: Search allows exploring alternatives o Background o State space representation o Uninformed vs. informed o Any path vs. optimal path o Implementation and performance R. Marinescu October-2009page 8

University College Cork (Ireland) Department of Civil and Environmental Engineering Trees and graphs R. Marinescu October-2009page 9 C B A Tree root Terminal (leaf) Link (edge) B is parent of C C is child of B A is ancestor of C C is descendant of A

University College Cork (Ireland) Department of Civil and Environmental Engineering Trees and graphs R. Marinescu October-2009page 10 C B A Tree root Terminal (leaf) Link (edge) B is parent of C C is child of B A is ancestor of C C is descendant of A Directed Graph (one way streets)

University College Cork (Ireland) Department of Civil and Environmental Engineering Trees and graphs R. Marinescu October-2009page 11 C B A Tree root Terminal (leaf) Link (edge) B is parent of C C is child of B A is ancestor of C C is descendant of A Directed Graph (one way streets) Undirected Graph (two way streets)

University College Cork (Ireland) Department of Civil and Environmental Engineering Examples of graphs R. Marinescu October-2009page 12 San Fran Boston Wash DC LA Dallas Airline routes

University College Cork (Ireland) Department of Civil and Environmental Engineering Examples of graphs R. Marinescu October-2009page 13 San Fran Boston Wash DC LA Dallas Airline routes Planning actions (graph of possible states of the world) ABC AB C A B C A C B B A C Put C on A Put C on B Put B on C Put A on C Put C on A

University College Cork (Ireland) Department of Civil and Environmental Engineering Problem solving paradigm o What are the states? (All relevant aspects of the problem) Arrangement of parts (to plan an assembly) Positions of trucks (to plan package distribution) Cities (to plan a trip) Set of facts (e.g., to prove a mathematical theorem) o What are the actions (operators)? (deterministic, discrete) Assemble two parts Move a truck to a new position Fly to a new city Apply a theorem to derive a new fact o What is the goal test? (Condition for success) All parts in place All packages delivered Reached destination city Derived goal fact R. Marinescu October-2009page 14

University College Cork (Ireland) Department of Civil and Environmental Engineering Example: holiday in Romania o On vacation in Romania, currently in Arad o Flight home leaves tomorrow from Bucharest R. Marinescu October-2009page 15

University College Cork (Ireland) Department of Civil and Environmental Engineering Example: holiday in Romania o Goal Be in Bucharest o State-space States: various cities Actions: drive between cities o Solution Sequence of actions to destination R. Marinescu October-2009page 16

University College Cork (Ireland) Department of Civil and Environmental Engineering Solution to the holiday problem R. Marinescu October-2009page 17 Solution: go(Sibiu), go(Fagaras), go(Bucharest) Cost: = 450

University College Cork (Ireland) Department of Civil and Environmental Engineering State-space problem formulation o A problem is defined by 4 items: Initial state: e.g., in(Arad) Actions or successor function: S(X) = set of action-state pairs  e.g., S(Arad) = {,, } Goal test: e.g., in(Bucharest) Path cost (additive)  e.g., sum of distances to drive o A solution is a sequence of actions leading from the initial state to a goal state R. Marinescu October-2009page 18

University College Cork (Ireland) Department of Civil and Environmental Engineering Vacuum cleaner state space o States: location of dirt and robot o Initial state: any o Actions: move robot left, right and suck o Goal state: no dirt at all locations o Path cost: 1 per action R. Marinescu October-2009page 19

University College Cork (Ireland) Department of Civil and Environmental Engineering 8-queen puzzle state space o States: arrangements of n ≤ 8 queens in the leftmost n columns, 1 per column, such that no queen attacks another o Initial state: no queens on the board o Actions: add queen to the leftmost empty column such that it is not attacked by any other queen o Goal state: 8 queens on the board, none attacked o Path cost: 1 per action R. Marinescu October-2009page 20

University College Cork (Ireland) Department of Civil and Environmental Engineering Sliding tile puzzle state space o States o Initial state o Actions o Goal state o Path cost R. Marinescu October-2009page 21 Try yourselves

University College Cork (Ireland) Department of Civil and Environmental Engineering Sliding tile puzzle state space o States: locations of tiles o Initial state: given (left) o Actions: move blank left, right, up, down o Goal state: given (right) o Path cost: 1 per action R. Marinescu October-2009page 22

University College Cork (Ireland) Department of Civil and Environmental Engineering Sliding tile puzzle state space R. Marinescu October-2009page 23

University College Cork (Ireland) Department of Civil and Environmental Engineering Search algorithms o Basic idea Exploration of state space graph by generating successors of already- explored states (a.k.a. expanding states) Every states is evaluated: is it a goal state ? R. Marinescu October-2009page 24

University College Cork (Ireland) Department of Civil and Environmental Engineering Terminology o State – Used to refer to the vertices in the underlying graph that is being searched, that is states in the problem domain, for example, a city, an arrangement of blocks or the arrangement of parts in a puzzle o Search node – Refers to the vertices in the search tree that is being generated by the search algorithm. Each node refers to a state of the world; many nodes may refer to the same state. Importantly, a node implicitly represents a path (from the start state of the search tree to the state associated with the node). Because search nodes are part of the search tree, they have a unique ancestor node (except for the root node) R. Marinescu October-2009page 25

University College Cork (Ireland) Department of Civil and Environmental Engineering Terminology: more details o A state is a (representation of) a physical configuration o A node is a data structure constituting part of a search tree contains info such as: state, parent node, action, path cost g(x), depth R. Marinescu October-2009page 26

University College Cork (Ireland) Department of Civil and Environmental Engineering Search strategies o A search strategy is defined by picking the order of node expansion o Search strategies are evaluated along the following dimensions: completeness: does it always find a solution if one exists? time complexity: number of nodes generated space complexity: maximum number of nodes in memory optimality: does it always find a least-cost solution? o Time and space complexity are measured in terms of b: maximum branching factor of the search tree d: depth of the search tree R. Marinescu October-2009page 27

University College Cork (Ireland) Department of Civil and Environmental Engineering Classes of search o Any path search Uninformed search Informed search o Optimal path search Uninformed search Informed search R. Marinescu October-2009page 28

University College Cork (Ireland) Department of Civil and Environmental Engineering Classes of search R. Marinescu October-2009page 29 ClassNameOperation Any PathDepth-FirstSystematic exploration of whole tree UninformedBreadth-Firstuntil a goal node is found. Any PathBest-FirstUses heuristic measure of goodness Informedof a state, e.g. estimated distance to goal. OptimalUniform-CostUses path “length” measure. UninformedFinds shortest path. OptimalA*Uses path “length” measure and heuristic InformedFinds shortest path.

University College Cork (Ireland) Department of Civil and Environmental Engineering Simple search algorithm o A search node is a path from some state X to the start state, e.g., (X B A S) o The state of a search node is the most recent state of the path, e.g., X o Let Q be a list of search nodes, e.g., ((X B A S) (C B A S) …) o Let S be the start state 1.Initialize Q with search node (S) as only entry, set Visited = (S) 2.If Q is empty, fail. Else, pick some node N from Q 3.If state(N) is goal, return N (we’ve reached the goal) 4.(Otherwise) Remove N from Q 5.Find all descendants of state(N) not in Visited and create all the one-step extensions of N to each descendant 6.Add the extended paths to Q; add children of state(N) to Visited 7.Go to step 2. R. Marinescu October-2009page 30

University College Cork (Ireland) Department of Civil and Environmental Engineering Simple search algorithm o A search node is a path from some state X to the start state, e.g., (X B A S) o The state of a search node is the most recent state of the path, e.g., X o Let Q be a list of search nodes, e.g., ((X B A S) (C B A S) …) o Let S be the start state 1.Initialize Q with search node (S) as only entry, set Visited = (S) 2.If Q is empty, fail. Else, pick some node N from Q 3.If state(N) is goal, return N (we’ve reached the goal) 4.(Otherwise) Remove N from Q 5.Find all descendants of state(N) not in Visited and create all the one-step extensions of N to each descendant 6.Add the extended paths to Q; add children of state(N) to Visited 7.Go to step 2. R. Marinescu October-2009page 31 Critical decisions: Step 2: picking N from Q Step 6: adding extensions of N to Q

University College Cork (Ireland) Department of Civil and Environmental Engineering Implementing the search strategies o Depth-first Pick first element of Q Add path extensions to front of Q o Breadth-first Pick first element of Q Add path extensions to end of Q R. Marinescu October-2009page 32

University College Cork (Ireland) Department of Civil and Environmental Engineering Terminology o Visited – a state M is first visited when a path to M first gets added to Q. In general, a state is said to have been visited if it has ever shown up in a search node in Q. The intuition is that we have briefly “visited” them to place them in Q, but we have not yet examined them carefully. o Expanded – a state M is expanded when it is the state of a search node that is pulled off of Q. At that point, the descendants of M are visited and the path that led to M is extended to the eligible descendants. We sometimes refer to the search node that led to M (instead of M itself) as being expanded. However, once a node is expanded we are done with it; we will not need to expand it again. In fact, we discard it from Q R. Marinescu October-2009page 33

University College Cork (Ireland) Department of Civil and Environmental Engineering Depth-First R. Marinescu October-2009page 34 S A B C D G Pick first element of Q; Add path extensions to front of Q QVisited Added paths in blue We show the paths in reversed order; the node’s state is the first entry

University College Cork (Ireland) Department of Civil and Environmental Engineering Depth-First R. Marinescu October-2009page 35 S A B C D G Pick first element of Q; Add path extensions to front of Q QVisited 1(S)S Added paths in blue We show the paths in reversed order; the node’s state is the first entry 1

University College Cork (Ireland) Department of Civil and Environmental Engineering Depth-First R. Marinescu October-2009page 36 S A B C D G Pick first element of Q; Add path extensions to front of Q QVisited 1(S)S 2(A S) (B S)A, B, S Added paths in blue We show the paths in reversed order; the node’s state is the first entry 1 2

University College Cork (Ireland) Department of Civil and Environmental Engineering Depth-First R. Marinescu October-2009page 37 S A B C D G Pick first element of Q; Add path extensions to front of Q QVisited 1(S)S 2(A S) (B S)A, B, S 3(C A S) (D A S) (B S)C, B, A, S 4 5 Added paths in blue We show the paths in reversed order; the node’s state is the first entry 1 2 3

University College Cork (Ireland) Department of Civil and Environmental Engineering Depth-First R. Marinescu October-2009page 38 S A B C D G Pick first element of Q; Add path extensions to front of Q QVisited 1(S)S 2(A S) (B S)A, B, S 3(C A S) (D A S) (B S)C, B, A, S 4(D A S) (B S)C, D, B, A, S 5 Added paths in blue We show the paths in reversed order; the node’s state is the first entry

University College Cork (Ireland) Department of Civil and Environmental Engineering Depth-First R. Marinescu October-2009page 39 S A B C D G Pick first element of Q; Add path extensions to front of Q QVisited 1(S)S 2(A S) (B S)A, B, S 3(C A S) (D A S) (B S)C, B, A, S 4(D A S) (B S)C, D, B, A, S 5(G D A S) (B S)G, C, D, B, A, S Added paths in blue We show the paths in reversed order; the node’s state is the first entry

University College Cork (Ireland) Department of Civil and Environmental Engineering Depth-First R. Marinescu October-2009page 40 S A B C D G Pick first element of Q; Add path extensions to front of Q QVisited 1(S)S 2(A S) (B S)A, B, S 3(C A S) (D A S) (B S)C, B, A, S 4(D A S) (B S)C, D, B, A, S 5(G D A S) (B S)G, C, D, B, A, S Added paths in blue We show the paths in reversed order; the node’s state is the first entry

University College Cork (Ireland) Department of Civil and Environmental Engineering Depth-First: another (easier?) way to see it R. Marinescu October-2009page 41 S A B C D G S A B 1 1 Numbers indicate order pulled off of Q (expanded) Blue fill = Visited & Expanded Gray fill = Visited

University College Cork (Ireland) Department of Civil and Environmental Engineering Depth-First: another (easier?) way to see it R. Marinescu October-2009page 42 S A B C D G S A B 1 1 Numbers indicate order pulled off of Q (expanded) Blue fill = Visited & Expanded Gray fill = Visited CD 2 2

University College Cork (Ireland) Department of Civil and Environmental Engineering Depth-First: another (easier?) way to see it R. Marinescu October-2009page 43 S A B C D G S A B 1 1 Numbers indicate order pulled off of Q (expanded) Blue fill = Visited & Expanded Gray fill = Visited CD

University College Cork (Ireland) Department of Civil and Environmental Engineering Depth-First: another (easier?) way to see it R. Marinescu October-2009page 44 S A B C D G S A B 1 1 Numbers indicate order pulled off of Q (expanded) Blue fill = Visited & Expanded Gray fill = Visited CD CG 4 4 NB: C is not visited again

University College Cork (Ireland) Department of Civil and Environmental Engineering Depth-First: another (easier?) way to see it R. Marinescu October-2009page 45 S A B C D G S A B 1 1 Numbers indicate order pulled off of Q (expanded) Blue fill = Visited & Expanded Gray fill = Visited CD CG

University College Cork (Ireland) Department of Civil and Environmental Engineering Implementing the search strategies o Depth-first Pick first element of Q Add path extensions to front of Q o Breadth-first Pick first element of Q Add path extensions to end of Q R. Marinescu October-2009page 46

University College Cork (Ireland) Department of Civil and Environmental Engineering Breadth-First R. Marinescu October-2009page 47 Pick first element of Q; Add path extensions to end of Q S A B C D G QVisited 1(S)S Added paths in blue We show the paths in reversed order; the node’s state is the first entry

University College Cork (Ireland) Department of Civil and Environmental Engineering Breadth-First R. Marinescu October-2009page 48 Pick first element of Q; Add path extensions to end of Q S A B C D G QVisited 1(S)S 2(A S) (B S)A, B, S Added paths in blue We show the paths in reversed order; the node’s state is the first entry 1

University College Cork (Ireland) Department of Civil and Environmental Engineering Breadth-First R. Marinescu October-2009page 49 Pick first element of Q; Add path extensions to end of Q S A B C D G QVisited 1(S)S 2(A S) (B S)A, B, S 3(B S) (C A S) (D A S)C, D, B, A, S Added paths in blue We show the paths in reversed order; the node’s state is the first entry 1 2

University College Cork (Ireland) Department of Civil and Environmental Engineering Breadth-First R. Marinescu October-2009page 50 Pick first element of Q; Add path extensions to end of Q S A B C D G QVisited 1(S)S 2(A S) (B S)A, B, S 3(B S) (C A S) (D A S)C, D, B, A, S 4(C A S) (D A S) (G B S)*G, C, D, B, A, S 5 6 Added paths in blue We show the paths in reversed order; the node’s state is the first entry * We could have stopped here, when the first path to the goal was generated 1 2 3

University College Cork (Ireland) Department of Civil and Environmental Engineering Breadth-First R. Marinescu October-2009page 51 Pick first element of Q; Add path extensions to end of Q S A B C D G QVisited 1(S)S 2(A S) (B S)A, B, S 3(B S) (C A S) (D A S)C, D, B, A, S 4(C A S) (D A S) (G B S)*G, C, D, B, A, S 5(D A S) (G B S)G, C, D, B, A, S 6 Added paths in blue We show the paths in reversed order; the node’s state is the first entry * We could have stopped here, when the first path to the goal was generated

University College Cork (Ireland) Department of Civil and Environmental Engineering Breadth-First R. Marinescu October-2009page 52 Pick first element of Q; Add path extensions to end of Q S A B C D G QVisited 1(S)S 2(A S) (B S)A, B, S 3(B S) (C A S) (D A S)C, D, B, A, S 4(C A S) (D A S) (G B S)*G, C, D, B, A, S 5(D A S) (G B S)G, C, D, B, A, S 6 Added paths in blue We show the paths in reversed order; the node’s state is the first entry * We could have stopped here, when the first path to the goal was generated

University College Cork (Ireland) Department of Civil and Environmental Engineering Breadth-First R. Marinescu October-2009page 53 Pick first element of Q; Add path extensions to end of Q S A B C D G QVisited 1(S)S 2(A S) (B S)A, B, S 3(B S) (C A S) (D A S)C, D, B, A, S 4(C A S) (D A S) (G B S)*G, C, D, B, A, S 5(D A S) (G B S)G, C, D, B, A, S 6(G B S)G, C, D, B, A, S Added paths in blue We show the paths in reversed order; the node’s state is the first entry * We could have stopped here, when the first path to the goal was generated

University College Cork (Ireland) Department of Civil and Environmental Engineering Breadth-First R. Marinescu October-2009page 54 Pick first element of Q; Add path extensions to end of Q S A B C D G QVisited 1(S)S 2(A S) (B S)A, B, S 3(B S) (C A S) (D A S)C, D, B, A, S 4(C A S) (D A S) (G B S)*G, C, D, B, A, S 5(D A S) (G B S)G, C, D, B, A, S 6(G B S)G, C, D, B, A, S Added paths in blue We show the paths in reversed order; the node’s state is the first entry * We could have stopped here, when the first path to the goal was generated

University College Cork (Ireland) Department of Civil and Environmental Engineering Breadth-First: another (easier?) way to see it R. Marinescu October-2009page 55 S A B C D G S A B 1 CD DG 6 Numbers indicate order pulled off of Q (expanded) Blue fill = Visited & Expanded Gray fill = Visited NB: D is not visited again

University College Cork (Ireland) Department of Civil and Environmental Engineering Worst case running time o The number of states in the search space may be exponential in the some “depth” parameter, e.g. number of actions in a plan, number of moves in a game o All searches may have to visit each state at least one, in the worst case o So, all searches will have worst case running times that are at least proportional to the total number of states and therefore exponential in the “depth” parameter R. Marinescu October-2009page 56 b=2 d=0 d=1 d=2 d is depth b is branching factor b d < (b d+1 – 1) / (b - 1) < b d+1 states in tree Max Time α Max # Visited

University College Cork (Ireland) Department of Civil and Environmental Engineering Worst case space R. Marinescu October-2009page 57 Depth-first max Q size (b – 1)d ≈ bd visited expanded Max Q size = Max(#Visited - #Expanded) Breadth-first max Q size b d

University College Cork (Ireland) Department of Civil and Environmental Engineering Cost performance of any-path methods R. Marinescu October-2009page 58 SearchWorst FewestGuaranteed to MethodTimeSpaceStatesfind path? Depth-Firstb d+1 bdNoYes* Breadth-Firstb d+1 bdbd Yes Searching a tree with branching factor b and depth d (without a Visited list) * If there are no infinitely long paths in the search space Worst case time is proportional to the number of nodes added to Q Worst case space is proportional to the maximal length of Q

University College Cork (Ireland) Department of Civil and Environmental Engineering Space (the final frontier) o In large search problems, memory is often the limiting factor o Imagine searching a tree with branching factor 8 and depth 10. Assume a node requires just 8 bytes of storage. The, breadth- first search might require up to (2 3 ) 10 x 2 3 = 2 33 bytes = 8,000 Mbytes = 8 Gbytes o One strategy is to trade time for memory. For example, we can emulate breadth-first search by repeated application of depth- first search, each up to a preset depth limit. This is called iterative deepening search (IDS) 1.C = 1 2.Do DFS to max depth C. If path found, return it 3.Otherwise, increment C and go to 2. R. Marinescu October-2009page 59

University College Cork (Ireland) Department of Civil and Environmental Engineering Summary o State-space formulation Abstract representation of the problem o Search for a solution Depth-first search : exponential time, linear space Breadth-first search : exponential time, exponential space, but finds the “shallowest” goal Iterative deepening search : trades off time for space (simulates breadth-first search) o Readings Chapter 3 in R&N book R. Marinescu October-2009page 60