Chapter 2 AI

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

4/1/2023

Topics to be covered
• Agents and environments
Chapter-2 • Rationality & Omniscience

Intelligent Agents • PAGE & PEAS

• Environment types

• Agent types

• Learning agents
4/1/2023 1 4/1/2023 2

Agents
Agents and environments
 How do you design an intelligent agent?
• An agent is anything that can be viewed as perceiving its
environment through sensors and acting upon that
environment through actuators/ effectors
• A discrete agent receives percepts one at a time,
and maps this percept sequence to a sequence of • The agent function maps from percept histories
discrete actions. to actions:
• Properties [f: P*  A]
–Autonomous
–Reactive to the environment • The agent program runs on the physical
–Pro-active (goal-directed) architecture to produce f
–Interacts with other agents • agent = architecture + program
via the environment
4/1/2023 3 4/1/2023 4
4/1/2023

Sensors/percepts and effectors/actions A more specific example 1:


• Humans Automated taxi driving system
– Sensors: Eyes (vision), ears (hearing), skin (touch), • Percepts: Video, sonar, speedometer, odometer, engine sensors,
tongue (gestation), nose (olfaction), neuromuscular keyboard input, microphone, GPS, …
system (proprioception) • Actions: Steer(navigate), accelerate, brake, horn, speak/display,
– Percepts: …
• At the lowest level – electrical signals from these sensors • Goals: Maintain safety, reach destination, maximize profits (fuel,
• After preprocessing – objects in the visual field (location, textures, colors, …), tire wear), obey laws, provide passenger comfort, …
auditory streams (pitch, loudness, direction), …
– Effectors: limbs, digits, eyes, tongue, … • Environment: urban streets, freeways, traffic, pedestrians,
weather, customers, …
– Actions: lift a finger, turn left, walk, run, carry an
object, …
• The Point: percepts and actions need to be carefully defined, • Don’t forget that different aspects of driving
possibly at different levels of abstraction may require different types of agent programs!
4/1/2023 5 4/1/2023 6

A more specific example 2: Vacuum cleaner world Rational agents


• Agent: robot vacuum cleaner • An agent should strive to "do the right thing", based on what it
• Environment: floors of your apartment can perceive and the actions it can perform. The right action is
• Sensors: the one that will cause the agent to be most successful.
– dirt sensor: detects when floor in front of robot is dirty • An ideal rational agent should, for each possible percept
– bump sensor: detects when it has bumped into something sequence, do whatever actions will maximize its expected
– power sensor: measures amount of power in battery performance measure based on
– bag sensor: amount of space remaining in dirt bag 1. The percept sequence, and
• Actuators/Effectors: 2. its built-in and acquired knowledge.
– motorized wheels
– Suction[pulls] motor • In summary what is Rational at any given point depends on
– plug into wall? empty dirt bag? four things:[parameters on which rational agent are depend on]
• Percepts: location and contents, e.g., [A,Dirty] or [“Floor A is a) Performance Measure
dirty”] b) Percept Sequence
– Actions: Left, Right, Suck, NoOp e.g. “Forward, 0.5 ft/sec” c) Knowledge from Environment
4/1/2023 7 4/1/2023
d) Possible Actions 8
4/1/2023

Rational Agents… Rationality vs. Omniscience


a) Performance measure: An objective criterion for •Rational agent acts so as to achieve one's goals, given one's beliefs
success of an agent's behavior. (one that does the right thing).
– In other words, criteria for determining the quality of an –What does right thing mean? one that will cause the agent to be most successful
and is expected to maximize goal achievement, given the available information
agent’s behavior.
•An Omniscient agent knows the actual outcome of its actions, and
• E.g., performance measure of a vacuum-cleaner agent
can act accordingly.
could be amount of dirt cleaned up, amount of time – in reality omniscience is impossible.
– An omniscient agent is one that can predict the future
taken, amount of electricity consumed, amount of noise perfectly.
– Omniscience =all-knowing with infinite knowledge
generated, etc.
• Rational Agent ≠ Omniscient[all-knowing/all-seeing] Agent
– Dirt collected in 8 hour shift/ጽዳት የምካሄደዉ ብ 8 ሰዓት ልዩነት ነዉ፡/
4/1/2023 9 4/1/2023 10

Example Rationality
– You are walking along the road to Adama; You see
an old friend across the street. There is no traffic. • This points out that rationality is concerned with

– So, being rational, you start to cross the street. expected success, given what has been perceived.

– Meanwhile a big banner falls off from above and • Crossing the street was rational, because most of the

before you finish crossing the road, you are flattened. time, the crossing would be successful, and there was
no way you could have foreseen the falling banner.
Were you irrational to cross the street?

4/1/2023 11 4/1/2023 12
4/1/2023

Rational agent Autonomy


•The EXAMPLE shows that we can not blame an agent for failing to • A system is autonomous to the extent that its own
take into account something it could not perceive.
behavior is determined by its own experience (with ability
OR
for failing to take an action that it is incapable of taking. to learn and adapt).

