Unit 2
Unit 2
APPLICATION
SEMESTER 2
DCA6301
ARTIFICIAL INTELLIGENCE
Unit: 2 - Introduction to Intelligent Agents and Problem-Solving 1
DCA6301: Artificial Intelligence
Unit - 2
Introduction to Intelligent Agents and
Problem-Solving
DCA324
KNOWLEDGE MANAGEMENT
Unit: 2 - Introduction to Intelligent Agents and Problem-Solving 2
DCA6301: Artificial Intelligence
TABLE OF CONTENTS
1 Introduction - -
5-6
1.1 Learning Objectives - -
4 Agent Architecture - -
4.1 Perceptual System 2 -
4.2 Types of Sensors 3, 4, 5, 6 -
4.3 Internal Model - - 17-22
4.4 Decision-Making System - -
4.5 Action Execution System - -
4.6 Learning Element 7 -
6 Search Algorithms - -
6.1 Types of Search Algorithms - -
6.2 Uninformed Search Strategies - -
6.2.1 Depth-First Search (DFS) - -
6.2.2 Breadth-First Search (BFS) - -
6.2.3 Depth-Limited Search (DLS) - -
6.2.4 Iterative Deepening Search (IDS) - -
6.3 Informed Search Strategies (Heuristic 48-49
- -
Search)
6.3.1 Greedy Search 8, 9 -
6.3.2 Minimax Algorithm - -
6.3.3 A* Search: Balancing Efficiency and 10 -
Optimality
6.3.4 AO* Algorithm - -
6.3.5 Case Study-AO* - -
6.3.6 Alpha-Beta Pruning - -
8 Summary - - 50
9 Glossary - - 51-53
10 Self-Assessment Questions - 1 54
11 Terminal Questions - - 55
12 Answers - -
12.1 Self-Assessment Questions - - 56-57
12.2 Terminal Questions - -
13 References - - 52
1. INTRODUCTION
The world of artificial intelligence (AI) revolves around creating intelligent agents. These are systems
that can reason, learn, and act autonomously in their environment. Imagine a robot vacuum cleaner
navigating your house, a spam filter sorting your emails, or a chess-playing program making strategic
moves. These are all examples of intelligent agents in action.
This journey into intelligent agents starts by understanding their different types. We'll explore how
some agents react directly to stimuli (simple reflex agents), while others have a mental map of their
surroundings (model-based reflex agents). We'll also delve into agents with specific goals (goal-based
agents) and those that make decisions based on value (utility-based agents). And of course, we can't
forget about learning agents, which can improve their performance over time.
But how do these agents function? We'll peek inside their architecture, examining the components
that enable them to perceive, reason, and act. This includes the perceptual system that gathers
information, the internal model that represents the environment, and the decision-making system
that chooses the best course of action. We'll also explore how actions are carried out and how some
agents can even learn and adapt.
Next, we'll shift gears to problem-solving agents, a specific type designed to tackle challenges. We'll
break down the essential elements of these agents, including the initial state, available actions, the
consequences of those actions, and how to determine if a goal has been achieved.
Finally, we'll enter the fascinating world of search algorithms. These are the methods problem-solving
agents use to find a sequence of actions leading to a goal. We'll explore uninformed search strategies
that systematically explore all possibilities and informed search strategies that use knowledge
(heuristics) to guide the search more efficiently. We'll also learn how to choose the most suitable
search algorithm for a given problem, considering factors like space and time complexity as well as
the specific characteristics of the problem itself.
So, buckle up and get ready to dive deep into the world of intelligent agents and problem-solving!
• Sensors: These are the agent's eyes and ears, gathering information about the environment (e.g.,
dirt detected by the vacuum).
• Condition-Action Rules: These are the pre-programmed "if-then" instructions (e.g., if dirt
detected, then move towards it).
• Actuators: These are the agent's hands and feet, allowing it to take action in the world (e.g.,
vacuum cleaner wheels move forward).
Examples in Action:
• Thermostat: Senses the room temperature (sensor) and turns on the heater if it's cold
(condition-action rule) to maintain a set temperature (action).
• Traffic Light: Detects the presence of cars (sensor) and changes light colors (action) based on
pre-defined rules (condition-action rule).
• Automatic Door: Senses someone approaching (sensor) and triggers the door to open (action)
based on proximity (condition-action rule).
Simple reflex agents are the starting point for many intelligent systems. While they might not be the
most sophisticated AI, they provide a foundation for understanding how agents perceive, react, and
interact with the world. As we move towards more complex environments, we'll need to explore
agents with learning capabilities and internal models, but for now, these basic robots are doing a
pretty good job keeping our rooms clean and our traffic lights flowing!
• Internal Model: They maintain a mental map or model of the environment, keeping track of
past observations and the world's state. This allows them to consider not just the current input,
but also the potential consequences of actions.
• Partially Observable Environments: They can function even if they can't sense everything. By
using the internal model, they can make educated guesses about the unseen parts of the
environment.
How it Works:
Here's a breakdown of the model-based reflex agent's decision process:
1. Perceive: The agent gathers information about the environment through sensors (e.g., seeing
the chessboard).
2. Update Internal Model: Based on the new information, the agent updates its internal
representation of the environment (e.g., understanding the opponent's strategy).
3. Simulate Actions: Using the internal model, the agent simulates different actions and their
potential outcomes (e.g., predicting the opponent's response to different chess moves).
4. Select Best Action: The agent chooses the action that leads to the most desirable outcome based
on its goals (e.g., selecting the chess move that gives you the best advantage).
5. Take Action: The agent executes the chosen action in the real world (e.g., making the chess
move).
Examples in Action:
Model-based reflex agents are used in various scenarios:
• Self-Driving Cars: These cars perceive their surroundings (sensors), maintain a map of the
environment (internal model), predict traffic flow (simulate actions), and choose the safest path
(select best action).
• Robot Arm in a Factory: The robot arm senses object positions (sensors), keeps track of its
own movements (internal model), simulates different pick-and-place actions, and chooses the
most efficient movement (select best action) to avoid collisions.
Model-based reflex agents are a step up from simple reflex agents, providing a more sophisticated
way to interact with the world. By considering past experiences and potential consequences, they can
make informed decisions in dynamic environments. As AI continues to evolve, these agents will play
a crucial role in tasks requiring strategic thinking and adaptation in complex situations.
5. Plan Generator: This component analyzes the current state, the goal, and the internal model (if
present) to generate a sequence of actions (e.g., a cleaning plan for the robot).
6. Action Selection: This component chooses the most suitable action from the generated plan to
take the next step towards the goal.
Examples in Action:
Goal-based reflex agents find applications in various domains:
• Game Playing AI: An AI playing chess has the goal of checkmating the opponent. It perceives
the board (perceptors), considers possible moves (plan generation), and selects the best move
based on its goal (action selection).
• Search and Rescue Robots: These robots have the goal of finding survivors. They use sensors
to navigate the environment (perceptors), keep track of explored areas (internal model), and
plan search paths to maximize the chance of finding survivors (plan generation and action
selection).
Goal-based reflex agents represent a significant advancement in agent design. By incorporating goals
and planning, they can tackle more complex tasks and navigate dynamic environments. As AI
technology progresses, these agents will play a vital role in achieving specific objectives in various
applications, from game playing to real-world robotics.
Decision-Making Process:
1. Perceive: The agent gathers information about the environment.
2. Generate Options: Based on the perceived state, it identifies possible actions.
3. Predict Outcomes: Using the internal model (if present) or simulations, the agent predicts the
potential outcomes of each action.
4. Evaluate Utility: The utility function assigns a numerical value to each predicted outcome.
5. Select Best Action: The agent chooses the action that leads to the outcome with the highest
utility.
6. Take Action: The chosen action is executed in the real world.
Examples in Action:
Utility-based agents are used in various applications:
• Personal Assistant Robots: These robots consider various factors like weather, traffic, and user
preferences (perceive) to suggest personalized schedules or routes (predict outcomes, evaluate
utility, select best action).
• Self-Driving Cars: They navigate by considering factors like safety, efficiency, and traffic laws
(perceive), predict possible routes based on traffic data (predict outcomes), and choose the route
with the highest utility (evaluate utility, select best action).
Utility-based agents introduce a sophisticated approach to making decisions in the real world. By
considering the "goodness" of potential outcomes, they can navigate complex environments and
achieve a balance between various objectives. As AI continues to evolve, these agents hold promise
for applications requiring flexible decision-making and optimal action selection in dynamic scenarios.
If a robot is playing a game against you, at first, it might make random moves. But with each game, it
starts to learn your strategies and adapt its own. This is the world of learning agents, where the
ability to improve performance over time sets them apart.
Examples in Action:
Learning agents are making waves in various fields:
• Recommendation Systems: These systems analyze past user behavior to recommend movies,
music, or products (supervised learning).
• Spam Filtering: Email filters use supervised learning to identify and block spam emails based
on past examples.
• Game Playing AI: AI players in games like Chess or Go learn through reinforcement learning,
continuously improving their strategies based on past encounters.
Learning agents represent the cutting edge of artificial intelligence. Their ability to learn from
experience opens up possibilities for intelligent systems that can continuously improve and adapt to
the real world. As research in learning algorithms progresses, these agents will play a vital role in
solving complex problems and automating tasks across various domains.
4. AGENT ARCHITECTURE
Intelligent agents are not magical boxes. They achieve their feats through a well-defined architecture
consisting of several key components working together. Let's explore these components and
understand their roles:
The perceptual system is the sensory gateway for an intelligent agent. It's responsible for gathering
information about the surrounding environment, allowing the agent to perceive the world around it
through various sensors like cameras, microphones, LiDAR (Light Detection and Ranging), or
temperature sensors. For example, a self-driving car uses a multitude of sensors, including cameras
to perceive traffic lights and pedestrians, LiDAR to create a 3D map of the surroundings, and radar to
detect distant objects.
The specific type of sensor depends on the agent's purpose and the environment it operates in.
This information serves as the foundation for all the agent's subsequent actions and decision-making
processes.
1. Sensors: Capture raw data from the environment (visual, auditory, tactile, etc.).
2. Signal Processing: Prepares the raw data for further analysis.
3. Feature Extraction: Identifies key characteristics of the data.
4. Pattern Recognition: Matches data to existing patterns or models.
5. Perceptual Output(Actuators): Processed information sent to the agent's decision-making
system.
By effectively utilizing the perceptual system, intelligent agents can gain a vital understanding of their
surroundings, enabling them to react, plan, and make informed decisions in the real world.
• Auditory Sensors (Microphones): Capture sound and audio information. Used in speech
recognition systems, virtual assistants, and robots that interact with humans.
• Range Sensors (LiDAR, Radar): Measure distance and create 3D maps of the
environment. Used in self-driving cars, autonomous drones, and robots navigating complex
spaces.
Figure 2.5: Selfdriving car with a LiDAR sensor mounted on its roof
Information Processing:
The raw data captured by the sensors needs to be processed and interpreted before it becomes
meaningful information for the agent. This processing might involve tasks like:
• Signal Processing: Removing noise and enhancing relevant signals.
• Feature Extraction: Identifying key characteristics of the data (e.g., edges in an image, voice
pitch in audio).
• Pattern Recognition: Matching sensory data to pre-existing patterns or models stored in the
agent's memory.
The internal model plays a crucial role in decision-making. It allows the agent to consider the potential
consequences of actions before taking them and plan effectively to achieve its goals.
The decision-making system can be rule-based, relying on pre-programmed if-then statements. More
sophisticated agents might employ machine learning techniques to make data-driven decisions or
even utilize probabilistic reasoning to handle uncertainty in the environment.
The action execution system needs to ensure smooth and accurate execution of the chosen action.
Factors like motor control, signal processing, and safety considerations come into play here.
The learning element can modify the agent's internal model, refine its decision-making strategies, or
even adjust its perception based on new data encountered in the environment.
For example:
• In a maze navigation problem, the initial state could be the agent's location (coordinates) within
the maze.
• In a game of chess, the initial state would be the starting position of all the pieces on the board.
• In a route-finding problem, the initial state could be the agent's current location and the
destination it needs to reach.
5.2. Actions
These are the set of possible operations or maneuvers that the agent can perform to alter its state in
the problem space. The available actions depend on the specific problem and the capabilities of the
agent.
be represented mathematically as a function that takes the current state and an action as input and
returns the resulting new state.
For instance:
• In a maze navigation problem, the path cost could be the number of moves it takes to reach a
specific location.
• In a game of chess, the path cost might be an evaluation of the material lost (pieces captured)
during the game.
• In a route-finding problem, the path cost could be the total distance traveled or the travel time
based on the mode of transportation.
By effectively utilizing these core components, problem-solving agents can systematically navigate
through the problem space, evaluate potential solutions, and ultimately find a sequence of actions
leading to a successful goal state.
6. SEARCH ALGORITHMS
Search algorithms are the workhorses of problem-solving agents. They systematically explore the
problem space, a collection of all possible states an agent can be in, to find a sequence of actions
leading to a goal state. If you're lost in a maze, how do you find the exit? This is where search
algorithms come in! They are a fundamental concept in computer science, used to systematically
explore a set of possibilities and find the best solution to a problem.
o Example: Breadth-First Search explores all options at the same level (like checking every
hallway in a floor before moving to the next).
2. Informed Search: These algorithms leverage additional information, often a heuristic function,
to guide their search towards the goal more efficiently. The heuristic estimates how "close" a
particular state is to the goal, allowing the algorithm to prioritize promising paths.
o Example: A* Search uses a heuristic like the Manhattan distance to estimate the remaining
distance to the exit in the maze.
• Game Playing: AI players in games like chess or checkers use search algorithms to evaluate
possible moves and choose the best one.
• Problem Solving: Search algorithms are used in various problem-solving domains, from
scheduling tasks to optimizing resource allocation.
Search algorithms are powerful tools for navigating complex problem spaces. By exploring different
possibilities and evaluating their costs, they help us find the best solutions to a wide range of
challenges. As computer science continues to evolve, search algorithms will continue to play a vital
role in developing intelligent systems that can tackle increasingly complex tasks.
• Data Structure: DFS typically uses a Last-In-First-Out (LIFO) data structure like a stack to keep
track of the paths being explored. New states are pushed onto the stack, and backtracking
involves popping states off the stack to revisit previous branching points.
• However, this path reaches a dead end. Since there are no further options down this branch, DFS
backtracks.
• It pops the most recent state (D) off the stack and explores the right path (R) from the previous
state.
• This process continues, with DFS pushing states onto the stack as it explores down paths and
popping them off when it needs to backtrack.
• Eventually, DFS explores the path sequence "Start" -> "R" -> "U" -> "R" -> "Goal," successfully
reaching the goal state.
Advantages of DFS:
• Simple to implement: The LIFO stack structure makes DFS easy to understand and code.
• Space efficient: DFS only needs to store the current path being explored, leading to lower space
complexity compared to BFS (explained later).
Disadvantages of DFS:
• Can get stuck in deep dead ends: DFS might prioritize long, winding paths and get stuck
exploring a deep dead end before finding a shorter solution.
• Not optimal for all problems: DFS doesn't guarantee finding the shortest path to the
goal, especially in problems with branching paths.
• Next, BFS removes the first state from the queue (which is still "Start") and explores its
unvisited neighbors again (Right, Down this time, as Up was already explored). This process
continues, systematically adding all neighboring states of the current state to the back of the
queue.
• As BFS expands outward, it eventually encounters the "Goal" state, which is a neighbor of a
previously explored state. Since the goal is found, the search terminates.
Advantages of BFS:
• Guaranteed to find a shortest path: If a solution exists, BFS is guaranteed to find a path with
the minimum number
While Depth-First Search (DFS) and Breadth-First Search (BFS) provide fundamental uninformed
search approaches, they have limitations. DFS can get stuck in deep dead ends, and BFS can be
inefficient for problems with vast shallow spaces. Here, we explore two advanced uninformed search
strategies that address these shortcomings: Depth-Limited Search and Iterative Deepening Search.
Core Idea:
• DLS functions similarly to DFS, using a stack to keep track of the explored path.
• However, DLS introduces a depth limit (L) that restricts how far down a path the search can go.
• When a state at depth L is encountered, DLS backtracks even if there are unexplored branches
at that state.
• The search continues exploring alternative paths, adhering to the depth limit, until a goal state
is found or all possibilities are exhausted.
• Since the depth limit is 2, DLS can explore one more level. It goes down again (D), pushing that
state as well (depth 2).
• However, there are no further options at this point. Since the depth limit is reached, DLS
backtracks, even though there's an unexplored path to the right.
• It pops the state at depth 2 off the stack and tries the right path (R) from the previous state
(depth 1).
• DLS can now explore the path "Start" -> "R" -> "U" -> "R," successfully reaching the goal state
within the depth limit.
Advantages of DLS:
• Avoids getting stuck in deep dead ends: The depth limit prevents DLS from endlessly
exploring irrelevant deep paths.
• More focused exploration than DFS: DLS prioritizes exploring paths closer to the surface,
potentially finding solutions faster than unrestricted DFS.
Disadvantages of DLS:
• May require multiple executions: Finding the optimal depth limit can be tricky. A low limit
might miss the goal, while a high limit might behave similarly to DFS. Sometimes, running DLS
with progressively increasing depth limits might be necessary.
• Not guaranteed to find the shortest path: Like DFS, DLS doesn't guarantee finding the most
efficient solution, especially if the goal is located deeper than the chosen depth limit.
Core Idea:
• IDS performs multiple DFS searches iteratively, with each iteration increasing the depth limit by
one.
• In the first iteration, it acts like DLS with a depth limit of 1, exploring all states at depth 1.
• If the goal isn't found, the second iteration increases the limit to 2, essentially running a DLS with
a limit of 2.
• This process continues, systematically increasing the depth limit in each iteration until the goal
is found or all possibilities are exhausted at the current depth.
Advantages:
• Efficiency for Shallow Solutions: IDS inherits the benefits of BFS for exploring shallow levels
of the search space. By iteratively increasing the depth limit, it prioritizes finding solutions
closer to the initial state, potentially leading to faster results in problems where the goal is likely
to be found at a shallow depth.
• Guaranteed to Find a Solution (if it exists): Similar to DFS, IDS guarantees finding a solution
to the problem if one exists within the defined search space. By systematically increasing the
depth limit in each iteration, it ensures that all possible paths are eventually explored, leading
to the goal state if it's reachable.
• Space Efficient: Unlike BFS, which can require storing a vast number of states in the queue for
deeper problems, IDS maintains a space complexity similar to DFS. It only needs to keep track
of the current path being explored in each iteration, making it memory-efficient for problems
with large branching factors.
Disadvantages:
• Redundant Exploration: In some cases, IDS might perform redundant state explorations.
During each iteration with an increased depth limit, it might revisit states that were already
explored in previous iterations. While this doesn't affect the correctness of the solution, it can
lead to a slight increase in overall search time compared to an optimal uninformed search
strategy.
• Potential for Multiple Iterations: Depending on the depth of the goal state, IDS might require
multiple iterations to find the solution. This can be slower than scenarios where BFS or a well-
informed search strategy can find the solution in a single pass.
• Tuning Depth Limit: While IDS guarantees finding a solution eventually, the initial choice of
depth limit can impact efficiency. If the limit is set too low, it might require many iterations.
Conversely, a very high limit might lead to unnecessary exploration similar to DFS.
IDS offers a valuable alternative to uninformed search algorithms like DFS and BFS. It provides a
balance between efficiency and completeness, making it suitable for various problem-solving
scenarios. While it might involve some redundant exploration and requires tuning the depth limit,
IDS is a powerful tool for navigating complex search spaces where finding a solution within a
reasonable timeframe is crucial.
Core Idea:
• Greedy search maintains a list of explored states and a set of frontier states (unexplored
neighbors of the current state).
• It iteratively selects the state from the frontier with the most promising heuristic value
(h(n)), indicating its perceived closeness to the goal.
• The chosen state is added to the explored list, and its unexplored neighbors are added to the
frontier.
• This process continues until the goal state is reached or a dead end is encountered (no neighbors
with a promising heuristic value).
• Greedy search starts at "Start" and calculates the h(n) for its neighbors (Up, Right, Down).
• Since "Right" has the lowest h(n) (closest estimated distance to the goal), it's chosen as the next
state.
• The process repeats, with Greedy search always moving towards the neighbor with the most
promising h(n) value.
• In this example, Greedy search successfully reaches the goal state by following the path "Start" -
> "Right" -> "Up" -> "Right."
considers the most promising neighbor, it might not explore alternative paths that could lead to
the actual goal.
• Greedy search would follow the same initial path ("Start" -> "Right" -> "Up" -> "Right").
• However, at this point, it would mistakenly choose "Down" as the next state because it has the
lowest h(n) among its neighbors.
• This leads to a dead end, and Greedy search wouldn't be able to find the actual goal state located
to the left.
possible moves for each player (usually alternating between maximizing and minimizing players).
Terminal nodes represent the end states of the game (win, lose, or draw).
Minimax in Action:
The minimax algorithm works recursively, evaluating each branch of the tree from the perspective of
the player whose turn it is at that level:
1. Maximizing Player's Turn: The algorithm examines all possible moves (child nodes) available
from the current node.
2. Recursive Evaluation: For each move (child node), it minimax is called recursively, simulating
the opponent's (minimizing player) best response. This involves evaluating the scores of all
terminal states reachable from that child node.
3. Score Propagation: The minimax algorithm propagates the score back up the tree. For the
maximizing player, it chooses the child node with the highest score, essentially maximizing its
potential outcome.
• X1, X2, X3: Represent possible opening moves for X (maximizing player).
• O1, O2, ..., O6: Represent possible responses from O (minimizing player) for each of X's moves.
• "...": Indicate terminal states (win, lose, or draw) reached after a sequence of moves.
Walkthrough:
1. Start at the root node. This is X's turn (maximizing player).
2. Explore X1: Simulate O's (minimizing player) best response for each child node (O1, O2).
Evaluate the score of each terminal state reachable from those nodes (win/loss for X).
3. Choose the best move for X from X1: This would be the move leading to the highest score (most
wins for X) considering O's potential responses.
4. Repeat for X2 and X3: Evaluate each move (X2 and X3) with minimax, considering O's best
replies. Choose the move for X that leads to the best outcome based on the propagated scores.
The minimax algorithm, by recursively evaluating all possible game states, identifies the move for the
maximizing player (X) that leads to the best outcome (most wins) considering all potential responses
from the minimizing player (O).
Limitations:
• Exponential Complexity: The number of possible game states grows exponentially with game
depth. Minimax can become computationally expensive for complex games with many moves.
• Static Evaluation: It relies on a static evaluation function to score terminal states. This function
might not perfectly capture the dynamic nature of a game.
Future Enhancements:
• Alpha-Beta Pruning: This optimization technique significantly reduces the number of states
explored by minimax, making it more efficient for complex games.
• Heuristic Evaluation: Using a more sophisticated heuristic function to estimate scores can
improve decision-making, especially for games with imperfect information.
By systematically exploring the game tree and considering all possible moves and responses, the
minimax algorithm provides a powerful approach for finding optimal moves in two-player zero-sum
games.
Core Idea:
A* Search operates by maintaining two crucial functions:
• h(n): The heuristic function, inherited from Greedy Search. It estimates the cost
(distance, time, etc.) of reaching the goal state from a particular state (n) in the problem space.
• f(n): The cost function, which combines the actual cost (g(n)) of reaching state (n) from the start
state and the heuristic estimate (h(n)). It represents the total estimated cost to reach the goal
from state (n). f(n) = g(n) + h(n).
A* Search employs a priority queue (frontier) to manage the exploration process. Unlike Greedy
Search, which solely prioritizes the heuristic value, A* Search prioritizes states based on their f(n)
values. States with lower f(n) are considered more promising as they suggest a potentially lower
overall cost to reach the goal.
1. Initialization: Start with the initial state and calculate its f(n) value. Add it to the empty frontier.
2. Loop: While the frontier is not empty and the goal state hasn't been reached:
o Remove the state with the lowest f(n) value from the frontier (considered the most
promising state).
o If the removed state is the goal state, terminate the search - a solution (optimal path) has
been found.
o Expand the current state by generating its successor states (possible next moves).
o For each successor state:
▪ Calculate its g(n) value (actual cost to reach it from the start state).
▪ Calculate its h(n) value (estimated cost to reach the goal from it).
▪ Calculate its f(n) value (g(n) + h(n)).
▪ If the successor state is not already in the explored list or the frontier, add it to the
frontier with its calculated f(n) value.
▪ If the successor state is already in the frontier, but the newly calculated f(n) is lower
than the existing one, update the state's f(n) value in the frontier (this ensures the
search prioritizes the most promising path).
o Add the expanded state (the one removed from the frontier in step 2.1) to the explored list.
Consider the maze below. Let h(n) represent the estimated straight-line distance to the goal from any
state (n).
Solution:
1. Start: We begin at "Start" and calculate its f(n). Since g(n) for the start state is 0 (no cost to reach
itself), f(n) will solely depend on h(n) (estimated distance to the goal).
2. Iteration 1: The frontier initially contains only "Start" with its f(n) value. We expand "Start,"
generating its neighbors ("Up," "Right," and "Down"). We calculate the g(n) for each neighbor
(cost of moving one step) and add h(n) to get their f(n) values. Since "Right" has the lowest
f(n), it becomes the next state to explore.
3. Iteration 2: We expand "Right," generating its neighbors ("Up," "Right," and "Down"). We
calculate their g(n) and f(n) values. This time, "Up" has the lowest f(n), so it's chosen for
exploration.
4. Iteration 3: Expanding "Up" leads to "Goal" as a successor state. Since "Goal" is the target, the
search terminates.
By following this process, A* Search efficiently navigates the maze, considering both the actual cost
of moves (g(n)) and the estimated cost to the goal (h(n)) to find the shortest path: "Start" -> "Right" -
> "Up" -> “Goal."
Maze Layout:
Imagine a maze like the one below, where "S" represents the starting point and "G" represents the
goal.
+---+---+---+
|S| | |
+---+---+---+
| | | |
+---+---+---+
| | |G|
+---+---+---+
A Search Process:
1. Initialization:
o We start at the "S" state.
o Since there's no cost to reach the starting state itself, its actual cost (g(n)) is 0.
o We calculate the heuristic value (h(n)) for the starting state, which is the straight-line
distance to the goal (typically calculated using a distance formula).
o The starting state's f(n) value is calculated as g(n) + h(n). f(n) represents the total
estimated cost to reach the goal from the current state.
o We create an empty explored list to keep track of visited states and a priority queue
(frontier) to manage unexplored states.
o The starting state with its f(n) value is added to the frontier.
o If the removed state is the goal state (G), the search terminates successfully - we've found
the optimal path!
o If not, we expand the current state by generating its successor states (all possible moves
from that state - Up, Down, Left, Right in this maze example).
▪ We add the successor state with its f(n) value to the frontier. This allows the priority
queue to prioritize states with lower estimated total costs.
o We also add the expanded state (the one removed from the frontier in step 2) to the
explored list to prevent revisiting the same state.
Following these steps, A Search will efficiently explore the maze, prioritizing paths that appear closer to
the goal based on the heuristic estimate. In this example, the optimal path (shortest route) from "S" to
"G" will be discovered.*
In real-world scenarios, the heuristic function might be more complex, and the calculations might
involve additional factors depending on the problem domain.
Advantages:
• Optimality: A* Search is guaranteed to find the optimal solution (shortest path) if a consistent
heuristic is used. A consistent heuristic never overestimates the actual cost to reach the goal
(h(n) <= actual cost to goal). This ensures that A* Search explores only the most promising paths
and eventually reaches the goal with the minimum cost.
• Efficiency: Compared to uninformed search algorithms like BFS, A* Search prioritizes states
with lower f(n) values. This f(n) function combines the actual cost traveled (g(n)) and the
estimated cost to the goal (h(n)). By focusing on states with a potentially lower overall cost, A*
Search avoids exploring irrelevant parts of the problem space, leading to faster solution times in
many scenarios.
• Heuristic Flexibility: A* Search doesn't require a perfect heuristic. Even with an imperfect but
reasonable estimate, A* Search can often find near-optimal solutions much faster than
uninformed search methods. This flexibility allows for adapting the heuristic function to specific
problem domains, potentially improving efficiency.
Disadvantages:
• Reliance on Heuristic Quality: The effectiveness of A* Search hinges on the quality of the
chosen heuristic function. A poor heuristic that significantly overestimates the cost to the goal
(h(n) >> actual cost) can lead A* Search down misleading paths, hindering its efficiency and
potentially preventing it from finding the optimal solution.
• Computational Overhead: Compared to simpler uninformed search algorithms, A* Search
involves maintaining a priority queue (frontier) and calculating f(n) values for states. This can
introduce some additional computational overhead, especially for problems with large
branching factors or complex heuristic functions.
• Incompleteness in Special Cases: While generally optimal with consistent heuristics, A* Search
can exhibit incomplete behavior in specific scenarios. For instance, if multiple paths to the goal
have the same actual cost but the heuristic consistently overestimates the cost for one path, A*
Search might prioritize exploring the other paths first, potentially missing the optimal solution
in rare cases.
A* Search offers a powerful approach for navigating problem spaces, particularly when an accurate
or reasonable heuristic function is available. Its ability to find optimal solutions while maintaining
efficiency makes it a popular choice for various AI applications. However, the quality of the heuristic
and the potential for computational overhead are important considerations when choosing A* Search
for a specific problem domain.
How it Works:
1. Modeling the Problem: The environment or scenario is represented as an AND-OR graph.
Nodes represent locations or states, and edges connect them. Edges are labeled as "OR"
(different options to reach the next node) or "AND" (all options need to be explored before
moving on).
2. Cost and Heuristic Functions: Similar to A*, AO* uses a cost function (g) to represent the effort
of traversing an edge and a heuristic function (h) to estimate the remaining effort to reach the
goal.
3. Open and Closed Lists: The algorithm maintains two lists: "OPEN" for unexplored nodes and
"CLOSED" for explored ones. Unlike A*, AO* can revisit nodes in the CLOSED list if new
information arises during the search.
4. Iterative Exploration: It starts at the starting node and explores the most promising node in
the OPEN list based on a combination of cost (g) and estimated effort (h).
2. Finding the Solution: The search continues until the goal is reached (safe zone in a rescue
mission) in an explored path. The reconstructed paths from various starting points represent
the optimal solution, considering all options and adapting to discovered dead ends.
Advantages of AO:*
• AND-OR Graph Efficiency: It effectively explores complex search spaces with multiple options
and dependencies between sub-goals.
• Adaptability to Change: AO* can dynamically adjust its search based on new information
discovered during the process.
Considerations:
• Computation Cost: Exploring multiple paths simultaneously can be computationally expensive
compared to A*.
• Heuristic Importance: A good heuristic function is crucial for guiding the search towards
promising areas and avoiding unnecessary exploration of dead ends.
By efficiently navigating the exploration of various possibilities, AO* solves problems where the
optimal solution requires considering diverse options and adapting to changing information.
Scenario: A fire engulfs a high-rise office building. Firefighters need to find the fastest way to
evacuate all occupants safely. The building has multiple staircases, exits, and some floors might be
inaccessible due to the fire.
AO to the Rescue:* Here's how AO* can be used for efficient evacuation:
1. Modeling the Building: The building layout is transformed into an AND-OR graph. Nodes
represent rooms, hallways, and exits. Edges connect them, with some marked as "OR" (different
escape routes from a floor) and others as "AND" (all occupants must use that passage, like a
single staircase). Blocked hallways due to fire are dead-end nodes.
2. Cost Function (g): Similar to A*, AO* uses a cost function (g) to represent the time or effort
required to traverse an edge. This could include factors like distance, number of people to
evacuate, and potential hazards like smoke density.
3. Heuristic Function (h): The heuristic (h) estimates the remaining effort needed to reach safe
exits from any point. This might consider proximity to known exits, smoke levels, or accessibility
for people with mobility limitations.
4. Open and Closed Lists: AO* maintains two lists: "OPEN" for unexplored nodes and "CLOSED"
for explored ones. However, unlike A*, AO* can revisit nodes in the CLOSED list if new
information arises, like discovering a blocked passage.
5. Search Process: The algorithm starts at the location where the fire alarm originated and adds it
to the open list. It then iteratively explores the most promising node (lowest f(n) - same as A*)
based on cost (g) and estimated effort (h).
6. AND vs. OR Nodes:
o OR Nodes: When encountering an OR node (e.g., hallway with two exits), the algorithm
explores all outgoing edges (paths) simultaneously, adding them to the open list. This allows
for parallel exploration of different escape routes.
o AND Nodes: For AND nodes (e.g., single staircase), all child nodes (people on that floor) need
to be explored and confirmed evacuated (or dead-end if the path is blocked) before moving
on. If any child node leads to a dead-end (blocked passage), the parent AND node is marked
as unreachable.
7. Solution Found: The search continues until all occupants are found to be on a path leading to a
safe exit (marked as a goal node) in an explored path. The reconstructed paths from different
points within the building represent the most efficient evacuation plan, considering all available
escape routes and potential obstacles.
This evacuation scenario highlights AO*'s ability to manage complex decision-making in emergencies
with multiple options and uncertainties. It's a valuable tool for applications like:
• Urban Search and Rescue: Optimizing search patterns for finding missing people in disaster
zones with collapsed buildings or blocked roads.
• Cybersecurity: Simulating attack scenarios and identifying the most effective ways to contain a
security breach within a computer network.
• Logistics and Delivery: Planning efficient delivery routes with multiple stops, considering
traffic conditions and potential delays.
By effectively navigating the exploration of various possibilities, AO* tackles problems where the
optimal solution requires considering diverse options and adapting to changing information.
• Beta: Represents the lowest guaranteed score the minimizing player can achieve from a branch.
Initially set to positive infinity (+∞).
o If the score is greater than alpha, alpha is updated to the new value. This signifies a better
score for the maximizing player.
2. Minimizing Player's Turn: The algorithm evaluates a node and gets a score. This score is
compared to beta.
o If the score is less than beta, beta is updated to the new value. This signifies a worse score
for the minimizing player (which is good for the maximizing player).
• For Minimizing Player: Similarly, if a node is encountered with a score greater than or equal to
the current beta value, it implies this branch cannot possibly yield a worse score for the
minimizing player than already found options. We can prune the entire branch below this node.
The maximizing player wouldn't choose a move leading to a score better than alpha for the
opponent.
Result:
By pruning unnecessary branches, the algorithm focuses on the most promising areas of the tree,
significantly reducing the number of nodes evaluated. This allows for faster decision-making,
especially in complex games with many possible moves.
Key Points:
• Alpha-beta pruning significantly improves the efficiency of minimax without affecting the final
outcome (optimal move).
• The effectiveness of pruning depends on the ordering of moves explored and the quality of the
heuristic evaluation function used to estimate scores.
Selecting a Search Algorithm: Choosing the Right Tool for the Job
In the realm of artificial intelligence, selecting the appropriate search algorithm is crucial for
efficiently solving problems. Different algorithms excel in handling various problem characteristics.
Here, we'll delve into two key factors influencing search algorithm selection: Space vs. Time
Complexity and Problem Characteristics.
Understanding the complexity of a search algorithm is essential. Complexity refers to the amount of
resources (memory and time) an algorithm requires as the problem size (number of states) increases.
Here's a breakdown of the two key complexities to consider:
• Time Complexity: This measures the execution time of an algorithm in relation to the problem
size. Common notations include O(log n) (logarithmic time), O(n) (linear time), and O(n^2)
(quadratic time). Lower time complexity indicates faster execution for larger problems.
• Space Complexity: This measures the amount of memory an algorithm needs to store
information during its execution. It's also denoted using notations like O(1) (constant space) or
O(n) (linear space). Lower space complexity is preferred for problems with limited memory
resources.
Problem Characteristics
The effectiveness of a search algorithm depends on the specific characteristics of the problem it's
tackling. Here are some key factors to consider:
• State Space Size: Is the problem space vast (e.g., chess game) or relatively small (e.g., navigating
a maze with few paths)? Algorithms with lower space complexity might be crucial for problems
with limited memory.
• Branching Factor: How many possible next states can be reached from any given state? Higher
branching factors can lead to exponential growth in the search space. Algorithms that prioritize
promising paths (informed search) are beneficial in such scenarios.
• Guaranteed Solution: Does the problem guarantee a solution exists, or is it possible no solution
is available (e.g., finding a path in a maze with a dead end)? If a solution might not exist,
algorithms with completeness guarantees (like DFS) are preferred.
• Optimality: Is finding the absolute shortest path crucial, or is a "good enough" solution
acceptable? If optimality is essential, A* Search with a consistent heuristic is ideal.
Selecting the right search algorithm requires careful consideration of the problem characteristics and
the desired outcome. Analyzing the space and time complexities of different algorithms in relation to
the specific problem helps in making an informed decision. By understanding these factors, you can
equip your AI systems with the most efficient search strategies for tackling various problem domains.
8. SUMMARY
Intelligent agents are categorized into five types based on their complexity and functionality. Simple
reflex agents operate using predefined rules to respond to immediate percepts, making them suitable
for simple and fully observable environments. Model-based reflex agents, however, maintain an
internal state that accounts for unobservable aspects of the environment, enabling them to handle
more complex and dynamic scenarios. Goal-based agents take this further by acting to achieve specific
objectives, which requires evaluating potential actions against their goals. Utility-based agents
introduce the concept of utility, aiming to maximize their overall satisfaction by considering the trade-
offs between different outcomes. Finally, learning agents possess the ability to improve their
performance over time through experience, making them adaptable to new and evolving situations.
The architecture of an agent consists of several critical components. The perceptual system gathers
and processes information from the environment, forming the basis for decision-making. The internal
model maintains a representation of the world, allowing the agent to make informed decisions even
when not all information is directly observable. The decision-making system evaluates possible
actions based on percepts, internal states, goals, and utilities. The action execution system then
carries out these decisions using actuators. Additionally, the learning element enables the agent to
adapt and improve by updating its internal model and decision-making processes based on past
experiences.
Problem-solving agents are defined by specific components that facilitate their search for solutions.
These include the initial state, representing the starting point of the problem, and actions, which are
the possible steps the agent can take. The transition model describes how actions affect the state,
while the goal test determines whether the current state meets the desired objectives. Path cost
evaluates the efficiency of different action sequences. Search algorithms are employed to navigate
through possible states, with uninformed strategies like depth-first and breadth-first search
exploring without additional information, and informed strategies like greedy search and A* search
using heuristics to guide the search more effectively. Selecting an appropriate search algorithm
depends on the balance between space and time complexity and the specific characteristics of the
problem at hand.
9. GLOSSARY
Agents that operate by setting specific goals and choosing actions that
Goal-Based Agents - bring them closer to these goals, requiring planning and evaluation of
future states.
Decision-Making The system that evaluates percepts, internal models, goals, and utilities to
- choose the best course of action.
System
Action Execution
- The part of the agent that carries out the chosen actions using actuators.
System
The component that enables the agent to adapt and improve its
Learning Element - performance by learning from experiences and updating its internal
model and decision-making processes.
The possible steps that an agent can take to transition from one state to
Actions - another.
Transition Model - Describes how actions affect the state, defining the rules for state changes.
Uninformed Search methods that explore the state space without additional
- information about the goal's location, including
Search Strategies
Depth-First
- Explores as far as possible along each branch before backtracking.
Search
Breadth-First Explores all nodes at the present depth before moving on to nodes at the
- next depth level.
Search
Informed Search
Strategies - Search methods that use heuristics to guide exploration, including
(Heuristic Search)
Selects the path that appears to lead most directly to the goal based on a
Greedy Search - heuristic.
Uses a heuristic to combine the cost to reach a node and the estimated cost
A* Search - from that node to the goal to find the most cost-effective path.
Space vs. Time Consideration of the trade-offs between the memory required (space
- complexity) and the time taken (time complexity) by a search algorithm.
Complexity
The specific attributes of the problem, such as the size of the state space
Problem
- and the nature of the goal, which influence the choice of an appropriate
Characteristics search algorithm.
SELF-ASSESSMENT QUESTIONS – 1
Fill in the blanks:
1 Simple Reflex Agents operate using __________ rules to respond to immediate percepts.
2 Model-Based Reflex Agents maintain an __________ state to account for unobservable aspects of
the environment.
3 Goal-Based Agents evaluate actions based on how well they achieve specific __________.
4 Utility-Based Agents use a __________ function to determine the desirability of different states.
5 Learning Agents improve their performance over time by __________ from past experiences.
6 The Perceptual System gathers and processes information from the environment to form
__________
7 An Internal Model helps an agent make decisions by maintaining a representation of the
__________.
8 The Decision-Making System evaluates percepts, internal models, goals, and utilities to choose
the best course of __________.
9 The Action Execution System carries out the chosen actions using __________.
10 The Learning Element allows the agent to adapt and improve its performance by updating its
__________ and decision-making processes based on experiences.
4. Why are utility-based agents considered more sophisticated than goal-based agents?
2. Explain the components of an agent's architecture and discuss how each component contributes
to the agent's overall functionality and effectiveness.
3. Describe the components of a problem-solving agent and explain how each component is used
to formulate and solve problems.
4. Discuss the differences between uninformed and informed search strategies, providing
examples of each and explaining how heuristics influence the performance of informed searches.
5. Evaluate the factors that need to be considered when selecting a search algorithm for a given
problem, including the trade-offs between space and time complexity and the specific
characteristics of the problem.
12. ANSWERS
Answer 5 : Topic References: Selecting a Search Algorithm (2.3), Space vs. Time Complexity (2.3.1),
Problem Characteristics (2.3.2)
13. REFERENCES