Intelligent Agents Chapter 2 – AIMA Dr. Aarij Mahmood Hussaan What is an (Intelligent) Agent? • An over-used, over-loaded, and misused term. • Anything that can be viewed as perceiving its environment through sensors and acting upon that environment through its actuators to maximize progress towards its goals. What is an (Intelligent) Agent? • PAGE (Percepts, Actions, Goals, Environment) • PEAS[AIMA] (Performance, Environment, Actuators, Sensors) • Task-specific & specialized: well-defined goals and environment • The notion of an agent is meant to be a tool for analyzing systems, • It is not a different hardware or new programming languages Agent • Percept • agent’s perceptual inputs at any given instant • Percept Sequence • the complete history of everything the agent has ever perceived • Agent’s action depends upon the complete history of percept sequence to date Agents and environments • Agents include humans, robots, softbots, thermostats, etc. • The agent function maps from percept histories to actions: f : P* A • The agent program runs on the physical architecture to produce f Vacuum-cleaner world • Percepts: location and contents, e.g., [A;Dirty] • Actions: Left, Right, Suck, NoOp A vacuum-cleaner agent 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 small agent program? Rationality 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? A rational agent chooses whichever action maximizes the expected value of the performance measure given the percept sequence to date Rational != omniscient • percepts may not supply all relevant information Rational != clairvoyant • action outcomes may not be as expected Hence, rational != successful Rational => exploration, learning, autonomy Agent To design a rational agent, we must specify the task environment Consider, e.g., the task of designing an automated taxi: Performance measure?? Environment?? Actuators?? Sensors?? Agent To design a rational agent, we must specify the task environment Consider, e.g., the task of designing an automated taxi: Performance measure?? safety, destination, profits, legality, comfort, .. Environment?? streets/highways, tracks, pedestrians, weather, Actuators?? steering, accelerator, brake, horn, speaker/display,…. Sensors?? video, accelerometers, gauges, engine sensors, keyboard, GPS, :… Some more examples A Windshield Wiper Agent Goals:? Percepts:? Sensors:? Actuators: ? Actions:? Environment: ? A Windshield Wiper Agent Goals: Keep windshields clean & maintain visibility Percepts: Raining, Dirty Sensors: Camera (moist sensor) Actuators: Wipers (left, right, back) Actions: Off, Slow, Medium, Fast Environment: Inner city, freeways, highways, weather … Internet shopping agent Performance measure?? price, quality, appropriateness, efficiency Environment?? current and future WWW sites, vendors, shippers Actuators?? display to user, follow URL, fill in form Sensors?? HTML pages (text, graphics, scripts) Interacting Agents Collision Avoidance Agent (CAA) Goals : Avoid running into obstacles Percepts: ? Sensors:? Actuators:? Actions: ? Environment: Freeway Lane Keeping Agent (LKA) •Goals : Stay in current lane •Percepts:? •Sensors:? •Actuators:? •Actions:? •Environment: Freeway Interacting Agents Collision Avoidance Agent (CAA) Goals : Avoid running into obstacles Percepts: Obstacle distance, velocity, trajectory Sensors: Vision, proximity sensing Actuators : Steering Wheel, Accelerator, Brakes, Horn, Headlights Actions : Steer, speed up, brake, blow horn, signal (headlights) Environment: Freeway Lane Keeping Agent (LKA) •Goals : Stay in current lane •Percepts: Lane center, lane boundaries •Sensors: Vision •Actuators: Steering Wheel, Accelerator, Brakes •Actions: Steer, speed up, brake •Environment: Freeway Conflict Resolution by Action Selection Agents • Override: CAA overrides LKA • Arbitrate: if Obstacle is Close then CAA else LKA • Compromise: Choose action that satisfies both agents • Any combination of the above • Challenges: Doing the right thing Behavior and performance of IAs Perception(sequence) to Action Mapping: f : P* A ◦Ideal mapping: specifies which actions an agent ought to take at any point in time ◦Description: Look-Up-Table, Closed Form, etc. Performance measure: a subjective measure to characterize how successful an agent is (e.g., speed, power usage, accuracy, money, etc.) (degree of) Autonomy: to what extent is the agent able to make decisions and take actions on its own? Look up table Closed form • Output (degree of rotation) = F(distance) • E.g., F(d) = 10/d (distance cannot be less than 1/10) How is an Agent different from other software? • Agents are autonomous, that is, they act on behalf of the user • Agents contain some level of intelligence, from fixed rules to learning engines that allow them to adapt to changes in the environment • Agents don't only act reactively, but sometimes also proactively • Agents have social ability, that is, they communicate with the user, the system, and other agents as required • Agents may also cooperate with other agents to carry out more complex tasks than they themselves can handle • Agents may migrate from one system to another to access remote resources or even to meet other agents Environment types • Fully observable vs. partially observable • Single agent vs. multi-agent • Deterministic vs. stochastic • Episodic vs. sequential • Static vs. dynamic • Discrete vs. continuous • (Known vs. unknown) Environment types Solitaire Observable? Deterministic? Episodic? Static? Discrete? Single-agent? Chess Internet Shopping Taxi Environment types Solitaire Observable? Deterministic? Episodic? Static? Discrete? Single-agent? Yes Chess Yes Internet Shopping No Taxi No Environment types Solitaire Chess Internet Shopping Taxi Observable? Yes Yes No No Deterministic? Yes No Partly No Episodic? Static? Discrete? Single-agent? Environment types Solitaire Chess Internet Shopping Taxi Observable? Yes Yes No No Deterministic? Yes No Partly No Episodic? No No No No Static? Discrete? Single-agent? Environment types Solitaire Chess 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? Environment types Solitaire Chess 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? Environment types Solitaire Chess 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, sequential, dynamic, continuous, multi-agent Structure of Intelligent Agents • Agent = architecture + program • Agent program: the implementation of f : P* A, the agent’s perception-action mapping Function Skeleton-Agent(Percept) returns Action memory UpdateMemory(memory, Percept) Action ChooseBestAction(memory) memory UpdateMemory(memory, Action) Return Action • Architecture: a device that can execute the agent program (e.g., general-purpose computer, specialized device, beobot, etc.) Using a look-up-table to encode f : P* A • Example: Collision Avoidance ◦Sensors:3 proximity sensors ◦Effectors: Steering Wheel, Brakes • How to generate? • How large? • How to select action? Using a look-up-table to encode f : P* A • Example: Collision Avoidance ◦Sensors: 3 proximity sensors ◦Effectors: Steering Wheel, Brakes • How to generate: for each p ∈ Pl x Pm x Pr generate an appropriate action, a ∈ S x B • How large: size of table = #possible percepts * #possible actions = |Pl | |Pm| |Pr| |S| |B| E.g., P = {close, medium, far}3 A = {left, straight, right} {on, off} then size of table = 27*3*2 = 162 • How to select action? Search. Agent types • 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 Simple reflex agents Simple reflex agents 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 Reflex agents with state Reflex agents with state Goal-based agents Utility-based agents Learning agents Summary Agents interact with environments through actuators and sensors The agent function describes what the agent does in all circumstances The performance measure evaluates the environment sequence A perfectly rational agent maximizes expected performance Agent programs implement (some) agent functions PEAS descriptions define task environments Environments are categorized along several dimensions: • observable? deterministic? episodic? static? discrete? single-agent? Several basic agent architectures exist: • reflex, reflex with state, goal-based, utility-based