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

CS321: Principles of Artificial Intelligence

Principles of Artificial
Intelligence
Course Code CS321
Faculty of Computing and Information Technology
Computer Science Department
Jan, 2022
These slides are based on lecture notes of the book’s author(Artificial
Intelligence: A Modern Approach,)
&
King Saud University course materials
&
Grokking Artificial Intelligence Algorithms

Lecturer:Wedad Al-Sorori
Intelligent Agents 2022 1/46
CS321: Principles of Artificial Intelligence

Intelligent Agents

Intelligent Agents 2022 2/46


CS321: Principles of Artificial Intelligence

Chapter Objectives
• At the end of this chapter, the student should be able to:
• Understand what an agent is and how an agent interacts with the
environment in a rational way.
• Identify the percepts available to the agent and the actions that the agent can
execute in a given problem situation.
• Understand the performance measures used to evaluate an agent
• Analyze a problem situation and identify the characteristics of the
environment.
• Discuss the different agent architectures and recommend the suitable
architecture of the desired agent.

Intelligent Agents 2022 3/48


CS321: Principles of Artificial Intelligence

Introduction

Thinking humanly Thinking rationally

Acting humanly Acting rationally

Intelligent Agents 2022 4/48


CS321: Principles of Artificial Intelligence

Agents and environments

• An agent is an entity that perceives and acts.

• An agent is anything that can be viewed as


• perceiving its environment through sensors and
• acting upon that environment through actuators

 Human agent:
 Sensors: eyes, ears, ...

 Actuators: hands, legs, mouth, …


Robotic agent:
 Sensors: cameras and infrared range finders

 Actuators: various motors


A software agent

receives file contents, network packets, and human input (keyboard/mouse/touchscreen/voice) as sensory inputs

and acts on the environment by writing files, sending network packets, and displaying information or generating sounds.

Intelligent Agents 2022 5/48


CS321: Principles of Artificial Intelligence

Agents and environments



Abstractly, an agent is a function from percept histories to actions: [f : P*  A]
• An agent is specified by an agent function f that maps sequences of percepts Y to actions a from
a set A:
• Y={y0, y1, … , yt}
• A={a0, a1, … , ak}


The agent function is an abstract mathematical description
The agent program is a concrete implementation, running within some physical system( physical
architecture to produce f).

• agent = architecture + program


General assumption: every agent can perceive its own actions, but possibly not its effects

Intelligent Agents 2022 6/48


CS321: Principles of Artificial Intelligence

Agents and environments (4/5)

• Example:
• A vacuum-cleaner agent
• Percepts: location and contents, e.g., [A,Dirty]
• Actions: Left, Right, Suck, NoOp
Intelligent Agents 2022 7/48
CS321: Principles of Artificial Intelligence

Agents and environments


• “Easy” solution: table that maps every possible sequence Y to an action a
• One small problem: exponential in length of Y

Intelligent Agents 2022 8/48


CS321: Principles of Artificial Intelligence

Rationality
• Definition
• The term rational should be used in a very specific technical way:
• Rational: maximally achieving pre-defined goals.
• Rationality only concerns what decisions are made (not the thought process
behind them).
• Goals are expressed in terms of the utility of outcomes.
• Being rational means maximizing your expected utility.

• Rational behavior: doing whatever is expected to


maximize goal achievement, given the available
information.

Intelligent Agents 2022 9/48


CS321: Principles of Artificial Intelligence

Rational Agents
An agent should strive to "do the right thing", based on what it can perceive
and the actions it can perform. The right action is the one that will cause the
agent to be most successful.

Performance measure: An objective criterion for success of an agent's


behavior.
• E.g.:
• performance measure of a vacuum-cleaner agent could be:
• amount of dirt cleaned up,
• amount of time taken,
• amount of electricity consumed,
• amount of noise generated, etc.

Intelligent Agents 2022 10/48


CS321: Principles of Artificial Intelligence

Rational Agent
• PAGE(Percepts, Actions, Goals, Environment)
• Must first specify the settings for intelligent agent design
• Without lose of generality “goals” specified by performance measure defining a
numerical value for any environment history

• 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.

Intelligent Agents 2022 11/48


CS321: Principles of Artificial Intelligence

Rational Agent
• Rationality is distinct from omniscience (all-knowing with infinite
knowledge).
• Rationality is not omniscience
• Rationality is not clairvoyance
• Rationality is not (necessarily) successful!

• Agents can perform actions in order to modify future percepts so as to


obtain useful information.
• Information gathering : exploring an unknown environment
• Learning: finding out which action is likely to produce a desired outcome.

• An agent is autonomous if its behavior is determined by its own experience


