real world search problems cs 331 artificial intelligence
play

Real World Search Problems CS 331: Artificial Intelligence - PDF document

Real World Search Problems CS 331: Artificial Intelligence Uninformed Search 1 2 Assumptions About Our Simpler Search Problems Environment Fully Observable Deterministic Sequential Static Discrete Single-agent 3 4


  1. Real World Search Problems CS 331: Artificial Intelligence Uninformed Search 1 2 Assumptions About Our Simpler Search Problems Environment • Fully Observable • Deterministic • Sequential • Static • Discrete • Single-agent 3 4 Example: Oregon Search Problem Formulation Portland S = {Coos Bay, Newport, A search problem has 5 components: Corvallis, Junction City, McMinnville 1. A finite set of states S Eugene, Medford, Albany, Salem 2. A non-empty set of initial states I  S Lebanon, Salem, Initial State 3. A non-empty set of goal states G  S Portland, McMinnville} Lebanon Albany 4. A successor function succ(s) which takes a state I = {Corvallis} Corvallis Newport s as input and returns as output the set of states G={Medford} you can reach from state s in one step. Junction Coos City 5. A cost function cost(s,s’) which returns the non- Bay Succ(Corvallis)={Albany, Eugene Newport, McMinnville, negative one-step cost of travelling from state s to s’ . The cost function is only defined if s’ is a Junction City} successor state of s . Cost(s,s’) = 1 for all transitions Medford Goal State 5 6 1

  2. Search Tree Results of a Search Problem • Solution Start with Initial State Corvallis Path from initial state to goal state Junction Eugene Medford Corvallis City • Solution quality Path cost (3 in this case) • Optimal solution Lowest path cost among all solutions (In this case, we found the optimal solution) 7 8 Search Tree Search Tree Is initial state the goal? Apply Successor() Corvallis Corvallis function • Yes, return solution • No, apply Successor() Junction Junction McMinnville Albany Newport McMinnville Albany Newport function City City Queue McMinnville These nodes have not been Albany expanded yet. Call them the Junction City fringe. We’ll put them in a Newport queue. 9 10 Search Tree Search Tree Queue Queue Corvallis Corvallis Albany Albany Junction City Junction City Junction Junction McMinnville Albany Newport McMinnville Albany Newport City Newport City Newport Portland Portland Portland Portland Now remove a node from the queue. If it’s a goal Things to note: state, return the solution. Otherwise, call • Order in which you expand nodes (in this Successor() on it, and put the results in the queue. example, we took the first node in the queue) Repeat. • Avoid repeated states 11 2

  3. Tree-Search Pseudocode Tree-Search Pseudocode Note: Goal test happens after we grab a node off the queue. 13 14 Tree-Search Pseudocode Uninformed Search • No info about states other than generating successors and recognizing goal states • Later on we’ll talk about informed search – Why are these parent node backpointers are important? can tell if a non-goal state is more promising than another 15 16 Evaluating Uninformed Search Complexity • Completeness Branching factor (b) – maximum number of 1. Is the algorithm guaranteed to find a solution successors of any node when there is one? 2. Depth (d) of the shallowest goal node • Optimality 3. Maximum length (m) of any path in the search Does it find the optimal solution? space • Time complexity How long does it take to find a solution? Time Complexity: number of nodes generated during • Space complexity search How much memory is needed to perform the Space Complexity: maximum number of nodes search stored in memory 17 18 3

  4. Uninformed Search Algorithms Breadth-First Search • Breadth-first search • Expand all nodes at a given depth before • Uniform-cost search any nodes at the next level are expanded • Implement with a FIFO queue • Depth-first search • Depth-limited search • Iterative Deepening Depth-first Search • Bidirectional search 19 20 Breadth First Search Example Breadth First Search Example A A A A B C B C B C B C D E F G D E F G D E F G D E F G Not yet reached Closed (expanded) nodes Not yet reached Closed (expanded) nodes Open nodes (on the fringe) Current node to be expanded Open nodes (on the fringe) Current node to be expanded 21 22 Evaluating BFS Evaluating BFS Complete? Complete? Yes provided branching factor is finite Optimal? Optimal? Time Complexity Time Complexity Space Complexity Space Complexity 23 24 4

  5. Evaluating BFS Evaluating BFS Complete? Yes provided branching factor is Complete? Yes provided branching factor is finite finite Optimal? Yes if step costs are identical Optimal? Yes if step costs are identical b+b 2 +b 3 +…+b d +(b d+1 -b)= Time Complexity Time Complexity O(b d+1 ) Space Complexity Space Complexity 25 26 Evaluating BFS Uniform-cost Search • What if step costs are not equal? Complete? Yes provided branching factor is finite • Recall that BFS expands the shallowest node Optimal? Yes if step costs are identical • Now we expand the node with the lowest path cost • Uses priority queues b+b 2 +b 3 +…+b d +(b d+1 -b)= Time Complexity O(b d+1 ) Space Complexity O(b d+1 ) Note: Gets stuck if there is a zero-cost action leading back to the same state. For completeness and optimality, we require the cost of every step to be ≥  Exponential time and space complexity make BFS impractical for all but the smallest problems 27 28 Evaluating Uniform-cost Search Evaluating Uniform-cost Search Complete? Complete? Yes provided branching factor is finite and step costs ≥  for small positive  Optimal? Optimal? Time Complexity Time Complexity Space Complexity Space Complexity 29 30 5

  6. Evaluating Uniform-cost Search Evaluating Uniform-cost Search Complete? Yes provided branching factor is Complete? Yes provided branching factor is finite and step costs ≥  for small finite and step costs ≥  for small positive  positive  Optimal? Yes Optimal? Yes O(b 1+floor(C*/  ) ) where C* is the Time Complexity Time Complexity cost of the optimal solution Space Complexity Space Complexity 31 32 Evaluating Uniform-cost Search Depth-first Search • Expands the deepest node in the current Complete? Yes provided branching factor is finite and step costs ≥  for small fringe of the search tree positive  • Implemented with a LIFO queue Optimal? Yes O(b 1+floor(C*/  ) ) where C* is the Time Complexity cost of the optimal solution O(b 1+floor(C*/  ) ) where C* is the Space Complexity cost of the optimal solution 33 34 Depth-first Search Example Depth-first Search Example A A A A A A B C B C B C B C B C B C D E F G D E F G D E F G D E F G D E F G D E F G H I J K L M N O H I J K L M N O H I J K L M N O H I J K L M N O H I J K L M N O H I J K L M N O A A A A A A B C B C B C B C B C B C D E F G D E F G D E F G D E F G D E F G D E F G H I J K L M N O H I J K L M N O H I J K L M N O H I J K L M N O H I J K L M N O H I J K L M N O Not yet reached Expanded nodes on current path Current node to be Not yet reached Expanded nodes on current path Current node to be expanded expanded Expanded nodes with no Expanded nodes with no On fringe but On fringe but M Goal state M Goal state descendants in the fringe (can be descendants in the fringe (can be unexpanded unexpanded removed from memory) removed from memory) 6

  7. Evaluating Depth-first Search Evaluating Depth-first Search Complete? Complete? Yes on finite graphs. No if there is an infinitely long path with no Optimal? solutions. Optimal? Time Complexity Time Complexity Space Complexity Space Complexity 37 38 Evaluating Depth-first Search Evaluating Depth-first Search Complete? Yes on finite graphs. No if there is Complete? Yes on finite graphs. No if there is an infinitely long path with no an infinitely long path with no solutions. solutions. Optimal? No (Could expand a much longer Optimal? No (Could expand a much longer path than the optimal one first) path than the optimal one first) Time Complexity Time Complexity O(b m ) Space Complexity Space Complexity 39 40 Evaluating Depth-first Search Depth-limited Search • Solves infinite path problem by using Complete? Yes on finite graphs. No if there is an infinitely long path with no predetermined depth limit l solutions. • Nodes at depth l are treated as if they have no successors Optimal? No (Could expand a much longer • Can use knowledge of the problem to path than the optimal one first) determine l (but in general you don’t know Time Complexity O(b m ) this in advance) Space Complexity O(bm) 41 42 7

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