Slides Module2 1
Slides Module2 1
DA109: AI Basics
Module 2
2
Parts
➢ Agents and Environments
❑ Brief overview of agents and environment
➢ Knowledge-Based Agents
❑ Detailed discussion on knowledge-based agents with practical examples
3
Part - I
Agents and Environments
4
Agents and Environments
➢ An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that
environment through actuators.
➢ We use the term percept to refer to the agent’s perceptual inputs at any given instant.
➢ An agent’s percept sequence is the complete history of everything the agent has ever perceived.
➢ In general, an agent’s choice of action at any given instant can depend on the entire percept sequence
observed to date, but not on anything it hasn’t perceived.
➢ By specifying the agent’s choice of action for every possible percept sequence, we have said more or less
everything there is to say about the agent.
➢ Mathematically speaking, we say that an agent’s behavior is described by the agent function that maps any
given percept sequence to an action.
5
Agents and Environments
➢ An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that
environment through actuators
ASIC FPGA
sensors actuators
7
Agents and Environments
Types of Agents
8
Rationality
❑ This particular world has just two locations: squares A and B. The vacuum agent perceives which
square it is in and whether there is dirt in the square.
❑ It can choose to move left, move right, suck up the dirt, or do nothing.
❑ One very simple agent function is the following: if the current square is dirty, then suck; otherwise,
move to the other square.
9
Rationality
10
Part - II
Good Behavior: The Concept of Rationality
11
Good Behavior: The Concept of Rationality
➢ A rational agent is one that does the right thing—conceptually speaking, every entry in the table for the agent
function is filled out correctly.
➢ Obviously, doing the right thing is better than doing the wrong thing, but what does it mean to do the right
thing?
12
Good Behavior: The Concept of Rationality
➢ When an agent is plunked down in an environment, it generates a sequence of actions according to the
percepts it receives.
➢ This sequence of actions causes the environment to go through a sequence of states. If the sequence is
desirable, then the agent has performed well.
➢ This notion of desirability is captured by a performance measure that evaluates any given sequence of
environment states.
➢ Notice that we said environment states, not agent states. If we define success in terms of agent’s opinion of
its own performance, an agent could achieve perfect rationality simply by deluding itself that its performance
was perfect.
13
Good Behavior: The Concept of Rationality
➢ Obviously, there is not one fixed performance measure for all tasks and agents; typically, a designer will
devise one appropriate to the circumstances.
➢ Consider, for example, the vacuum-cleaner agent from the preceding section. We might propose to measure
performance by the amount of dirt cleaned up in a single eight-hour shift.
➢ With a rational agent, of course, what you ask for is what you get. A rational agent can maximize this
performance measure by cleaning up the dirt, then dumping it all on the floor, then cleaning it up again, and
so on. A more suitable performance measure would reward the agent for having a clean floor.
➢ For example, one point could be awarded for each clean square at each time step (perhaps with a penalty for
electricity consumed and noise generated). As a general rule, it is better to design performance measures
according to what one actually wants in the environment, rather than according to how one thinks the agent
should behave.
14
Rationality
➢ Rational Agent: 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.
15
Rationality
➢ That depends! First, we need to say what the performance measure is, what is known about the environment,
and what sensors and actuators the agent has.
❑ The “geography” of the environment is known a priori but the dirt distribution and the initial location of
the agent are not. Clean squares stay clean and sucking cleans the current square. The Left and
Right actions move the agent left and right except when this would take the agent outside the
environment, in which case the agent remains where it is.
❑ The agent correctly perceives its location and whether that location contains dirt.
16
Part - III
The Nature of Environments
17
The Nature of Environments
➢ Now that we have a definition of rationality, we are almost ready to think about building rational agents.
➢ First, however, we must think about task environments, which are essentially the “problems” to which rational
agents are the “solutions.”
➢ We begin by showing how to specify a task environment, illustrating the process with a number of examples.
➢ We then show that task environments come in a variety of flavors. The flavor of the task environment directly
affects the appropriate design for the agent program.
18
Specifying the task Environment
➢ In our discussion of the rationality of the simple vacuum-cleaner agent, we had to specify the performance
measure, the environment, and the agent’s actuators and sensors.
➢ We group all these under the heading of the task environment. For the acronymically minded, we call this the
PEAS (Performance, Environment, Actuators, Sensors) description.
➢ In designing an agent, the first step must always be to specify the task environment as fully as possible.
➢ The vacuum world was a simple example; let us consider a more complex problem: an automated taxi driver.
19
Specifying the task Environment
Agent Type
Taxi Driver Performance,
Environment,
Actuators,
Sensors
20
Specifying the task Environment
21
Specifying the task Environment
22
Specifying the task Environment
23
Specifying the task Environment
24
Specifying the task Environment
➢ An automated taxi driver:
❑ First, what is the performance measure to which we would like our automated driver to aspire?
Desirable qualities include getting to the correct destination; minimizing fuel consumption; minimizing the
trip time or cost; minimizing violations of traffic laws and disturbances to other drivers; maximizing safety
and passenger comfort; maximizing profits.
❑ Next, what is the driving environment that the taxi will face? Any taxi driver must deal with a variety of
roads, ranging from rural lanes and urban alleys to 12-lane freeways. The roads contain other traffic,
pedestrians, stray animals, road works, police cars, puddles, and potholes.
❑ The actuators for an automated taxi include those available to a human driver: control over the engine
through the accelerator and control over steering and braking. In addition, it will need output to a display
screen or voice synthesizer to talk back to the passengers, and perhaps some way to communicate with
other vehicles, politely or otherwise.
❑ The basic sensors for the taxi will include one or more controllable video cameras so that it can see the
road; it might augment these with infrared or sonar sensors to detect distances to other cars and
obstacles. To avoid speeding tickets, the taxi should have a speedometer, and to control the vehicle
properly, especially on curves, it should have an accelerometer 25
Specifying the task Environment
26
Specifying the task Environment
➢ Examples of agent types and their PEAS descriptions
28
Specifying the task Environment
➢ Examples of agent types and their PEAS descriptions
29
Specifying the task Environment
➢ Examples of agent types and their PEAS descriptions
30
Specifying the task Environment
➢ Examples of agent types and their PEAS descriptions
31
Specifying the task Environment
➢ Examples of agent types and their PEAS descriptions
32
Specifying the task Environment
➢ Examples of agent types and their PEAS descriptions
34
Specifying the task Environment
➢ Examples of agent types and their PEAS descriptions
35
Specifying the task Environment
➢ Examples of agent types and their PEAS descriptions
36
Specifying the task Environment
➢ Examples of agent types and their PEAS descriptions
37
Specifying the task Environment
➢ Examples of agent types and their PEAS descriptions
38
Specifying the task Environment
➢ Examples of agent types and their PEAS descriptions
40
Specifying the task Environment
➢ Examples of agent types and their PEAS descriptions
41
Specifying the task Environment
➢ Examples of agent types and their PEAS descriptions
42
Specifying the task Environment
➢ Examples of agent types and their PEAS descriptions
43
Specifying the task Environment
➢ Examples of agent types and their PEAS descriptions
44
Specifying the task Environment
➢ Examples of agent types and their PEAS descriptions
45
Properties of Task Environment
➢ An environment is everything in the world which surrounds the agent, but it is not a part of an agent itself. An
environment can be described as a situation in which an agent is present. The environment is where agent
lives, operate and provide the agent with something to sense and act upon it.
46
Properties of Task Environment
❑ If an agent sensor can sense or access the complete state of an environment at each point of time
then it is a fully observable environment, else it is partially observable.
❑ A fully observable environment is easy as there is no need to maintain the internal state to keep
track history of the world.
47
Properties of Task Environment
➢ Static vs Dynamic
❑ If the environment can change itself while an agent is deliberating then such environment is
called a dynamic environment else it is called a static environment.
❑ Static environments are easy to deal because an agent does not need to continue looking at
the world while deciding for an action.
❑ However for dynamic environment, agents need to keep looking at the world at each action.
❑ Taxi driving is an example of a dynamic environment whereas Crossword puzzles are an example
of a static environment.
48
Properties of Task Environment
➢ Discrete vs Continuous
❑ If in an environment there are a finite number of percepts and actions that can be performed
within it, then such an environment is called a discrete environment else it is called continuous
environment.
❑ A chess game comes under discrete environment as there is a finite number of moves that can be
performed.
49
Properties of Task Environment
➢ Deterministic vs Stochastic
❑ If an agent's current state and selected action can completely determine the next state of the
environment, then such environment is called a deterministic environment.
❑ In a deterministic, fully observable environment, agent does not need to worry about uncertainty.
50
Properties of Task Environment
➢ Single-agent vs Multi-agent
❑ If only one agent is involved in an environment, and operating by itself then such an
environment is called single agent environment.
❑ However, if multiple agents are operating in an environment, then such an environment is called
a multi-agent environment.
❑ The agent design problems in the multi-agent environment are different from single agent
environment.
51
Properties of Task Environment
➢ Episodic vs sequential
❑ In an episodic environment, there is a series of one-shot actions, and only the current percept
is required for the action.
52
Properties of Task Environment
➢ Known vs Unknown
❑ Known and unknown are not actually a feature of an environment, but it is an agent's state of
knowledge to perform an action.
❑ In a known environment, the results for all actions are known to the agent. While in unknown
environment, agent needs to learn how it works in order to perform an action.
53
Properties of Task Environment
➢ Accessible vs Inaccessible
❑ If an agent can obtain complete and accurate information about the state's environment, then
such an environment is called an Accessible environment else it is called inaccessible.
❑ An empty room whose state can be defined by its temperature is an example of an accessible
environment.
54
Properties of Task Environment
55
Properties of Task Environment
56
Properties of Task Environment
57
Properties of Task Environment
58
Properties of Task Environment
59
Properties of Task Environment
60
Properties of Task Environment
61
Properties of Task Environment
62
Properties of Task Environment
63
Properties of Task Environment
64
Properties of Task Environment
66
The Structure of Agents
➢ So far we have talked about agents by describing behavior—the action that is performed after any given
sequence of percepts.
❑ The job of AI is to design an agent program that implements the agent function-the mapping
from percepts to actions.
➢ We assume this program will run on some sort of computing device with physical sensors and actuators—we
call this the architecture:
Agent = Architecture + Program
➢ Obviously, the program we choose has to be one that is appropriate for the architecture.
❑ If the program is going to recommend actions like Walk, the architecture had better have legs.
➢ In general, the architecture makes the percepts from the sensors available to the program, runs the program,
and feeds the program’s action choices to the actuators as they are generated.
67
Agent Programs
➢ Agent programs take the current percept as input from the sensors and return an action to the actuators.
❑ The agent program, which takes the current percept as input, and the agent function, which
takes the entire percept history.
➢ The agent program takes just the current percept as input because nothing more is available from the
environment; if the agent’s actions need to depend on the entire percept sequence, the agent will have to
remember the percepts.
68
Kinds of Agent Programs
➢ The four basic kinds of agent programs that embody the principles underlying almost all intelligent systems.
❑ Goal-based agents
❑ Utility-based agents
➢ Each kind of agent program combines particular components in particular ways to generate actions.
69
Simple reflex agents
➢ The simplest kind of agent is the simple reflex agent. These agents select actions on the basis of the
current percept, ignoring the rest of the percept history.
➢ The most effective way to handle partial observability is for the agent to keep track of the part of the world it
can’t see now.
➢ That is, the agent should maintain some sort of internal state that depends on the percept history and
thereby reflects at least some of the unobserved aspects of the current state.
➢ Updating this internal state information as time goes by requires two kinds of knowledge to be encoded in the
agent program.
❑ First, we need some information about how the world evolves independently of the agent
❑ Second, we need some information about how the agent’s own actions affect the world
➢ This knowledge about “how the world works”—whether implemented in simple Boolean circuits or in
complete scientific theories—is called a model of the world. An agent that uses such a model is called a
model-based agent.
71
Model-based reflex agents
➢ Update-state is responsible for creating the new internal state description. The details of how models and
states are represented vary widely depending on the type of environment and the particular technology used
in the agent design
72
Goal-based agents
➢ Knowing something about the current state of the environment is not always enough to decide what to do.
➢ At a road junction, the taxi can turn left, turn right, or go straight on. The correct decision depends on
where the taxi is trying to get to
➢ In other words, as well as a current state description, the agent needs some sort of goal information that
describes situations that are desirable—for example, being at the passenger’s destination
➢ The agent program can combine this with the to choose actions that achieve the goal.
73
Goal-based agents
A goal-based agent. It keeps track of the world state as well as a set of goals it is trying to achieve, and
chooses an action that will (eventually) lead to the achievement of its goals.
74
Utility-based agents
➢ Goals alone are not enough to generate high-quality behavior in most environments.
➢ For example, many action sequences will get the taxi to its destination (thereby achieving the goal) but some
are quicker, safer, more reliable, or cheaper than others.
➢ Goals just provide a crude binary distinction between “happy” and “unhappy” states.
➢ A more general performance measure should allow a comparison of different world states according to
exactly how happy they would make the agent.
➢ Because “happy” does not sound very scientific, economists and computer scientists use the term utility (the
quality of being useful) instead.
➢ An agent’s utility function is essentially an internalization of the performance measure. If the internal utility
function and the external performance measure are in agreement, then an agent that chooses actions to
maximize its utility will be rational according to the external performance measure.
75
Utility-based agents
A utility-based agent. It uses a model of the world, along with a utility function that measures its preferences
among states of the world. Then it chooses the action that leads to the best expected utility, where expected utility
is computed by averaging over all possible outcome states, weighted by the probability of the outcome.
76
77
Part - V
Knowledge-Based Agents
78
Knowledge-Based Agents
➢ Humans, it seems, know things; and what they know helps them do things.
➢ They make strong claims about how the intelligence of humans is achieved—not by purely reflex mechanisms
but by processes of reasoning that operate on internal representations of knowledge.
➢ The central component of a knowledge-based agent is its knowledge base i.e. a set of sentences
➢ Each sentence is expressed in a language called a knowledge representation language and represents
some assertion about the world.
79
Learning Agents
80
81
Summary
➢ The major points to recall are as follows:
82