(with ability to learn and adapt)
Intelligent Agents 2022 12/48
CS321: Principles of Artificial Intelligence

The Nature of Environments


• The environment could be everything—the entire universe! In practice it is just
that part of the universe whose state we care about when designing this agent—
the part that affects what the agent perceives and that is affected by the agent’s
actions
• For any given class of environments and tasks, we seek the agent (or class of
agents) with the best performance.

• To design a rational agent we need to specify a Task Environment


• a problem specification for which the agent is a solution

• PEAS: to specify a task environment


• Performance measure
• Environment
• Actuators
• Sensors
Intelligent Agents 2022 13/48
CS321: Principles of Artificial Intelligence

The Nature of Environments

• Example Agent: Automated taxi driver.


• Performance measure:
• ?
• Environment:
• ?
• Actuators:
• ?
• Sensors:
• ?

Intelligent Agents 2022 14/48


CS321: Principles of Artificial Intelligence

The Nature of Environments

• Example Agent: Automated taxi driver.


• Performance measure:
• safe, fast, legal, comfortable, maximize profits
• Environment:
• ?
• Actuators:
• ?
• Sensors:
• ?

Intelligent Agents 2022 15/48


CS321: Principles of Artificial Intelligence

The Nature of Environments

• Example Agent: Automated taxi driver.


• Performance measure:
• safe, fast, legal, comfortable, maximize profits
• Environment:
• roads, other traffic, pedestrians, customers
• Actuators:
• ?
• Sensors:
• ?

Intelligent Agents 2022 16/48


CS321: Principles of Artificial Intelligence

The Nature of Environments

• Example Agent: Automated taxi driver.


• Performance measure:
• safe, fast, legal, comfortable, maximize profits
• Environment:
• roads, other traffic, pedestrians, customers
• Actuators:
• steering, accelerator, brake, signal, horn
• Sensors:
• ?

Intelligent Agents 2022 17/48


CS321: Principles of Artificial Intelligence

The Nature of Environments

• Example Agent: Automated taxi driver.


• Performance measure:
• safe, fast, legal, comfortable, maximize profits
• Environment:
• roads, other traffic, pedestrians, customers
• Actuators:
• steering, accelerator, brake, signal, horn
• Sensors:
• cameras, sonar, speedometer, GPS

Intelligent Agents 2022 18/48


CS321: Principles of Artificial Intelligence

The Nature of Environments


• Agent: Medical diagnosis system

• Performance measure:
• Healthy patient, minimize costs, lawsuits
• Environment:
• Patient, hospital, staff
• Actuators:
• Screen display (form including: questions, tests, diagnoses, treatments,
referrals)
• Sensors:
• Keyboard (entry of symptoms, findings, patient's answers)
Intelligent Agents 2022 19/48
CS321: Principles of Artificial Intelligence

The Nature of Environments


• Agent: Part-picking robot
• Performance measure:
• Percentage of parts in correct bins
• Environment:
• Conveyor belt with parts, bins
• Actuators:
• Jointed arm and hand
• Sensors:
• Camera, joint angle sensors

Intelligent Agents 2022 20/48


CS321: Principles of Artificial Intelligence

The Nature of Environments


• Agent: Interactive English tutor

• Performance measure:
• Maximize student's score on test
• Environment:
• Set of students
• Actuators:
• Screen display (exercises, suggestions, corrections)
• Sensors:
• Keyboard

Intelligent Agents 2022 21/48


CS321: Principles of Artificial Intelligence

The Nature of Environments


• Properties of Task Environment:

• Fully observable (vs. partially observable): An agent's sensors give it access to the
complete state of the environment at each point in time.

• 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)

• Episodic (vs. sequential): The agent's experience is divided into atomic "episodes"
during which the agent perceives and then performs a single action, and the choice of
action in each episode depends only on the episode itself.
Intelligent Agents 2022 22/48
CS321: Principles of Artificial Intelligence

The Nature of Environments


• Static (vs. dynamic): The environment is unchanged while an agent is
deliberating.
• 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 limited number of distinct, clearly defined


percepts and actions.

• Single agent (vs. multiagent): An agent operating by itself in an environment.

Intelligent Agents 2022 23/48


CS321: Principles of Artificial Intelligence

The Nature of Environments


 Detailed Examples for specifying the task environment properties:

Solitaire Backgammon Internet shopping Taxi


??Observable

??Deterministic

??Episodic

??Static

??Discrete

??Single-agent

AI 1
Intelligent Agents
24 2022 24/48
CS321: Principles of Artificial Intelligence

The Nature of Environments

Fully vs. partially observable: an environment is full observable when the


sensors can detect all aspects that are relevant to the choice of action.

