Intelligent Agents Lecture Notes PDF
Document Details
Uploaded by Deleted User
Tags
Summary
This document is a lecture on intelligent agents, exploring fundamental concepts like agents, agent programs, and different types of agents (e.g., animal, human, robotic, internet agents). The lecture also delves into agent structures, agent programs, and algorithms, along with practical examples such as a vacuum-cleaner agent and an automated taxi agent.
Full Transcript
Intelligent Agents 2 2 1 2 Intelligence Agents 2.1 Agents 2.2 Agent programs 2.3 Rationality 2.4 Environments 2.5 Agent structures 2.6 Multi-agent systems 2 2 ...
Intelligent Agents 2 2 1 2 Intelligence Agents 2.1 Agents 2.2 Agent programs 2.3 Rationality 2.4 Environments 2.5 Agent structures 2.6 Multi-agent systems 2 2 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) 2 3 Agents and environments sensors percepts ? environment agent actions actuators An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment through actuators 2 4 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 2 5 Example: Vacuum-cleaner world Example: Robot cleaner, say, iRobot Roombat A B Percepts: location and contents, e.g., [A, Dirty] Actions: Lef t, Right, Suck, N oOp 2 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 2 7 Example: A vacuum-cleaner agent Percept sequence Action [A, Clean] Right [A, Dirty] Suck [B, Clean] Lef t [B, Dirty] Suck [A, Clean], [A, Clean] Right [A, Clean], [A, Dirty] Suck.... What is the right function? Can it be implemented in a program? 2 8 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 def Skeleton-Agent( percept) 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 2 9 Other forms of algorithm function Skeleton-Agent( percept) returns action // output result inputs: percept, input from sensors // may be omitted 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 // output The algorithm is described by the pseudocode 2 10 Other forms 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 described by the pseudocode 2 11 Other forms of algorithm Popular forms of pseudocode are written by LATEXalgorithmic packages (e.g., alrorithm2e) 1: procedure Skeleton-Agent(percept) 2: memory: the agent’s memory of the world 3: memory ← Update-Memory(memory, percept) 4: action ← Choose-Best-Action(memory) 5: memory ← Update-Memory(memory, action) 6: return action 2 12 Algorithm 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 2 13 The pseudocode The pseudocode is a simple language to describe algorithms – similar to programming languages like C, Java, Lisp or Python – 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 Default values for parameters: “function F (x, y = 0) return a number” means that is an optional argument with default value 0, i.e., the calls F (3, 0) and F (3) are equivalent 2 16 The pseudocode Indentation is significant: the scope of a loop, conditional or statement block 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” Conditiolnal if c then · · · (else) · · ·: if the condition c is hold then doing something; otherwise doing something else 2 17 The pseudocode Loops – for x in c do: the loop is executed with the variable x bound to successive elements of the collection c or for each x in c do – for i = 1 to n do: the loop is executed with bound to successive integers from 1 to n inclusive – while c (condition) do”: means the condition is evaluated be- fore each iteration of the loop, and the loop exits if the condition is false or loop c · · · – repeat · · · until c: the loop is executed unconditionally the first time, then the condition is evaluated, and the loop exits if the condition is true; otherwise the loop keeps executing (and testing at the end) 2 18 The pseudocode Generator: a function that contains yield is a generators that generates a sequence of values, one each time the yield expression is encountered. After yielding, the function continues execution with the next statement, say, “generator G(x) yields number” defines G as a generator function Data types: data structure – Lists: [x, y, z], [f irst|rest] – Sets: {x, y, z} – Arrays start at 1: as in usual mathematical notation, not 0 as in Python // the explanations can be given as remark 2 19 The code The algorithms in the pseudocode can be implemented in Python, Java, C/C++, Lisp and Prolog etc. The 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) 2 20 A Python coding∗ import environment as en import domain as do import action as ac def skeleton_agent(percept): m = [] m = do.push(percept) a = ac.choose() #chosen from action class m = ac.update() return a ∗ may be tried, programming language and programming methodol- ogy are prerequisite which are out of the basic requirement of this course 2 21 Example: A vacuum-cleaner agent def Table-Driven-Agent( percept) persistent: percepts, a sequence, initially empty table, a table, indexed by percept sequences, initially fully specified append percept to the end of percepts action ← Lookup( percepts, table) return action 2 22 Python: A vacuum-cleaner agent∗ def Table_Driven_Vacuum_Agent(table): """ A table is provided as a dictionary of all {percept_sequence:action} pairs. """ percepts = [] def agent(percept): percepts.append(percept) action = table.get(tuple(percepts)) return action return agent Hint: It can be executable Python code 2 23 Python: A vacuum-cleaner agent∗ def Table_Driven_Vacuum_Agent(): """Tabular approach towards vacuum world >>> agent = Table_Driven_Vacuum_Agent() >>> environment = VacuumEnvironment() >>> environment.add_thing(agent) >>> environment.run() >>> environment.status == {(1,0):'Clean' , (0,0) : 'Clean'} True """ table = {((loc_A, 'Clean'),): 'Right', ((loc_A, 'Dirty'),): 'Suck', ((loc_B, 'Clean'),): 'Left', ((loc_B, 'Dirty'),): 'Suck', ((loc_A, 'Dirty'), (loc_A, 'Clean')): 'Right', ((loc_A, 'Clean'), (loc_B, 'Dirty')): 'Suck', ((loc_B, 'Clean'), (loc_A, 'Dirty')): 'Suck', ((loc_B, 'Dirty'), (loc_B, 'Clean')): 'Left', ((loc_A, 'Dirty'), (loc_A, 'Clean'), (loc_B, 'Dirty')): 'Suck', ((loc_B, 'Dirty'), (loc_B, 'Clean'), (loc_A, 'Dirty')): 'Suck'} return Agent(Table_Driven_Vacuum_Agent(table)) Hint: It can be executable Python code 2 24 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 2 25 Limited rationality Limited rationality: computational limitations make perfect rational- ity 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 Rational ⇒ exploration, learning, autonomy 2 26 Example: 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? 2 27 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?? 2 28 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,... 2 29 Example: Internet shopping agent Performance measure?? Environment?? Actuators?? Sensors?? 2 30 Example: 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),... 2 31 Environments Solitaire Backgammon Internet shopping Taxi Observable?? Deterministic?? Episodic?? Static?? Discrete?? Single-agent?? 2 32 Environments Solitaire Backgammon Internet shopping Taxi Observable?? Yes Yes No No Deterministic?? Episodic?? Static?? Discrete?? Single-agent?? 2 33 Environments Solitaire Backgammon Internet shopping Taxi Observable?? Yes Yes No No Deterministic?? Yes No Partly No Episodic?? Static?? Discrete?? Single-agent?? 2 34 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?? 2 35 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?? 2 36 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?? 2 37 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 2 38 Agent structures Agents interact with environments through sensors and actuators Agent Sensors Percepts Environment ? Actions Actuators 2 39 Agent structures Four basic types in order of increasing generality: – simple reflex agents – model-based reflex agents – goal-based agents – utility-based agents All these can be turned into – learning agents 2 40 Simple reflex agents Agent Sensors What the world is like now Environment Condition-action rules What action I should do now Actuators 2 41 Example: A vacuum-cleaner agent def Reflex-Vacuum-Agent( [location,status]) if status = Dirty then return Suck else if location = A then return Right else if location = B then return Left 2 42 Simple reflex agents def Simple-Reflex-Agent( percept) persistent: rules, a set of condition-action rules state ← Interpret-Input(percept) rule ← Rule-Match(state, rules) action ← rule.action return action 2 43 Model-based reflex agents Sensors State What the world How the world evolves is like now Environment What my actions do What action I Condition−action rules should do now Agent Actuators Reflex agents with (internal) state transition model - how the world works 2 44 Goal-based agents Sensors State What the world How the world evolves is like now Environment What it will be like What my actions do if I do action A What action I Goals should do now Agent Actuators 2 45 Utility-based agents Sensors State What the world How the world evolves is like now Environment What it will be like What my actions do if I do action A Utility How happy I will be in such a state What action I should do now Agent Actuators 2 46 Learning agents Performance standard Critic Sensors feedback Environment changes Learning Performance element element knowledge learning goals Problem generator Actuators Agent 2 47 Multi-agent systems MAS (multi-agent systems): a agent interacts with neighbouring agents a complex task is divided into multiple smaller tasks, each of which is assigned to a distinct agent Applications - modeling complex systems - smart grids - computer networks – cloud computing, social networking, security, routing - etc. 2 48 Properties of MAS Coordination: managing agents to collaboratively reach their goals. consensus - achieving a global agreement. controllability - using certain regulations to transmit a state. synchronization - aligning each agent in time with other agents. connection - connecting to each other. formation - organizing in a structure Communication: communicating among agents Fault detection and isolation (FDI): a faulty agent may infect other agents that it collaborates with Task allocation: allocation of tasks to agents considering the associ- ated cost and time Localization: each agent has limited view (only its neighbors) 2 49 Agent organization The way agents communicate and connect Flat - all agents are regarded as equals Hierarchy - agents have tree-like relations Holon - agents are organized in multiple groups which are known as holons based on particular features (e.g., heterogeneity), holons are then multiply layered Coalition - agents are temporarily grouped based on their goal team - agents create a team and define a team goal which differs with their own goal Matrix - each agent is managed by at least two head agents Congregation - agents in a location form a congregation to achieve their requirements that they cannot achieve alone 2 50 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 2 51