CMP346 Artificial Intelligence

Artificial IntelligenceUnit 29 min read

Intelligent Agents: Types, Environments & Rationality

Unit 2 of Artificial Intelligence explores intelligent agents—autonomous entities that perceive and act in environments—covering agent types (reflex, model-based, goal-based), environment characteristics (accessible, deterministic, episodic), and rationality principles with worked examples from real-world systems like

What is an Intelligent Agent?

An intelligent agent is an autonomous entity that perceives its environment through sensors and acts upon it via actuators to achieve goals. It is the core concept in AI, bridging perception and action.

Key Components of an Agent

PerceptSequence (sensors)Action (actuators)AgentEnvironment
Agent-Environment interaction: Percepts flow from Environment to Agent via sensors; Actions flow back via actuators.

Agent Function vs. Agent Program

  • Agent Function: Maps any percept sequence to an action.
  • Agent Program: The implementation of the agent function (e.g., code, rules).

Example: A thermostat agent:

  • Percepts: Temperature readings.
  • Actions: Turn heater on/off.
  • Agent Program: If temperature < 20°C, turn heater on.

Types of Intelligent Agents

Agents are classified based on their percept sequence and agent program. Below are the four primary types:

1. Simple Reflex Agents

  • How it works: Acts based on the current percept only (no history).
  • Agent Program: Condition-Action rules (if-then).
  • Example: Vacuum cleaner that cleans if it detects dirt.
graph TD
    A["Percept: Dirt Detected"] --> B["Action: Suck"]
    A --> C["Percept: No Dirt"] --> D["Action: Move"]

Limitations:

  • Cannot learn or improve.
  • Fails in dynamic environments (e.g., dirt reappears).

2. Model-Based Reflex Agents

  • How it works: Maintains an internal state (model of the world) to track changes.
  • Agent Program: Uses history of percepts to update state.
  • Example: A robot that remembers if it has cleaned a room before.

Worked Example: Suppose a robot has two rooms, A and B, and starts in A.

  • Percepts: Dirty(A), Clean(A), Dirty(B).
  • State Update:
    • Initially: State = {A: Clean, B: Dirty}.
    • After cleaning A: State = {A: Clean, B: Dirty} (no change if already clean).
    • After moving to B: State = {A: Clean, B: Clean} (after cleaning B).

Advantages:

  • Handles partially observable environments.
  • Can track changes over time.

3. Goal-Based Agents

  • How it works: Chooses actions to achieve a goal state (not just react to percepts).
  • Agent Program: Uses a goal test to evaluate success.
  • Example: A delivery drone that must reach a specific location.

Worked Example: A drone must deliver a package to Location X.

  • Percepts: GPS coordinates, battery level.
  • Goal Test: IsCurrentLocation(X) && IsPackageDelivered?
  • Actions: Navigate toward X, avoid obstacles.

Limitations:

  • Requires a problem-solving component (e.g., search algorithms).
  • Computationally expensive for complex goals.

4. Utility-Based Agents

  • How it works: Maximizes expected utility (not just achieving a goal).
  • Agent Program: Uses a utility function to rank actions.
  • Example: A stock trading bot that balances risk and profit.

Worked Example: A bot trades stocks with:

  • Utility Function: .
  • Actions:
    • Buy (Profit = +5, Risk = 3) → .
    • Hold (Profit = 0, Risk = 0) → .
    • Sell (Profit = -2, Risk = 1) → .
  • Best Action: Hold (highest utility).

Advantages:

  • Handles uncertainty and trade-offs.
  • Used in reinforcement learning.

Environment Characteristics

Agents interact with environments that vary in accessibility, determinism, episodicity, and staticness. Below is a comparison table:

