Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its...

50
Chapter 2 Intelligent Agent

Transcript of Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its...

Page 1: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Chapter 2

Intelligent Agent

Page 2: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Agents

• An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment through actuators– 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

• any given instant can depend on the entire percept sequence observed to date, but not on anything it hasn't perceived.

Page 3: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Agents and environments

• The agent function maps from percept histories to actions:[f: P* A]

• The agent program runs on the physical architecture to produce f

• agent = architecture + program• The agent function is an abstract mathematical description;

the agent program is a specify implementation, running within some physical system.

Page 4: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Vacuum-cleaner world

• Percepts: location and state of the environment, e.g., [A,Dirty], [A,Clean], [B,Dirty]

• Actions: Left, Right, Suck, NoOp• Simple agent function:

– if the current square is dirty, then suck; otherwise, move to the other square.

Page 5: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

what makes an agent good or bad, intelligent or stupid?

Page 6: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Rational agents

• Rational agent: is one that does the right thing• Performance measure:

– that evaluates any given sequence of environment states. – An objective criterion for success of an agent's behavior, e.g.,

• Robot driver?• Chess-playing program?• Spam email classifier?

• Rational Agent: selects actions that is expected to maximize its performance measure, – given percept sequence – given agent’s built-in knowledge– sidepoint: how to maximize expected future performance,

given only historical data

Page 7: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Rationality

•What is rational at any given time depends on four things: – The performance measure that defines the criterion of success.– The agent's prior knowledge of the environment. – The actions that the agent can perform.– The agent's percept sequence to date.

•For each possible percept sequence, a rational agent should select an action that is expected to maximize its performance measure, given the evidence provided by the percept sequence and whatever built-in knowledge the agent has.

Page 8: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Rational agents

• Performance measure: An objective criterion for success of an agent's behavior, e.g.,– Robot driver?– Chess-playing program?– Spam email classifier?

• Rational Agent: selects actions that is expected to maximize its performance measure, – given percept sequence – given agent’s built-in knowledge

– sidepoint: how to maximize expected future performance, given only historical data

Page 9: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Rational agents

• Rationality is distinct from omniscience (all-knowing with infinite knowledge)

• Agents can perform actions in order to modify future percepts so as to obtain useful information (information gathering, exploration)

• An agent is autonomous if its behavior is determined by its own percepts & experience (with ability to learn and adapt) without depending solely on built-in knowledge99

Page 10: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Task Environment

• Before we design an intelligent agent, we must specify its “task environment”:

PEAS:1. Performance measure2. Environment3. Actuators4. Sensors

Page 11: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

PEAS

• Example: Agent = robot driver in DARPA Challenge

– 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,

Page 12: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

PEAS

• Example: Agent = Medical diagnosis system

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)

Page 13: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

PEAS

Agent type Percepts Actions Goals Environment

Medical diagnosis system

Symptoms, findings, patient's answers

Questions, tests, treatments

Healthy patients, minimize costs Patient, hospital

Satellite image analysis system

Pixels of varying intensity, color

Print a categorization of scene

Correct categorization

Images from orbiting satellite

Part-picking robot 

Pixels of varying intensity

Pick up parts and sort into bins

Place parts in correct bins

Conveyor belts with parts

Refinery controller 

 

Temperature, pressure readings

Open, close valves; adjust temperature 

Maximize purity, yield, safety 

Refinery 

 

Interactive English tutor 

Typed words 

 

Print exercises, suggestions, corrections

Maximize student's score on test

Set of students 

 

Page 14: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Environment types

• Fully observable (vs. partially observable): – An agent's sensors give it access to the complete state of

the environment at each point in time.– Fully observable environments are convenient because the

agent need not maintain any internal state to keep track of the world.

– E.g.: Playing soccer : Partial observable, Perform high jump : Full observable.

• Single agent (vs. multi-agent): – An agent operating by itself in an environment. Does the

other agent interfere with my performance measure?• e,.g: crossword puzzle : Single agent

Playing chess : mult-iagent (agent may be competitive or cooperation)

Page 15: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Environment types

• Deterministic (vs. stochastic): – The next state of the environment is completely determined

by the current state and the action executed by the agent. – If the environment is deterministic except for the actions of

other agents, then the environment is strategic– Deterministic environments can appear stochastic to an

agent (e.g., when only partially observable)– E.g: shopping for IT book online: deterministic,– Stochastic: generally implies that uncertainty about outcomes is

quantified in terms of probabilities

E.g: performing a high Jump :Stochastic

Page 16: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

• Episodic (vs. sequential): – An agent’s action is divided into atomic episodes. Decisions

do not depend on previous decisions/actions.– Episodic : the next episode does not depend on the actions

