Intelligent Agents 2 AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 - - PowerPoint PPT Presentation

intelligent agents
SMART_READER_LITE
LIVE PREVIEW

Intelligent Agents 2 AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 - - PowerPoint PPT Presentation

Intelligent Agents 2 AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 1 2 Intelligence Agents 2.1 Agents 2.2 Agent programs 2.3 Rationality 2.4 Environments 2.5 Agent structures AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 2 Agents


slide-1
SLIDE 1

Intelligent Agents

2

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 1

slide-2
SLIDE 2

2 Intelligence Agents 2.1 Agents 2.2 Agent programs 2.3 Rationality 2.4 Environments 2.5 Agent structures

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 2

slide-3
SLIDE 3

Agents

An agent is an entity that perceives and acts in an environment Agents include – animal agents – human agents – robotic agents (robots) – software agents (softbots) – – internet agents – – – crawler – – – webbot – – – email agent – – – search agent, etc. – – chatbots – – – Cortana/Siri/GAssistant/Waston/Alexa/FMessenger/· · · Single agent or usually multi-agents (so-called distributed AI)

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 3

slide-4
SLIDE 4

Agents and environments

? agent percepts sensors actions environment actuators

An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment through actuators

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 4

slide-5
SLIDE 5

Sensors and actuators

A sensor measures some aspect of the environment in a form that can be used as input by an agent – vision, hearing, touch – radio, infrared, GPS, wireless signals – active sensing: send out a signal (such as radar or ultrasound) and sense the reflection of this signal off of the environment ⇒ IoT (Internet of Things) Perception provides agents with information about the world they inhabit by interpreting the response of sensors Actuators – hands, legs, vocal tract etc. – automated taxi: those available to a human driver e.g., accelerator, steering, braking and so on

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 5

slide-6
SLIDE 6

Agent functions

An agent is completely specified by the agent function : maps from percept histories to actions f : P∗ → A For any given class of environments and tasks, we seek the agent (or class of agents) with the best performance Find a way to implement the rational agent function concisely

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 6

slide-7
SLIDE 7

Agent programs

The agent program runs on the physical architecture to produce the agent function agent = architecture + program program = algorithm + data The agent program takes a single percept as input, keeps internal state

function Skeleton-Agent( percept) returns action persistent: memory, the agent’s memory of the world memory ← Update-Memory(memory, percept) action ← Choose-Best-Action(memory) memory ← Update-Memory(memory, action) return action

The algorithm is described by the pseudocode

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 7

slide-8
SLIDE 8

Another form of algorithm

A procedure for the skeleton-agent that takes a single percept as input, keeps internal state

Procedure of Skeleton-Agent Input: percept Output: action memory the agent’s memory of the world

  • 1. memory ← Update-Memory(memory, percept)
  • 2. action ← Choose-Best-Action(memory)
  • 3. memory ← Update-Memory(memory, action)

The algorithm is also described by the pseudocode

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 8

slide-9
SLIDE 9

Algorithm

Recall: an algorithm is an explicit effective set of instructions for a computing procedure – may be used to find the answers to any of a given class of questions – can be precisely defined by computational models, e.g., Turing machine, etc. Analysis of algorithms, independently of the particular implementation and input – time complexity: speed in seconds e.g., the worst Tworst(n) or the average Tavg(n) – space complexity: memory consumption in bytes Complexity analyzes problems rather than algorithms

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 9

slide-10
SLIDE 10

Algorithm

O-notation: asymptotic analysis T(n) is O(f(n)) if T(n) ≤ kf(n) for some k, for all n > 0 O(nk) for some k: polynomial time/space, called P or “easiness” Otherwise, exponential time/space, e.g., O(2n), called NP, hardness – class of nondeterministic (Turing machine) polynomial problems guess a solution and then verify whether the guess is correct in polynomial time – NP-complete problems (the hardest subclass of NP) – – co-NP (-complete) is the complement of NP (-complete) “yes” and“no” answers reversed Theorem: either all the NP-complete problems are in P or none of them is

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 10

slide-11
SLIDE 11

Algorithm

NP = P?? if you could try all the guesses at once, or you were very lucky and always guess right the first time #P: counting problems corresponding to decision problems in NP decision problems have a yes-or-no answer, counting problems have an integer answer: how many solutions at least as hard as any NP problems PSPACE: require a polynomial amount of space, even on a non- deterministic machine it is believed that PSPACE-hard problems are worse than NP- complete problems although it could turn out that NP = PSPACE, just as P = NP

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 11

slide-12
SLIDE 12

The pseudocode

The pseudocode is a simple language to describe algorithms – similar to programming language like Java, C, Python or Lisp – informal to use mathematical formulas or ordinary English to describe parts

  • Persistent variables (global and local variables): a variable is

