outline
play

Outline Problem solving agents and search Solving Problems by - PDF document

Outline Problem solving agents and search Solving Problems by Examples Properties of search algorithms Searching Uninformed search CS486/686 Breadth first Depth first University of Waterloo Iterative Deepening


  1. Outline • Problem solving agents and search Solving Problems by • Examples • Properties of search algorithms Searching • Uninformed search CS486/686 – Breadth first – Depth first University of Waterloo – Iterative Deepening May 5th, 2005 1 2 CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart Introduction Problem-solving agents • Search was one of the first topics studied in AI – Newell and Simon (1961) General Problem Solver • Central component to many AI systems – Automated reasoning, theorem proving, robot navigation, VLSI layout, scheduling, game playing,… 3 4 CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart Example: Traveling in Romania Examples of Search Problems Oradea 71 Neamt 7 2 4 1 2 Zerind 87 151 75 Iasi Start Arad 5 6 3 4 5 140 92 Sibiu Fagaras 99 118 Vaslui 8 3 1 6 7 8 80 Rimnicu Vilcea Timisoara 142 Start State Goal State 211 111 Pitesti Lugoj 97 70 98 Hirsova 146 85 States: Locat ions of 8 t iles and blank States: Arr angement of 0 t o 8 queens on Mehadia 101 Urziceni 86 75 138 t he boar d Bucharest I nitial State: Any st at e Dobreta 120 End 90 I nitial State: No queens on t he boar d Craiova Eforie Giurgiu Succ Func: Gener at es legal st at es t hat r esult f rom t r ying 4 act ions (blank up, Succ Func: Add a queen t o an empt y Formulat e Goal Formulat e P roblem Find a solut ion down, lef t , r ight ) space Get t o Bucharest I nit ial st at e: I n(Ar ad) Sequence of cit ies: Ar ad, Sibiu, Fagar as, Buchar est Goal test: Does st at e mat ch desir ed Goal test: 8 queens on boar d, none Act ions: Drive bet ween cit ies conf igur at ion at t acked Goal Test : I n(Bucharest )? P at h cost : Dist ance bet ween cit ies Path cost: Number of st eps Path cost: 5 6 CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart 1

  2. More Examples Common Characteristics • All of those examples are – Fully observable – Deterministic – Sequential – Static – Discrete – Single agent • Can be tackled by simple search techniques 7 8 CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart Cannot tackle these yet… Cannot tackle these yet… I nf init e number of st at es Chance Games against an adversary Hidden st at es All of t he above 9 10 CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart Searching Data Structures for Search • Basic data structure: Search Node • We can formulate a search problem – State – Now need to find the solution – Parent node and operator applied to parent to reach • We can visualize a state space search in terms current node of trees or graphs – Cost of the path so far – Nodes correspond to states – Depth of the node – Edges correspond to taking actions P ARENT− N ODE A CTION = right • We will be studying search trees 5 4 5 4 Node D EPTH = 6 P C OST = 6 S TATE ATH− – These trees are constructed “on the fly” by our 6 6 1 1 8 8 algorithms 7 7 3 3 2 2 11 12 CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart 2

  3. Expanding Nodes Generic Search Algorithm • Expanding a node – Applying all legal operators to the state contained in the 1. Initialize search algorithm with initial state of node and generating nodes for all corresponding the problem successor states 2. Repeat (a) The initial state Arad Sibiu Timisoara Zerind 1. If no candidate nodes can be expanded, return failure Arad Fagaras Oradea Rimnicu Vilcea Arad Lugoj Arad Oradea 2. Choose leaf node for expansion, according to (b) After expanding Arad Arad search strategy Sibiu Timisoara Zerind 3. If node contains a goal state, return solution Arad Fagaras Oradea Rimnicu Vilcea Arad Lugoj Arad Oradea 4. Otherwise, expand the node, by applying legal (c) After expanding Sibiu Arad operators to the state within the node. Add Sibiu Timisoara Zerind resulting nodes to the tree Arad Fagaras Oradea Rimnicu Vilcea Arad Lugoj Arad Oradea 13 14 CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart Implementation Details Breadth-first search • We need to only keep track of nodes that need to be expanded (fringe) All nodes on a given depth are expanded before any – Done by using a (prioritized) queue nodes on the next level are expanded. Implemented with a FIFO queue 1. Initialize queue by inserting the node corresponding to the initial state of the problem A A A A 2. Repeat 1. If queue is empty, return failure B C B C B C B C 2. Dequeue a node 3. If the node contains a goal state, return solution D E F G D E F G D E F G D E F G 4. Otherwise, expand node by applying legal operators to the state within. Insert resulting nodes into queue A B,C C,D,E D,E,F,G Search algorit hms dif f er in t heir queuing f unct ion! 15 16 CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart Evaluating search algorithms Judging BFS • Completeness: Is the algorithm guaranteed to find a • Complete: Yes, if b is finite solution if a solution exists? • Optimality: Does the algorithm find the optimal solution • Optimal: Yes, if all costs are the same (Lowest path cost of all solutions) • Time: 1+b+b 2 +b 3 +…+b d = O(b d ) • Time complexity • Space complexity • Space: O(b d ) Variables b Branching factor d Depth of shallowest goal node All uninformed search methods will have m Maximum length of any path in the state space exponential time complexity � 17 18 CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart 3

  4. Uniform Cost Search Depth-first search • A variation of breadth-first search – Instead of expanding shallowest node it expands the node with The deepest node in the current fringe of the search lowest path cost tree is expanded first. – Implemented using a priority queue Implemented with a stack (LIFO queue) C* is cost of optimal solution ε is minimum action cost Tim e: O(b ceiling(C* / ε ) ) Optim al Com plete if ε > 0 Space : O(b ceiling(C* / ε ) ) 19 20 CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart Depth-first search Depth-first search The deepest node in the current fringe of the search The deepest node in the current fringe of the search tree is expanded first. tree is expanded first. Implemented with a stack (LIFO queue) Implemented with a stack (LIFO queue) 21 22 CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart Depth-first search Depth-first search The deepest node in the current fringe of the search The deepest node in the current fringe of the search tree is expanded first. tree is expanded first. Implemented with a stack (LIFO queue) Implemented with a stack (LIFO queue) 23 24 CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart CS486/686 Lecture Slides (c) 2005 K. Larson and P.Poupart 4

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend