02 - Agent Models and Stated Based Search
02 - Agent Models and Stated Based Search
Alfredo Milani
Overview
Human agent:
eyes, ears, and other organs for sensors;
hands, legs, mouth, and other body parts for
actuators
Robotic agent:
cameras and infrared range finders for sensors; various motors
for actuators
Agents and environments
PEAS:
• Performance measure
• Environment
• Actuators
• Sensors
– Performance measure:
• Time to complete course
– Environment:
• Roads, other traffic, obstacles
– Actuators:
• Steering wheel, accelerator, brake, signal, horn
– Sensors:
• Optical cameras, lasers, sonar, accelerometer,
speedometer, GPS, odometer, engine sensors,
PEAS
Performance measure:
Healthy patient, minimize costs, lawsuits
Environment:
Patient, hospital, staff
Actuators:
Screen display (questions, tests, diagnoses, treatments,
referrals)
Sensors:
Keyboard (entry of symptoms, findings, patient's answers)
Environment types
poker
– Goal-based agents
• Problem-solving agents
– Utility-based agents
• Can distinguish between different goals
• Implicit goals
Others types
– Learning agents
– Multiagents
– Distributed coordinating agents …..
Agent types: Simple Reflex Agent
No history, no memory
Agent types: Reflex Agent with State
• State-space Model
– the agent’s model of the world
– usually a set of discrete states
– e.g., in driving, the states in the model could be towns/cities
• Goal State(s)
– a goal is defined as a desirable state for an agent
– there may be many states which satisfy the goal test
• e.g., drive to a town with a ski-resort
– or just one state which satisfies the goal
• e.g., drive to Mammoth
A ≡ Actions/Operators a A a: SS
(a is executable in some states Ea S)
• Optimizing the solution with respect to a criteria (e.g. shortest path, minimum cost,
highest payoff etc.)
s4 s17
s24 s18
s5 s19
s1
s6 s3
s7 s22
s2 s21
s0 sg s20
s9 s15
s3 s16
s10 s12
s11 s13
Initial Simplifying Assumptions
• Environment is static
– no changes in environment while problem is being solved
• Environment is observable
• Environment is deterministic
Example: Traveling in Romania
• Formulate goal:
– be in Bucharest
• Formulate problem:
– states: various cities, a single state: to be in a city X
– actions/operators: drive between cities, e.g. drive from X to Y, one
action for each directed arc on the map
• Find solution
– By searching through states to find a goal
– sequence of drive action between cities, e.g., Arad, Sibiu, Fagaras,
Bucharest
• Set of States
– individual cities
– e.g., Irvine, SF, Las Vegas, Reno, Boise, Phoenix, Denver
• Operators
– freeway routes from one city to another
– e.g., Irvine to SF via 5, SF to Seattle, etc
• Start State
– current city where we are, Irvine
• Goal States
– set of cities we would like to be in
– e.g., cities which are closer than Irvine
• Solution
– a specific goal city, e.g., Boise
– a sequence of operators which get us there,
• e.g., Irvine to SF via 5, SF to Reno via 80, etc
Abstraction
• Definition of Abstraction:
Process of removing irrelevant detail to create an abstract
representation: ``high-level”, ignores irrelevant details
• Graphs:
– nodes, arcs, directed arcs, paths
• Search graphs:
– States are nodes
– operators are directed arcs
– solution is a path from start S to goal G
• Problem formulation:
– Give an abstract description of states, operators, initial state
and goal state.
• Problem solving:
– Generate a part of the search space that contains a solution
The Traveling Salesperson Problem
• Find the shortest tour that visits all cities without visiting any city
twice and return to starting point.
• State: sequence of cities visited
• S0 = A
C
B
A D
F
• G = a complete tour E
Example: 8-queens problem
State-Space problem formulation
• States
• Initial state
• Actions
• Goal test
• Path Cost
Example: Robot Assembly
• States
• Initial state
• Actions
• Goal test
• Path Cost
Learning a spam email classifier
• states?
• initial state?
• actions?
• goal test?
• path cost?
Example: 8-puzzle
• Operators
– Fill 3-gallon from faucet, fill 4-gallon from faucet
– Fill 3-gallon from 4-gallon , fill 4-gallon from 3-gallon
– Empty 3-gallon into 4-gallon, empty 4-gallon into 3-gallon
– Dump 3-gallon down drain, dump 4-gallon down drain
Production Rules for the Water Jug Problem
7 (x,y) (4,y – (4 –x)) Pour water from the 3-gallon jug into the 4-
if x + y ≥ 4 and y > 0 gallon jug until the 4-gallon jug is full
The Water Jug Problem (cont’d)
8 (x,y) (x – (3 – y),3) Pour water from the 4-gallon jug into the 3-
if x + y ≥ 3 and x > 0 gallon jug until the 3-gallon jug is full
9 (x,y) (x + y, 0) Pour all the water from the 3-gallon jug into
if x + y ≤ 4 and y > 0 the 4-gallon jug
10 (x,y) (0, x + y) Pour all the water from the 4-gallon jug into
if x + y ≤ 3 and x > 0 the 3-gallon jug
One Solution to the Water Jug Problem
0 0 2
0 3 9
3 0 2
3 3 7
4 2 5
0 2 9
2 0
Generalizing the Water Jug Problem
• Basic idea:
– Exploration of state space by generating successors of already-
explored states (a.k.a. expanding states).
This “strategy” is
what differentiates
different search
algorithms
States versus Nodes
• The Expand function creates new nodes, filling in the various fields and
using the SuccessorFn of the problem to create the corresponding states.
State Spaces versus Search Trees
• State Space
– Set of valid states for a problem
– Linked by operators
– e.g., 20 valid states (cities) in the Romanian travel problem
• Search Tree
– Root node = initial state
– Child nodes = states that can be visited from parent
– Note that the depth of the tree can be infinite
• E.g., via repeated states
– Partial search tree
• Portion of tree that has been expanded so far
– Fringe
• Leaves of partial search tree, candidates for expansion
Depth of Nodes to
Solution Expand Time Memory
• Uninformed search
– Breadth-first, depth-first
– Uniform cost
– Iterative deepening