uninformed search
play

Uninformed Search Depth First Search Iterative Deepening Volker - PowerPoint PPT Presentation

Intro to AI: Lecture 2 Volker Sorge States and Actions Background for Search Breadth First Search Uninformed Search Depth First Search Iterative Deepening Volker Sorge Uniform Cost Search Intro to AI: States Lecture 2 Volker Sorge


  1. Intro to AI: Lecture 2 Volker Sorge States and Actions Background for Search Breadth First Search Uninformed Search Depth First Search Iterative Deepening Volker Sorge Uniform Cost Search

  2. Intro to AI: States Lecture 2 Volker Sorge States and Actions In problem solving, states represent configurations of that Background for Search problem. Thereby depending on the problem states can refer Breadth First to: Search ◮ The current progress towards a solution (e.g., in search) Depth First Search Iterative ◮ The state of the environment that is manipulated (e.g., Deepening game play) Uniform Cost Search ◮ The internal state of an agent (e.g., knowledge) Some important concepts are Intial State The start state of the problem. Goal State The solution of the problem or final state. State Space The space of all possible states.

  3. Intro to AI: Actions Lecture 2 Volker Sorge States and Actions Background for Search Actions are transitions from one valid state into another. Breadth First ◮ Action has to be applicable in the current state of the Search problem. Depth First Search Iterative ◮ An action has an effect that changes the state. Deepening Some important concepts are: Uniform Cost Search Path A sequence of actions leading from one state to another. Solution A path leading from the intial state to the goal state.

  4. Intro to AI: Search Problem Lecture 2 Volker Sorge States and Actions Background for Search We define a search problem as: Breadth First Search ◮ A set of states S . Depth First Search ◮ An initial state s ∈ S . Iterative Deepening ◮ A set of goal or final states F ⊆ S . Uniform Cost Search ◮ An action mapping A ⊆ S × S from a state to a (set of) new state(s). What we are often interested in is the size of the state space | S | , which can of course be infinite. ∈

  5. Intro to AI: Example: 15 Puzzle Lecture 2 Volker Sorge 13 10 11 6 1 2 3 4 States and Actions Background for Search 5 7 4 8 5 6 7 8 Breadth First Search 1 12 2 14 9 10 11 12 Depth First Search Iterative 3 15 9 13 14 15 Deepening Uniform Cost Search ◮ A potential initial state on the left. ◮ The goal state on the right. ◮ Actions are valid moves of the tiles. ◮ States are all valid configurations of the puzzle. Mathematically they correspond to all even permutations. ◮ State space size is therefore 16! 2 = 10 , 461 , 394 , 944 , 000

  6. Intro to AI: Graph: Definition Lecture 2 Volker Sorge States and Actions Background for In this section we need the concept of a graph, a very Search common data structure. Graphs are used to represent Breadth First Search relationships between objects. For example, points on a map Depth First Search together with roads that connect them. Iterative Deepening Generally a graph is a collection of objects together with Uniform Cost links between some of these objects. More formally we can Search define a graph G as a pair ( V , E ), where ◮ V is a set of vertices, and ◮ E ⊆ V × V is a set of edges. { . } × ⊆

  7. Intro to AI: Graph: Example Lecture 2 Volker Sorge States and Actions Background for Search Breadth First Search Depth First Search Iterative Deepening Uniform Cost Search Source: Wikipedia V = { 1 , 2 , 3 , 4 , 5 , 6 } E = { (1 , 2) , (1 , 5) , (2 , 3) , (2 , 5) , (3 , 4) , (4 , 5) , (4 , 6) }

  8. Intro to AI: Search Lecture 2 Volker Sorge States and Actions Background for Search Search can then be defined as Breadth First Search ◮ A graph G = ( V , E ), where States are vertices V = S Depth First Search and actions are edges E = A . Iterative Deepening ◮ A method expanding unexplored vertices, i.e., moving Uniform Cost from a vertex to vertices not yet visited. Search ◮ Explored set of already expanded vertices. ◮ Frontier is a set of nodes yet to be expanded. The way we expand the Frontier defines a search strategy.

  9. Intro to AI: Search Tree Lecture 2 Volker Sorge States and Actions Background for Search Breadth First ◮ Search algorithms effectively construct a tree while Search searching the graph. Depth First Search Iterative ◮ Level 0 of the tree consists of the start state s . Deepening ◮ Level n of the tree are nodes whose shortest path to s Uniform Cost Search contains n edges. ◮ A leaf is reached as soon as the next has already been explored (is an element of Explored ).

  10. Intro to AI: Properties of Search Strategies Lecture 2 Volker Sorge States and Actions Background for Search Breadth First Completeness If there exists a solution will we find it? Search Depth First Search Optimality Will we find the shortest possible solution? Iterative Time Complexity How long does it take to find the solution? Deepening Uniform Cost Space Complexity How much memory will we need to find a Search solution? For the latter two we are usually interested in the worst possible case.

  11. Intro to AI: Breadth-First Search Lecture 2 Volker Sorge States and Actions Background for Search Breadth First Search Depth First Search ◮ Search from the start node in a “concentric” way. Iterative Deepening ◮ Expand all nodes of level n before expanding any nodes Uniform Cost Search on level n + 1.

  12. Intro to AI: Algorithm: BFS Lecture 2 Input : Graph G = ( V , E ), Start state s , Set of goal states F Volker Sorge Output : Path P ⊆ E States and Actions 1 begin let Frontier = [ s ]; Background for 2 Search let Explored = { s } ; 3 Breadth First while Frontier � = [] do 4 Search let v ::Frontier = Frontier; 5 Depth First Search if v ∈ F then 6 Iterative return Path( s , v ) 7 Deepening end 8 Uniform Cost else Search 9 let Frontier = Frontier@[ v 1 , . . . , v n ], 10 where ( v , v i ) ∈ E and v i �∈ Explored. let Explored = { v i }∪ Explored; end 11 end 12 return failure ; 13 14 end Usually Frontier is implemented as a priority queue . Observe that despite the algorithm being in pseudo-code, we use some Ocaml notation :: , @, let . �∈ [ . ] : : @ ∪

  13. Intro to AI: Example Lecture 2 Volker Sorge States and Actions Background for Search Breadth First Search Source http://goeurope.about.com Depth First Search Iterative Deepening Uniform Cost Search Getting from Paris to Rome? (Explore in alphabetical order!) ◮ Solution: Paris → Copenhagen → Prague → Vienna → Rome ◮ Have to explore: Every node except Naples.

  14. Intro to AI: Search Tree Lecture 2 Volker Sorge States and Actions Background for Search Level Breadth First 0 Paris Search Depth First Search 1 Amsterdam Copenhagen London Munich Madrid Iterative Deepening 2 Prague Edinburgh Lisbon Marseille Uniform Cost Search 3 Vienna Milan 4 Rome 5 Naples

  15. Intro to AI: Analysis Lecture 2 Volker Sorge States and Actions Background for Search Complete Yes, even for infinite state space. Breadth First Optimal Yes, will always find the shallowest solution. Search Depth First Search Time Complexity Let b be branching factor of the tree, i.e., Iterative the maximum number of nodes expanded in Deepening one move. Let d be the depth of the solution. Uniform Cost Search Then time complexity is O ( b d ). Space Complexity All nodes in the tree have to be kept. Hence space complexity is the same as time complexity: O ( b d ). O

  16. Intro to AI: Breadth-First Search Lecture 2 Volker Sorge States and Actions Background for Search Breadth First Search Depth First Search ◮ Search from the start node along one path as far as Iterative possible before backtracking. Deepening Uniform Cost ◮ Expand the first node of level n as deep as possible Search before expanding the next node on level n .

  17. Intro to AI: Algorithm: DFS Lecture 2 Volker Sorge Input : Graph G = ( V , E ), Start state s , Set of goal states F States and Actions Output : Path P ⊆ E Background for 1 begin Search let Frontier = [ s ]; 2 Breadth First let Explored = {} ; 3 Search while Frontier � = [] do 4 Depth First Search let v ::Frontier = Frontier; 5 Iterative if v ∈ F then 6 Deepening return Path( s , v ) 7 Uniform Cost Search end 8 else 9 let Explored = { v }∪ Explored; 10 let Frontier = [ v 1 , . . . , v n ]@Frontier, 11 where ( v , v i ) ∈ E and v i �∈ Explored. end 12 end 13 return failure ; 14 15 end Usually Frontier is implemented by a stack .

  18. Intro to AI: Example Lecture 2 Volker Sorge States and Actions Background for Search Breadth First Search Source http://goeurope.about.com Depth First Search Iterative Deepening Uniform Cost Search Getting from Paris to Rome? (Explore in alphabetical order!) ◮ Solution: Paris → Copenhagen → Prague → Vienna → Rome ◮ Have to explore: Paris, Amsterdam, Copenhagen, Prague, Vienna, Rome

  19. Intro to AI: Analysis Lecture 2 Volker Sorge States and Actions Background for Complete Not for infinite state space. Search Optimal No, will always find ’left-most’ solution. Breadth First Search Time Complexity Let b be branching factor of the tree, i.e., Depth First Search the maximum number of nodes expanded in Iterative Deepening one move. Let d be the depth of the solution. Uniform Cost Then time complexity is O ( b d ). Search Space Complexity Only the nodes on the most recent path are kept and the successors in each node in the path. Hence space complexity is with respect to the depth of the solution: O ( bd ).

Recommend


More recommend