given an initial value the first time a function is called and re- tains that value on all subsequent calls to the function. The agent programs use persistent variables for memory. Variables have low- ercase italic names.

  • Function as values: The value of a variable is allowed to be a
  • function. Functions and procedures have capitalized names
  • Indentation is significant: the scope of a loop or conditional

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 12

slide-13
SLIDE 13

The pseudocode

  • Assignment: ”x ← value” means that the right-hand side eval-

uate to the left-hand side variable – Destructuring assignment: ”x, y ← pair” means that the right-hand side evaluate to a two-element tuple, and the first element is assigned to x and the second to y. Or ”for each x, y in pair do”

  • if-then (-else): ”if c then · · · else · · ·” means that if the con-

dition c is hold then doing something; otherwise doing something else

  • for each: ”for each x in c do” means that the loop is executed

with the variable x bound to successive elements of the collection

  • c. Or ”while c do” or even ”loop · · · ”
  • Generators and yield: ”generator G(x) yields number” de-

fines G as a generator function

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 13

slide-14
SLIDE 14

The pseudocode

  • Lists: [x, y, z], [first|rest]
  • Sets: {x, y, z}
  • Arrays start at 1: as in usual mathematical notation, not 0 as

in Java and C

  • /* the explanations can be given as remarks */

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 14

slide-15
SLIDE 15

The code

The algorithms in the pseudocode can be implemented in Java, C/C++, Python, Lisp and Prolog etc. The (Lisp) code for each topic is divided into four directories: – agents: code defining agent types and programs – algorithms: code for the methods used by the agent programs – environments: code defining environment types, simulations – domains: problem types and instances for input to algorithms (Often run algorithms on domains rather than agents in environ- ments)

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 15

slide-16
SLIDE 16

A coding (Lisp)