taken in previous episodes.– E.g.: an agent that has to spot defective parts on an

assembly line bases each decision on the current part, regardless of previous decisions;

– sequential the current decision could affect all future decisions e.g.: Chess and taxi driving are sequential

Page 17: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Environment types• Static (vs. dynamic):

– Static : The environment is unchanged while an agent is deliberating.

• E.g.: crossword puzzle :static – Dynamic: agent need to keep looking at the world while it is deciding on an

action and The environment is changed while an agent is deliberating. Dynamic environment continuously asking agent what want to do.

• E.g.: Taxi driving : Dynamic

– The environment is semidynamic if the environment itself does not change with the passage of time but the agent's performance score does.

• Discrete (vs. continuous): – A discrete set of distinct, clearly defined percepts and actions.– How we represent or abstract or model the world

Dynamic

Need to worry about time

Need to observe while deliberating

Page 18: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

task environm.

observable

deterministic/stochastic

episodic/sequential

static/dynamic

discrete/continuous

agents

crosswordpuzzle

fully determ. sequential static discrete single

chess withclock

fully strategic sequential semi discrete multi

poker

taxidriving

partial stochastic sequential dynamic continuous multi

medicaldiagnosis

image analysis

fully determ. episodic semi continuous single

partpickingrobot

partial stochastic episodic dynamic continuous single

refinery controller

partial stochastic sequential dynamic continuous single

interact.tutor

partial stochastic sequential dynamic discrete multi

Page 19: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

What is the environment for the DARPA Challenge?

• Agent = robotic vehicle

• Environment = 130-mile route through desert– Observable?– Deterministic?– Episodic?– Static?– Discrete?– Agents?

Page 20: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Agent functions and programs

• An agent is completely specified by the agent function mapping percept sequences to actions

• One agent function (or a small equivalence class) is rational• Difference between agent program and agent function:

– Agent program: takes the current percept as input because nothing more is available from the environment;

– Agent function, which takes the entire percept history.

• Aim: find a way to implement the rational agent function concisely

Page 21: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Examples of how the agent function can be implemented

1. Table-driven agent2. Simple reflex agent3. Reflex agent with internal

state4. Agent with explicit goals5. Utility-based agent

More sophisticated

Page 22: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Table-lookup agent

• Drawbacks:– Huge table– Take a long time to build the table– No autonomy– Even with learning, need a long time to learn the table entries

• Agent programs type:– Simple reflex agents– Model-based reflex agents– Goal-based agents– Utility-based agents

Page 23: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Table-driven agent

Page 24: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Simple reflex agents

Page 25: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Simple reflex agent…

Table lookup of condition-action pairs defining all possible condition-action rules necessary to interact in an environment

e.g. if car-in-front-is-breaking then initiate breaking•select precepts based on the current percept•ignoring the rest of the precept history•The rules are like the form “if … then …” •efficient but have narrow range of applicability Because knowledge sometimes cannot be stated explicitly •Work only

if the environment is fully observable•Problems

–Table is still too big to generate and to store (e.g. taxi)–Takes long time to build the table–No knowledge of non-perceptual parts of the current state–Not adaptive to changes in the environment; requires entire table to be updated if changes occur–Looping: Can’t make actions conditional

Page 26: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

A Simple Reflex Agent in Naturepercepts(size, motion)

RULES:(1) If small moving object, then activate SNAP(2) If large moving object, then activate AVOID and inhibit SNAPELSE (not moving) then NOOP

Action: SNAP or AVOID or NOOPneeded forcompleteness

Page 27: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Model-based reflex agents

Page 28: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Model-Based Reflex Agents– Most effective way to keep track of the part of the world it can’t see now. –Maintain some internal state that depends on percept history and thereby reflects at least some of the unobserved aspects of the current state (e.g. using some type of variable).

• For the world that is partially observable–the agent has to keep track of an internal state

• That depends on the percept history• Reflecting some of the unobserved aspects• E.g., driving a car and changing lane

• Requiring two types of knowledge–How the world evolves independently of the agent–How the agent’s actions affect the world

Page 29: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Goal-based agents

Page 30: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

• Current state of the environment is always not enough • The goal is another issue to achieve

– Judgment of rationality / correctness

• Actions chosen goals, based on– the current state – the current percept

• Conclusion– Goal-based agents are less efficient– but more flexible

• Agent Different goals different tasks– Search and planning

• two other sub-fields in AI • to find out the action sequences to achieve its goal

Page 31: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Utility-based agents

Page 32: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

• Goals alone are not enough – to generate high-qualityhigh-quality behavior – E.g. meals in Canteen, good or not ?