•In summary what is rational at any given point depends on • Therefore, a system is not autonomous if it is guided by
four things. its designer according to a prior decisions.
a) Everything that the agent has perceived so far
b) What an agent knows about the environment • To survive, agents must have:
c) The actions that the agent can perform Enough built-in knowledge to survive.
d) The performance measure that defines degrees of success;
The ability to learn.
4/1/2023 13 4/1/2023 14

PEAS PEAS…
• PEAS: Stands for: Performance measure, Environment, • Must first specify the setting for intelligent agent design
Actuators, Sensors • Consider, e.g., the task of designing an automated taxi
• Must first specify the setting for intelligent agent design driver:
• Consider, e.g., the task of designing an automated taxi – Performance measure:
driver: • Safe, fast, legal, comfortable trip, maximize profits
– Environment:
– Performance measure • Roads, other traffic, pedestrians, customers

– Environment – Actuators:
• Steering wheel, accelerator, brake, signal, horn
– Actuators – Sensors:
• Cameras, sonar, speedometer, GPS, odometer, engine sensors, keyboard
– Sensors
4/1/2023 15 4/1/2023 16
4/1/2023

PEAS… PEAS…
• Agent:
• Agent:
– Medical diagnosis system
– Interactive English tutor
• Performance measure: • Performance measure:
– Healthy patient, minimize costs, lawsuits – Maximize student's score on test
• Environment: • Environment:
– Set of students
– Patient, hospital, staff
• Actuators:
• Actuators:
– Screen display (exercises, suggestions, corrections)
– Screen display (questions, tests, diagnoses, treatments, referrals)
• Sensors: Keyboard
• Sensors:
4/1/2023
– Keyboard (entry of symptoms, findings, patient's answers)17 4/1/2023 18

Classes of Environments Fully observable vs. partially observable


•Actions are done/taken by the agent on the • Does the agent’s sensory see the complete state
environment. Environments provide percepts to an
agent. of the environment?
•Agent perceives and acts in an environment. – If an agent has access to the complete state of the
•Properties of Environments: environment, then the environment is accessible or fully
–Fully observable vs. partially observable observable.
–Deterministic vs. stochastic
• An environment is effectively accessible if the
–Episodic vs. non-episodic
sensors detect all aspects that are relevant to the
–Static vs. Dynamic
choice of action.
–Discrete vs. continuous
4/1/2023 19 – Taxi driving is partially observable
4/1/2023 20
4/1/2023

Deterministic vs. stochastic Episodic vs. Sequential


• Does the next “episode” depend on the actions taken in
• Is there a unique mapping from one state to previous episodes?
another state for a given action? • In an episodic environment, the agent's experience
is divided into "episodes".
• The environment is deterministic if the next state – Each episode consists of the agent perceiving and then
acting.
is completely determined by
– The quality of its action depends just on the episode
1. Current state of the environment and itself.

2. Actions selected by the agents. • In sequential environment the current decision


could affect all future decisions
• Taxi driving is non-deterministic (i.e. stochastic) • Taxi driving is sequential, while assembly line
defective detecting is episodic
4/1/2023 21 4/1/2023 22

Static vs. Dynamic Discrete vs. Continuous


• Can the world change while the agent is thinking? • Are the distinct percepts & actions limited or
unlimited?
– If the environment can change while the agent is – If there are a limited number of distinct,
on purpose, then we say the environment is clearly defined percepts and actions, we say
the environment is discrete[countable].
dynamic/changing for that agent

– otherwise it is static. • Taxi driving is continuous - speed location are


in a range of continuous values.
• Taxi driving is dynamic • Chess is discrete - there are a fixed number of
possible moves on each item

4/1/2023 23 4/1/2023 24
4/1/2023

Single agent Vs. Multi-agent Agent functions and programs


• Single agent vs. Multi-agent • An agent is completely specified by the agent
function mapping percept sequences to
– If the environment contains other intelligent agents, the agent
actions
needs to be concerned about strategic, game-theoretic aspects of
[f: P*  A]
the environment (for either cooperative or competitive agents)
• One agent function (or a small equivalence
• An agent operating by itself in an environment.
class) is rational
– Most engineering environments don’t have multi-agent
properties, whereas most social and economic systems get their
• Aim: find a way to implement the rational agent
complexity from the interactions of (more or less) rational agents. function concisely
4/1/2023 25 4/1/2023 26

Some agent types


• (0) Table-driven agents • Algorithm for Table-driven agent

– use a percept sequence/action table in memory to find


the next action. They are implemented by a (large)
lookup table.

– Table lookup of percept-action pairs mapping from


every possible perceived state to the optimal action for
that state An agent based on a pre-specified lookup table. It

– E.g. for a Percept (“ red light in a traffic system”)the keeps track of the percept sequence and just looks

Action (“Stop”) is executed/initiated. up the best action.


4/1/2023 27 4/1/2023 28
4/1/2023

Table-driven agents (1) Simple reflex agents


• Drawbacks: •Works by finding a rule whose condition matches the
– Huge table current situation (as defined by the percept) and then doing
• Too big to generate and to store (Chess has about 10120 states, for the action associated with that rule.
example)
• difficult to write codes for a large number of table entries E.g. If the car in front brakes, and its brake lights come on,
– Take a long time to build the table then the driver should notice this and initiate braking,
– No autonomy –Some processing is done on the visual input to establish the
– Even with learning, need a long time to learn the table condition. If "The car in front is braking"; then this triggers some
entries established connection in the agent program to the action "initiate
braking". We call such a connection a condition-action rule written
– No knowledge of non-perceptual parts of the current state
as:
– Not adaptive to changes in the environment; requires If car-in-front-is breaking then initiate-braking.
entire table to be updated if changes occur
– Looping: Can’t make actions conditional on previous •Humans also have many such conditions. Some of which are learned
actions/states responses. Some of which are innate (inborn) responses
4/1/2023 29 4/1/2023 30
–Blinking when something approaches the eye.

Cont’d…. Simple reflex agents


Simple Reflex Agent
sensors
Characteristics
• Has rule-based (some rule) in form of “condition-action”

Environment
What the world
• Has a component to extract feature is like now
• There is no access to complete state of the world
• Works only if correct decision can be made on basis of current What action I
Condition - action rules
percept. should do now
• Problems
effectors
– Still usually too big to generate and to store
– Still no knowledge of non-perceptual parts of state function SIMPLE-REFLEX-AGENT(percept) returns action
– Still not adaptive to changes in the environment; requires static: rules, a set of condition-action rules
collection of rules to be updated if changes occur state  INTERPRET-INPUT (percept)
– Still can’t make actions conditional on previous state rule  RULE-MATCH (state,rules)
action  RULE-ACTION [rule]
return action
4/1/2023 31 4/1/2023 32
4/1/2023

(2) Agents with memory(Model-Based reflex) Structure of a Model-Based reflex agent


•This is a reflex agent with internal state. State sensors
–It keeps track of the world that it can’t see now.
How the world evolves What the world
•It works by finding a rule whose condition matches the current is like now

Environment
situation (as defined by the percept and the stored internal state) What my actions do

–If the car is a recent model -- there is a centrally mounted brake light. With older
models, there is no centrally mounted, so what if the agent gets confused?
Is it a parking light? Is it a brake light? Is it a turn signal light? Condition - action rules
What action I
should do now
–Some sort of internal state should be in order to choose an action.
effectors
–The camera should detect two red lights at the edge of the vehicle go ON or OFF
simultaneously. function REFLEX-AGENT-WITH-STATE (percept) returns action
static: state, a description of the current world state
•The driver should look in the rear-view mirror to check on the rules, a set of condition-action rules
location of near by vehicles. In order to decide on lane-change the state  UPDATE-STATE (state, percept)
driver needs to know whether or not they are there. The driver sees, rule  RULE-MATCH (state, rules)
and there is already stored information, and then does the action action  RULE-ACTION [rule]
state  UPDATE-STATE (state, action)
associated with that rule. return action
4/1/2023 33 34
4/1/2023

(3) Goal-based agents Structure of a goal-based agent


•Keeping track of the current state is often not enough  need to add State sensors
goals to decide which situations are good
How the world evolves What the world
•Choose actions that achieve the goal (an agent with explicit goals) is like now

Environment
What my actions do
•Involves consideration of the future:
What it will be like
–Knowing about the current state of the environment is not always enough to if I do action A
decide what to do.
For example, at a road junction, the taxi can turn left, right or go straight. Goals
What action I
should do now
–The right decision depends on where the taxi is trying to get to. As well as a
current state description, the agent needs some sort of goal information, which effectors
describes situations that are desirable. E.g. being at the passenger's destination.
•The agent may need to consider long sequences, twists and turns to Decision making of this kind is fundamentally different from the condition-
find a way to achieve a goal. action rules described earlier. It involves
1. What will happen if I take such and such action?
2. Will that enable me reach goal?
4/1/2023 35 36
4/1/2023
4/1/2023

(4) Utility-based agents Structure of a utility-based agent


• Goals are not really enough to generate high quality
behavior. State sensors

For e.g., there are many action sequences that will get the taxi to its How the world evolves What the world
destination, thereby achieving the goal. Some are quicker, safer, is like now
What my actions do
more reliable, or cheaper than others. We need to consider Speed
What it will be like

Environment
and safety if I do action A

• When there are several goals that the agent can aim for,
non of which can be achieved with certainty. Utility Utility
How happy I will
be in such as a state
provides a way in which the likelihood of success can be
weighed up against the importance of the goals. What action I
should do now
• An agent that possesses an explicit utility function can effectors
make rational decisions.
4/1/2023 37 4/1/2023 38

(5)Learning agents Learning agents

• Learning has an advantage that it allows the agents to


initially operate in unknown environments and to
become more competent than its initial knowledge
alone might allow.

• Implements learning methods for extending and


refining the knowledge base to improve agent’s
competence and/or efficiency in problem solving.
4/1/2023 39 40
4/1/2023
4/1/2023

Thank You!
?
4/1/2023 41

You might also like