(setq joe (make-agent :name ’joe :body (make-agent-body) :program (make-dumb-agent-program))) (defun make-dumb-agent-program () (let ((memory nil)) #’(lambda (percept) (push percept memory) ’no-op)))

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 16

slide-17
SLIDE 17

Rationality

A rational agent is one that does right thing – to achieve the best performance “goals” specifiable by performance measure defining a numerical value for any environment history Rational action: whichever action maximizes the expected value of the performance measure given the percept sequence to date Limited rationality: computational limitations make perfect ra- tionality unachievable ⇒ design best program for given machine resources Rational = omniscient – percepts may not supply all relevant information Rational = clairvoyant – action outcomes may not be as expected ⇒ rational = successful

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 17

slide-18
SLIDE 18

Vacuum-cleaner world

Example: Robot cleaner, say, iRobot Roombat

A B

Percepts: location and contents, e.g., [A, Dirty] Actions: Left, Right, Suck, NoOp

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 18

slide-19
SLIDE 19

A vacuum-cleaner agent

Percept sequence Action [A, Clean] Right [A, Dirty] Suck [B, Clean] Left [B, Dirty] Suck [A, Clean], [A, Clean] Right [A, Clean], [A, Dirty] Suck . . . . . .

function Reflex-Vacuum-Agent( [location,status]) returns an action if status = Dirty then return Suck else if location = A then return Right else if location = B then return Left

What is the right function? Can it be implemented in a program?

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 19

slide-20
SLIDE 20

Vacuum-cleaner rational agent

Fixed performance measure evaluates the environment sequence – one point per square cleaned up in time T? – one point per clean square per time step, minus one per move? – penalize for > k dirty squares?

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 20

slide-21
SLIDE 21

PEAS (Performance/Environment/Actuators/Sensors)

To design a rational agent, we must specify the task environment E.g., an automated taxi (intelligent vehicle): Performance measure?? Environment?? Actuators?? Sensors??

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 21

slide-22
SLIDE 22

Example: automated taxi agent

To design a rational agent, we must specify the task environment E.g., intelligent vehicle (an automated taxi): Performance measure?? safety, destination, profits, legality, . . . Environment?? streets, traffic, pedestrians, weather, . . . Actuators?? steering, accelerator, brake, horn, speaker/display, . . . Sensors?? video, accelerometers, gauges, engine sensors, GPS, . . .

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 22

slide-23
SLIDE 23

Example: Internet shopping agent

Performance measure?? Environment?? Actuators?? Sensors??

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 23

slide-24
SLIDE 24

Internet shopping agent

Performance measure?? price, quality, appropriateness, efficiency, . . . Environment?? web sites, vendors, shippers, . . . Actuators?? display to user, follow URL, fill in form, . . . Sensors?? pages (text, graphics, scripts), . . .

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 24

slide-25
SLIDE 25

Environments

Solitaire Backgammon Internet shopping Taxi Observable?? Deterministic?? Episodic?? Static?? Discrete?? Single-agent??

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 25

slide-26
SLIDE 26

Environments

Solitaire Backgammon Internet shopping Taxi Observable?? Yes Yes No No Deterministic?? Episodic?? Static?? Discrete?? Single-agent??

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 26

slide-27
SLIDE 27

Environments

Solitaire Backgammon Internet shopping Taxi Observable?? Yes Yes No No Deterministic?? Yes No Partly No Episodic?? Static?? Discrete?? Single-agent??

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 27

slide-28
SLIDE 28

Environments

Solitaire Backgammon Internet shopping Taxi Observable?? Yes Yes No No Deterministic?? Yes No Partly No Episodic?? No No No No Static?? Discrete?? Single-agent??

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 28

slide-29
SLIDE 29

Environments

Solitaire Backgammon Internet shopping Taxi Observable?? Yes Yes No No Deterministic?? Yes No Partly No Episodic?? No No No No Static?? Yes Semi Semi No Discrete?? Single-agent??

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 29

slide-30
SLIDE 30

Environments

Solitaire Backgammon Internet shopping Taxi Observable?? Yes Yes No No Deterministic?? Yes No Partly No Episodic?? No No No No Static?? Yes Semi Semi No Discrete?? Yes Yes Yes No Single-agent??

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 30

slide-31
SLIDE 31

Environments

Solitaire Backgammon Internet shopping Taxi Observable?? Yes Yes No No Deterministic?? Yes No Partly No Episodic?? No No No No Static?? Yes Semi Semi No Discrete?? Yes Yes Yes No Single-agent?? Yes No Yes (except auctions) No The environment type largely determines the agent design The real world is (of course) partially observable, stochastic, sequen- tial, dynamic, continuous, multi-agent

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 31

slide-32
SLIDE 32

Agent structures

Agents interact with environments through sensors and actuators

Agent

Sensors Actuators

Environment

Percepts Actions

?

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 32

slide-33
SLIDE 33

Agent structures

Four basic types in order of increasing generality: – simple reflex agents – reflex agents with state – goal-based agents – utility-based agents All these can be turned into – learning agents

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 33

slide-34
SLIDE 34

Simple reflex agents

Agent Environment

Sensors What action I should do now Condition-action rules Actuators What the world is like now

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 34

slide-35
SLIDE 35

Simple reflex agents

function Simple-Reflex-Agent( percept) returns an action persistent: rules, a set of condition-action rules state ← Interpret-Input(percept) rule ← Rule-Match(state,rules) action ← rule.action return action

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 35

slide-36
SLIDE 36

Example

function Reflex-Vacuum-Agent( [location,status]) returns an action if status = Dirty then return Suck else if location = A then return Right else if location = B then return Left

(setq joe (make-agent :name ’joe :body (make-agent-body) :program (make-reflex-vacuum-agent-program))) (defun make-reflex-vacuum-agent-program () #’(lambda (percept) (let ((location (first percept)) (status (second percept))) (cond ((eq status ’dirty) ’Suck) ((eq location ’A) ’Right) ((eq location ’B) ’Left)))))

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 36

slide-37
SLIDE 37

Model-based reflex agents

Agent Environment

Sensors State How the world evolves What my actions do Condition-action rules Actuators What the world is like now What action I should do now

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 37

slide-38
SLIDE 38

Example

function Reflex-Vacuum-Agent( [location,status]) returns an action persistent: last A, last B, numbers, initially ∞ if status = Dirty then . . .

(defun make-reflex-vacuum-agent-with-state-program () (let ((last-A infinity) (last-B infinity)) #’(lambda (percept) (let ((location (first percept)) (status (second percept))) (incf last-A) (incf last-B) (cond ((eq status ’dirty) (if (eq location ’A) (setq last-A 0) (setq last-B 0)) ’Suck) ((eq location ’A) (if (> last-B 3) ’Right ’NoOp)) ((eq location ’B) (if (> last-A 3) ’Left ’NoOp)))))))

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 38

slide-39
SLIDE 39

Goal-based agents

Agent Environment

Sensors What action I should do now State How the world evolves What my actions do Actuators What the world is like now What it will be like if I do action A Goals

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 39

slide-40
SLIDE 40

Utility-based agents

Agent Environment

Sensors How happy I will be in such a state State How the world evolves What my actions do Utility Actuators What action I should do now What it will be like if I do action A What the world is like now

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 40

slide-41
SLIDE 41

Learning agents

Performance standard

Agent Environment

Sensors Performance element changes knowledge learning goals Problem generator feedback Learning element Critic Actuators

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 41

slide-42
SLIDE 42

The agent projects

Design and implement a simple but useful agent – Just right now on the progress with the new knowledge charpter- by-charpter selectively – by a programming language which you are familiar with – in a software environment or platform – single agent or multi-agents (group) Options

  • Internet agent (say, smart shopping, chatbot)
  • Intelligent robot
  • Intelligent motor
  • Intelligent drone
  • Coding algorithms and finding applications

AI Slides (6e) c Lin Zuoquan@PKU 1998-2020 2 42