• Many action sequences the goals – some are better and some worse – If goal means success,– then utility means the degree of success (how successful it is)

• State A has higher utility– If state A is more preferred than others

• Utility is therefore a function – that maps a state onto a real number– the degree of success

• Utility has several advantages: – When there are conflicting goals,

• Only some of the goals but not all can be achieved• utility describes the appropriate trade-off

– When there are several goals • None of them are achieved certainly• utility provides a way for the decision-making

Page 33: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Learning Agents

• After an agent is programmed, can it work immediately?– No, it still need teaching

• In AI,– Once an agent is done– We teach it by giving it a set of examples– Test it by using another set of examples

• We then say the agent learns– A learning agent

• Four conceptual components– Learning element

• Making improvement

– Performance element• Selecting external actions

– Critic• Tells the Learning element how well the agent is doing with

respect to fixed performance standard.(Feedback from user or examples, good or not?)

– Problem generator• Suggest actions that will lead to new and informative experiences.

Page 34: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Learning agents

Page 35: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Agent types

• Five basic types in order of increasing generality:

– Table Driven agent

– Simple reflex agents

– Model-based reflex agents

– Goal-based agents• Problem-solving agents

– Utility-based agents• Can distinguish between different goals

– Learning agents

Page 36: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Problem-Solving Agents

• Intelligent agents can solve problems by searching a state-space

• 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

• Operators (actions, successor function)– operators are legal actions which the agent can take to move from

one state to another

Page 37: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Initial Simplifying Assumptions

• Environment is static– no changes in environment while problem is being solved

• Environment is observable

• Environment and actions are discrete– (typically assumed, but we will see some exceptions)

• Environment is deterministic

Page 38: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Example: Traveling in Romania

• On holiday in Romania; currently in Arad• Flight leaves tomorrow from Bucharest

• Formulate goal:– be in Bucharest

• Formulate problem:– states: various cities– actions/operators: drive between cities

• Find solution– By searching through states to find a goal– sequence of cities, e.g., Arad, Sibiu, Fagaras, Bucharest

• Execute states that lead to a solution

Page 39: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Example: Traveling in Romania

Page 40: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

State-Space Problem Formulation

A problem is defined by four items:

1. initial state e.g., "at Arad“

2. actions or successor function S(x) = set of action–state pairs

e.g., S(Arad) = {<Arad Zerind, Zerind>, … }

3. goal test (or set of goal states) e.g., x = "at Bucharest”, Checkmate(x)

4. path cost (additive)e.g., sum of distances, number of actions executed, etc.c(x,a,y) is the step cost, assumed to be ≥ 0

A solution is a sequence of actions leading from the initial state to a goal state

Page 41: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Example: Formulating the Navigation Problem

• 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

Page 42: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Abstraction

• Definition of Abstraction:Process of removing irrelevant detail to create an abstract representation: ``high-level”, ignores irrelevant details

• Navigation Example: how do we define states and operators?– First step is to abstract “the big picture”

• i.e., solve a map problem• nodes = cities, links = freeways/roads (a high-level description)• this description is an abstraction of the real problem

– Can later worry about details like freeway onramps, refueling, etc

• Abstraction is critical for automated problem solving– must create an approximate, simplified, model of the world for the

computer to deal with: real-world is too detailed to model exactly– good abstractions retain all important details

Page 43: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

The State-Space Graph

• 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

Page 44: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

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

• G = a complete tour

C

DA

E

F

B

Page 45: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Example: 8-queens problem

Page 46: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

State-Space problem formulation

• states? -any arrangement of n<=8 queens

-or arrangements of n<=8 queens in leftmost n columns, 1 per column, such that no queen attacks any other.

• initial state? no queens on the board

• actions? -add queen to any empty square

-or add queen to leftmost empty square such that it is not attacked by other queens.

• goal test? 8 queens on the board, none attacked.

• path cost? 1 per move

Page 47: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Example: Robot Assembly

• States

• Initial state

• Actions

• Goal test

• Path Cost

Page 48: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Example: Robot Assembly

• States: configuration of robot (angles, positions) and object parts

• Initial state: any configuration of robot and object parts

• Actions: continuous motion of robot joints

• Goal test: object assembled?

• Path Cost: time-taken or number of actions

Page 49: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Learning a spam email classifier

• States

• Initial state

• Actions

• Goal test

• Path Cost

Page 50: Chapter 2 Intelligent Agent. Agents An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment.

Learning a spam email classifier

• States: settings of the parameters in our model

• Initial state: random parameter settings

• Actions: moving in parameter space

• Goal test: optimal accuracy on the training data

• Path Cost: time taken to find optimal parameters

(Note: this is an optimization problem – many machine learning problems can be cast as optimization)