Solitaire Backgammon Internet shopping Taxi


??Observable

??Deterministic

??Episodic

??Static

??Discrete

??Single-agent

AI 1
Intelligent
10 december 20 Agents
25 2022 25/48
22
CS321: Principles of Artificial Intelligence

The Nature of Environments

Fully vs. partially observable: an environment is full observable when the


sensors can detect all aspects that are relevant to the choice of action.

Solitaire Backgammon Internet shopping Taxi


??Observable FULL FULL PARTIAL PARTIAL

??Deterministic

??Episodic

??Static

??Discrete

??Single-agent

AI 1
Intelligent
10 december 20 Agents
26 2022 26/48
22
CS321: Principles of Artificial Intelligence

The Nature of Environments

Deterministic vs. stochastic: if the next environment state is completely


determined by the current state the executed action then the environment is
deterministic.

Solitaire Backgammon Internet shopping Taxi


??Observable FULL FULL PARTIAL PARTIAL

??Deterministic

??Episodic

??Static

??Discrete

??Single-agent

AI 1
Intelligent
10 december 20 Agents
27 2022 27/48
22
CS321: Principles of Artificial Intelligence

The Nature of Environments

Deterministic vs. stochastic: if the next environment state is completely


determined by the current state the executed action then the environment is
deterministic.

Solitaire Backgammon Internet shopping Taxi


??Observable FULL FULL PARTIAL PARTIAL

??Deterministic YES NO YES NO

??Episodic

??Static

??Discrete

??Single-agent

AI 1
Intelligent
10 december 20 Agents
28 2022 28/48
22
CS321: Principles of Artificial Intelligence

The Nature of Environments

Episodic vs. sequential: In an episodic environment the agent’s experience


can be divided into atomic steps where the agents perceives and then performs
a single action. The choice of action depends only on the episode itself.

Solitaire Backgammom Intenet shopping Taxi


??Observable FULL FULL PARTIAL PARTIAL

??Deterministic YES NO YES NO

??Episodic

??Static

??Discrete

??Single-agent

AI 1
Intelligent
10 december 20 Agents
29 2022 29/48
22
CS321: Principles of Artificial Intelligence

The Nature of Environments

Episodic vs. sequential: In an episodic environment the agent’s experience


can be divided into atomic steps where the agents perceives and then performs
A single action. The choice of action depends only on the episode itself

Solitaire Backgammon Internet shopping Taxi


??Observable FULL FULL PARTIAL PARTIAL

??Deterministic YES NO YES NO

??Episodic NO NO NO NO

??Static

??Discrete

??Single-agent

AI 1
Intelligent
10 december 20 Agents
30 2022 30/48
22
CS321: Principles of Artificial Intelligence

The Nature of Environments

Static vs. dynamic: If the environment can change while the agent is choosing
an action, the environment is dynamic. Semi-dynamic if the agent’s performance
changes even when the environment remains the same.

Solitaire Backgammon Internet shopping Taxi


??Observable FULL FULL PARTIAL PARTIAL

??Deterministic YES NO YES NO

??Episodic NO NO NO NO

??Static

??Discrete

??Single-agent

AI 1
Intelligent
10 december 20 Agents
31 2022 31/48
22
CS321: Principles of Artificial Intelligence

The Nature of Environments

Static vs. dynamic: If the environment can change while the agent is choosing
an action, the environment is dynamic. Semi-dynamic if the agent’s performance
changes even when the environment remains the same.

Solitaire Backgammon Internet shopping Taxi


??Observable FULL FULL PARTIAL PARTIAL

??Deterministic YES NO YES NO

??Episodic NO NO NO NO

??Static YES YES SEMI NO

??Discrete

??Single-agent

AI 1
Intelligent
10 december 20 Agents
32 2022 32/48
22
CS321: Principles of Artificial Intelligence

The Nature of Environments

Discrete vs. continuous: This distinction can be applied to the state of the
environment, the way time is handled and to the percepts/actions of the agent.

Solitaire Backgammon Internet shopping Taxi


??Observable FULL FULL PARTIAL PARTIAL

??Deterministic YES NO YES NO

??Episodic NO NO NO NO

??Static YES YES SEMI NO

??Discrete

??Single-agent

AI 1
Intelligent
10 december 20 Agents
33 2022 33/48
22
CS321: Principles of Artificial Intelligence

The Nature of Environments

Discrete vs. continuous: This distinction can be applied to the state of the
environment, the way time is handled and to the percepts/actions of the agent.

Solitaire Backgammon Internet shopping Taxi


??Observable FULL FULL PARTIAL PARTIAL

??Deterministic YES NO YES NO

??Episodic NO NO NO NO

??Static YES YES SEMI NO

