State Space Search 1/25/16
Reading Quiz Q1: What is the forward branching factor of a node in a search graph? a) The number of paths from the start to the node. b) The number of paths from the node to the goal. c) The number of edges terminating at the node. d) The number of edges originating at the node
When is state space search applicable? ● The world can be described by discrete states. ● The environment is fully observable and deterministic. ● The agent’s objective is to reach some goal state.
The key idea ● Embed states of the world in a graph, where: ○ Each node contains one state. ○ A directed edge (A,B) indicates that some action by the agent can transition the world from state A to state B. ● The agent can then search for a path in the graph from start to goal. ● The sequence of actions along the path constitutes a plan the agent can execute to achieve its goal.
Some important distinctions ● States and nodes are not completely synonymous. ○ A state is a configuration of the world. ○ A node is a data structure. It contains a state, a parent pointer or other connection information, and possibly additional bookkeeping. ● Likewise, actions and edges are related but not identical. ● Start is a state; goal is a proposition. ○ The agent has a fixed start state. ○ There may be many states that achieve the goal. We describe this with a function.
Example: robot navigation ● The state must describe the robot’s location. ○ The state might also need to track package locations, etc. ○ The state may ignore some information (e.g. o105-o107) ● The robot can drive to nearby locations. ○ States between which the robot can drive directly are connected in the search graph. ● We need a start state: o103 ● We need a goal function: state == storage note: this graph is incomplete
Exercise: describe the search space. ● What is the start state? ● What states is it adjacent to? ● What states are those states adjacent to? ○ Start drawing the graph. ● What is the goal function? ● Do we need to track any additional information?
Example: traffic jam puzzle start state one of many states satisfying the goal proposition
Next states reachable in one move from the start state
Exercise: model this as a search problem. ● We are given a 3-quart and 4-quart pitcher. ● The pitchers have no markings that show partial quantities. ● Either pitcher can be filled from a faucet. ● The contents of either pitcher can be poured down a drain. ● Water may be poured from one pitcher to the other until either the pouring pitcher is empty or the receiving pitcher is full. ● We want to measure 2 quarts of water. Describe the state representation. How many total states are there? What is the start state? What are its neighbors? Draw a little bit of the graph. How can we recognize a goal state?
Generic search algorithm Procedure Search( G,S,goal ) add start to frontier Inputs add start to parents G : graph with nodes N and arcs A while frontier not empty and goal not found S : set of start nodes get state from frontier goal : Boolean function of states add state to walls or free Output if state is free path from a member of S to a node for add state to parents which goal is true add neighbors of state to frontier or ⊥ if there are no solution paths end if Local end while Frontier : set of paths Frontier ← { ⟨ s ⟩ : s ∈ S} while ( Frontier ≠{} ) select and remove ⟨ s 0 ,...,s k ⟩ from Frontier if ( goal(s k ) ) then return ⟨ s 0 ,...,s k ⟩ Frontier ← Frontier ∪ { ⟨ s 0 ,...,s k ,s ⟩ : ⟨ s k ,s ⟩ ∈ A} return ⊥
The rest of this week (and the rest of chapter 3) select and remove ⟨ s 0 ,...,s k ⟩ from Frontier ● A FIFO frontier gives breadth-first search. ● A LIFO frontier gives depth-first search. ● A priority queue frontier allows more sophisticated searches. What is an appropriate metric to use for “priority”? What characteristics of the search are we trying to optimize?
Generic search algorithm Procedure Search( G,S,goal ) Inputs G : graph with nodes N and arcs A S : set of start nodes goal : Boolean function of states Output path from a member of S to a node for which goal is true or ⊥ if there are no solution paths Local Frontier : set of paths Frontier ← { ⟨ s ⟩ : s ∈ S} while ( Frontier ≠{} ) select and remove ⟨ s 0 ,...,s k ⟩ from Frontier if ( goal(s k ) ) then return ⟨ s 0 ,...,s k ⟩ Frontier ← Frontier ∪ { ⟨ s 0 ,...,s k ,s ⟩ : ⟨ s k ,s ⟩ ∈ A} return ⊥
Recommend
More recommend