Property Description Example
Fully Observable Agent can sense everything in the environment. Chess (board fully visible).
Partially Observable Agent has limited sensors (e.g., robot with limited cameras). Self-driving car (blind spots).
Deterministic Next state depends only on current state and action. Tic-Tac-Toe (no random moves).
Stochastic Next state has randomness (e.g., dice roll). Poker (opponent cards unknown).
Episodic Agent’s actions divided into atomic decisions (no history needed). Playing a single game of chess.
Sequential Current decisions affect future states. Stock trading (today’s buy affects tomorrow’s price).
Static Environment does not change except by agent’s actions. Solving a Sudoku puzzle.
Dynamic Environment changes over time (e.g., traffic, weather). Traffic routing in Kathmandu.
Discrete Finite, countable states (e.g., chess pieces). Chessboard positions.
Continuous Infinite states (e.g., robot arm angles). Drone navigation in 3D space.
Single-Agent Only one agent acts in the environment. Solving a maze alone.
Multi-Agent Multiple agents interact (competitive or cooperative). Football (soccer) match.

Rationality in Agents

An agent is rational if it acts to maximize expected utility given its percept sequence and knowledge.

Key Principles:

  1. Performance Measure: Defines success (e.g., minimize delivery time).
  2. Environment: Constrains possible actions.
  3. Agent’s Knowledge: Limits what it can perceive.
  4. Rationality: Act to maximize expected performance.

Example: A Pathao driver agent is rational if it:

  • Maximizes tips (utility).
  • Avoids traffic jams (environment constraints).
  • Uses GPS (perception).

In the Real World

  1. eSewa (Nepal):

    • Agent Type: Utility-based agent.
    • How it works: Maximizes user satisfaction by balancing transaction speed, security, and fee structure.
    • Example: If a user’s utility function prioritizes speed, eSewa routes payments through the fastest available network.
  2. Pathao (Ride-Hailing):

    • Agent Type: Goal-based + Multi-agent system.
    • How it works:
      • Driver Agent: Goals = reach passenger quickly, avoid traffic.
      • Passenger Agent: Goal = shortest route, lowest fare.
    • Example: Pathao’s algorithm uses real-time traffic data (dynamic environment) to assign drivers, ensuring both agents (driver and passenger) maximize utility.
  3. NTC (Nepal Telecom) Network Routing:

    • Agent Type: Model-based reflex agent.
    • How it works: Maintains a network state model to route calls efficiently.
    • Example: If a tower fails, NTC’s agent reroutes calls via alternative paths (like a model-based reflex agent updating its internal state).

Worked Example: Traffic Light Control Agent

Scenario: A traffic light at a busy intersection in Kathmandu must minimize wait time.

starttimertimertimerRedGreenYellow
Finite-state machine for a traffic light agent (simplified).

Agent Design:

  1. Percepts: Sensor data (vehicle count on each road).
  2. Environment: Dynamic (traffic changes over time).
  3. Agent Type: Utility-based (maximize throughput).
  4. Utility Function: .
Percept 10Percept 21Percept 32Action3
Agent’s internal state: Current percept (index 3) triggers action via the agent program.

Trace:

Time Percepts Action Utility Calculation
0s Cars: N=5 (North), E=2 Green: North
30s Cars: N=0, E=8 Switch to East (wait time accumulates)
60s Cars: N=3, E=0 Switch back to North

Optimization: The agent learns to adjust timings based on real-time data (like a reinforcement learning agent).


Exam Tip

  1. Define Clearly: Always define agent, percept, and environment in your answers.
  2. Compare Types: Questions often ask to contrast reflex vs. model-based agents. Use the table above.
  3. Real-World Links: Relate agents to eSewa (utility), Pathao (multi-agent), or NTC (model-based).
  4. Worked Examples: Show step-by-step traces (like the traffic light example).
  5. Rationality: Explain how an agent’s performance measure defines rationality.
  6. Diagrams: Draw agent-environment interaction diagrams or state transition graphs where needed.

Visual Summary:

mindmap
  root((Intelligent Agents))
    Types
      Reflex
      Model-Based
      Goal-Based
      Utility-Based
    Environment
      Observable
      Deterministic
      Episodic
      Static/Dynamic
    Rationality
      Performance Measure
      Expected Utility
    Real-World
      eSewa
      Pathao
      NTC

Based on the PU BE Computer (PU) syllabus for Artificial Intelligence (CMP346), unit 2.

Discussion

Loading…