190 likes | 297 Views
Problem solving in state spaces. State representation and the problem solving agent algorithm. Problem-solving agent. environment described as state space agent actions can change one state to some others current situation is one state in space goal situation is another state
E N D
Problem solvinginstate spaces State representation and the problem solving agent algorithm
Problem-solving agent • environment described as state space • agent actions can change one state to some others • current situation is one state in space • goal situation is another state • problem solving agent finds sequence of actions to move from current to goal state D Goforth - COSC 4117, fall 2006
Problem-solving agent - example A farmer agent traveling with a bag of grain, a fox and a duck comes to a river he must cross on the way to market. There is on the shore a boat so small that he can only take one of his market products across at a time. He cannot leave the fox alone with the duck, nor the duck with the grain. How does he get his produce safely across the river? D Goforth - COSC 4117, fall 2006
What kind of problem? • fully / partly observable • deterministic / stochastic • sequential / episodic • static / dynamic • discrete / continuous • single- / multi-agent D Goforth - COSC 4117, fall 2006
What kind of problem? • fully / partly observable • deterministic / stochastic • sequential / episodic • static / dynamic • discrete / continuous • single- / multi-agent D Goforth - COSC 4117, fall 2006
Utility-based agent Algorithm: • Perceive state • If no plan exists, develop a plan • Act according to plan • internal state representing environment • goals expressed in terms of environment and/or agent states • performance measure rationality • NOT REFLEX; ‘tries’ actions internally and tests results against goals AND performance measure D Goforth - COSC 4117, fall 2006
Utility-based agent’s view Crossing river problem state space: which bank are farmer and produce on? Possible actions: cross river alone or with one item Current state: all on left bank Goal state: all on right bank Problem: plan a sequence of crossings to get from start (left bank) to goal (right) while avoiding other terminal states. D Goforth - COSC 4117, fall 2006
Internal model • State of environment – data structure • Perceptions and actions • Current state • Goal state • “Intelligence” to develop a plan • Possible form of plan: Look-up table or rules or list of actions (perception -> action) D Goforth - COSC 4117, fall 2006
The simple problem solver Restricted form of general agent: Figure 3.1, p.61 function Simple-Problem-Solving-Agent( percept) returns action seq an action sequence, initially empty state some description of the current world state goal a goal, initially null problem a problem formulation state = Update-State(state, percept) if seq is empty (ie – do plan (search) first time only) goal = Formulate-Goal(state) if (state==goal) return nil problem = Formulate-Problem(state, goal) performance seq = Search(problem) action = First(seq) (no replanning) seq = Rest(seq) return action D Goforth - COSC 4117, fall 2006
Problem-solving agent State space: possible locations of four objects: Agent, fox, duck, grain on left or right bank: e.g.: Agent: left fox: left duck: left grain: right State space has 24 = 16 states A f d g L L L R D Goforth - COSC 4117, fall 2006
Problem-solving agent Possible actions: Agent can cross river, taking any object on same side with it. R R L R Af A f d g Ad R L R R L L L R A R L L R D Goforth - COSC 4117, fall 2006
Problem-solving agent Start state: Goal state: F f d g L L L L F f d g R R R R D Goforth - COSC 4117, fall 2006
Problem-solving agent Performance measure: • get to goal state • minimize number of trips • avoid losing produce Constraints: • possible actions • boat size • dangerous combinations of position D Goforth - COSC 4117, fall 2006
Problem-solving agentstate-space and actions R L L L L L L L F Fg Fd Ff R R L L R L R L R L L R F F F L R L L L L R L L L L R Fg Ff Fd Fd Ff Fg R R R L R R L R R L R R F F F L R R L L R L R L L R R Ff Fd Fg R R R R L R R R F
Problem-solving agent (formulate problem)STATES TO AVOID R L L L L L L L R R L L R L R L R L L R L R L L L L R L L L L R R R R L R R L R R L R R L R R L L R L R L L R R R R R R L R R R
R L L L L L L L R R L L R L R L R L L R R R R L L R L L L L R L L L L R Ff R R R L R R L R R L R R 3 L R R L L R L R L L R R R R R R L R R R Problem-solving agent – example Node in search space L L R L F 2 D Goforth - COSC 4117, fall 2006
R L L L L L L L R R L L R L R L R L L R R R R L L R L L L L R L L L L R Ff R R R L R R L R R L R R 3 L R R L L R L R L L R R R R R R L R R R Problem-solving agent – example A solution sequence: Fd F Ff Fd Fg F Fd D Goforth - COSC 4117, fall 2006
The simple problem solver Restricted form of general agent: Figure 3.1, p.61 function Simple-Problem-Solving-Agent( percept) returns action seq an action sequence, initially empty state some description of the current world state goal a goal, initially null problem a problem formulation state = Update-State(state, percept) if seq is empty (ie – do plan (search) first time only) goal = Formulate-Goal(state) if (state==goal) return nil problem = Formulate-Problem(state, goal) performance seq = Search(problem) action = First(seq) seq = Rest(seq) return action Fd F Ff Fd Fg F Fd D Goforth - COSC 4117, fall 2006
General search algorithms Review breadth-first and depth-first traversals in graphs D Goforth - COSC 4117, fall 2006