??Discrete YES YES YES NO

??Single-agent

AI 1
Intelligent
10 december 20 Agents
34 2022 34/48
22
CS321: Principles of Artificial Intelligence

The Nature of Environments

Single vs. multi-agent: Does the environment contain other agents who
are also maximizing some performance measure that depends on the
current agent’s actions?

Solitaire Backgammon Internet shopping Taxi


??Observable FULL FULL PARTIAL PARTIAL

??Deterministic YES NO YES NO

??Episodic NO NO NO NO

??Static YES YES SEMI NO

??Discrete YES YES YES NO

??Single-agent

AI 1
Intelligent
10 december 20 Agents
35 2022 35/48
22
CS321: Principles of Artificial Intelligence

The Nature of Environments

Single vs. multi-agent: Does the environment contain other agents who
are also maximizing some performance measure that depends on the
current agent’s actions?

Solitaire Backgammon Internet shopping Taxi


??Observable FULL FULL PARTIAL PARTIAL

??Deterministic YES NO YES NO

??Episodic NO NO NO NO

??Static YES YES SEMI NO

??Discrete YES YES YES NO

??Single-agent YES NO NO NO

AI 1
Intelligent Agents 2022 36/48
CS321: Principles of Artificial Intelligence

The Nature of Environments

• The environment type largely determines the agent design.

• The simplest environment is


• Fully observable, deterministic, episodic, static, discrete and single-agent.

• Most real situations are:


• Partially observable, stochastic, sequential, dynamic, continuous and multi-agent.

Intelligent Agents 2022 37/48


CS321: Principles of Artificial Intelligence

The Structure of Agents


• The job of AI is to design the agent program that implements the
agent function mapping percepts to actions. Assuming this
program will run on some sort architecture of computing device
with physical sensors and actuators.

• Four basic kinds of agent program that embody the principles


underlying almost all intelligent systems:

• Simple reflex agents


• Model-based reflex agents
• Goal-based agents
• Utility-based agents

Intelligent Agents 2022 38/48


CS321: Principles of Artificial Intelligence

The Structure of Agents (2/6)


• Simple reflex agents
• characteristics
• no plan, no goal
• do not know what they want to
achieve
• do not know what they are doing
• condition-action rule
• If condition then action
• architecture function REFLEX_VACUUM_AGENT( percept )
returns an action
(location,status) = UPDATE_STATE( percept )
if status = DIRTY then return SUCK;
else if location = A then return RIGHT;
else if location = B then return LEFT;

Intelligent Agents 2022 39/48


CS321: Principles of Artificial Intelligence

The Structure of Agents (3/6)

• Model-based reflex agents New


• characteristics
• Reflex agent with internal state
• Sensor does not provide the complete state
of the world.
• must keep its internal state
• Updating the internal world
• requires two kinds of knowledge
• How world evolves
• How agent’s action affect the world
• architecture

Intelligent Agents 2022 40/48


CS321: Principles of Artificial Intelligence

The Structure of Agents (4/6)

 Goal-based agents
 Characteristics
 Action depends on the goal . (consideration of future)
 e.g. path finding
 fundamentally different from the condition-action rule.
 Search and Planning

New
 Solving “car-braking” problem?
 yes, possible, … but not likely natural.
 appears less efficient.
 architecture

Intelligent Agents 2022 41/48


CS321: Principles of Artificial Intelligence

The Structure of Agents (5/6)


 Utility-based agents
 Characteristics
 to generate high-quality behavior
 map the internal states to real
numbers.
(e.g., game playing) New
 Looking for higher utility value
 utility function
 architecture

Intelligent Agents 2022 42/48


CS321: Principles of Artificial Intelligence

The Structure of Agents (6/6)

 Learning agents
 architecture

Any other
agent!

Intelligent Agents 2022 43/48


CS321: Principles of Artificial Intelligence

AIMA Code

https://github.com/aimacode

Intelligent Agents 2022 44/48


CS321: Principles of Artificial Intelligence

Summary
• To conclude:

• An agent is something that perceives and acts in an environment.


• A task environment specification includes the performance measure, the external environment, the
actuators. and the sensors.
• Task environments vary along several significant dimensions. They can be fully or partially
observable, single-agent or multiagent, deterministic or stochastic, episodic or sequential, static or
dynamic, discrete or continuous, and known or unknown.
• There exists a variety of basic agent-program designs reflecting the kind of information made explicit
and used in the decision. They are: simple reflex agents, model-based reflex agents, goal-based

agents and utility-based agents.

Intelligent Agents 2022 45/48


CS321: Principles of Artificial Intelligence

THANKS

Intelligent Agents 2022 46/48

You might also like