Module 2 Lecture 4
Module 2 Lecture 4
01/24/2025 BMEE407L-Module 2 1
Heuristic
• In informed search algorithms additional information is used
to make the search more efficient and effective.
• That additional information is called heuristics. Heuristics
are not theories but some common sense, experience like
information.
Ex: If you travel between two cities by car, the heuristic will be
the traffic level. (Directly the path cost will be the distance
between two cities. Additional information such as
displacement and traffic between the cities are considered as
the heuristics)
01/24/2025 BMEE407L-Module 2 2
Heuristic Search
• Utilizes practical rules or heuristics to guide the search
process.
• Differs from exhaustive search methods.
• Incorporates domain-specific knowledge or common sense.
• Provides shortcuts to reach solutions more efficiently.
• Enables quicker problem-solving in complex scenarios.
• Widely used in computer science, optimization, and
artificial intelligence.
• Valuable tool for navigating through diverse problem
spaces.
01/24/2025 BMEE407L-Module 2 3
Types
1. Greedy Search
2. A* Search Algorithm
3. IDA* (Iterative Deepening A*)
4. Bidirectional Search
5. Memory-Bounded Heuristic Search
6. Real-Time Heuristic Search
7. Satisficing Heuristic Search
01/24/2025 BMEE407L-Module 2 4
Greedy Search
• Greedy Search is an informed search algorithm
• It makes decisions based solely on heuristic information
without considering the overall path cost.
• The algorithm prioritizes nodes with the lowest heuristic
values, aiming to move quickly towards the goal state.
• Greedy Search is not concerned with finding the optimal
solution but rather focuses on immediate gains.
01/24/2025 BMEE407L-Module 2 5
Algorithm Steps
• Initialize an open list with the start node and a closed list as empty.
• While the open list is not empty:
– Select the node with the lowest heuristic value from the open list.
– Move the selected node to the closed list.
– If the selected node is the goal, the solution is found.
– Otherwise, expand the node by generating its neighbors.
– For each neighbor, calculate its heuristic value and add it to the open list if
not already there.
• If the open list becomes empty and the goal has not been reached,
the problem has no solution.
01/24/2025 BMEE407L-Module 2 6
Example
01/24/2025 BMEE407L-Module 2 7
Find the best route to reach
the destination city from the
given starting point using a
greedy method.
01/24/2025 BMEE407L-Module 2 8
01/24/2025 BMEE407L-Module 2 9
Applications
• Used for Constructing Minimum Spanning Trees
• A greedy algorithm is utilized to build a Huffman tree that
compresses a given image, spreadsheet, or video into a
lossless compressed file.
• Job Scheduling Problem, and activity selection problem are
classic optimization problems solved using a greedy
algorithmic paradigm.
01/24/2025 BMEE407L-Module 2 10
Limitations
The greedy algorithm makes judgments based on the
information at each iteration without considering the broader
problem; hence it does not produce the best answer for
every problem.
01/24/2025 BMEE407L-Module 2 11
Example
• Consider a set of jobs with associated processing times and due
dates:
• Job 1: Processing Time = 5, Due Date = 10
• Job 2: Processing Time = 3, Due Date = 8
• Job 3: Processing Time = 7, Due Date = 12
• Job 4: Processing Time = 2, Due Date = 5
UCS ??
01/24/2025 BMEE407L-Module 2 14
Uniform-Cost Search
The goal of UCS is to find a path where the
cumulative sum of costs is the least.
01/24/2025 BMEE407L-Module 2 15
Find solution using UCS to move from node S to
node G?
01/24/2025 BMEE407L-Module 2 16
Let us redraw the tree
01/24/2025 BMEE407L-Module 2 17
Let us find the solution
01/24/2025 BMEE407L-Module 2 18
A* search f(x) = g(x) + h(x)
01/24/2025 BMEE407L-Module 2 20
01/24/2025 BMEE407L-Module 2 21
Example Find the path to reach
from S to G using A*
search.
01/24/2025 BMEE407L-Module 2 22
Solution
01/24/2025 BMEE407L-Module 2 23
Solution All possible Path h(x) g(x) f(x)
S 7 0 7
SA 9 3 12
SD 5 2 7
S D B 4 2+1=3 7
S D E 3 2+4=6 9
S DB C 2 3+2=5 7
SDBE 3 3+1=4 7
SDBCG 0 5+4=9 9
01/24/2025 BMEE407L-Module 2 25
Limitation
1.Memory Usage:
A* can be memory-intensive, particularly in scenarios with a large
search space. The algorithm maintains open and closed lists to track
nodes, and in certain cases, this can lead to significant memory
requirements.
2.Heuristic Accuracy:
The optimality of A* is contingent on the admissibility of the
heuristic function. If the heuristic consistently overestimates or
underestimates the true cost, the optimality guarantee may be
compromised.
01/24/2025 BMEE407L-Module 2 26
Application
• Navigation Systems: A* is extensively used in modern navigation systems and GPS
applications. It helps users find the most optimal routes considering real-time traffic
conditions, road closures, and other factors. Applications like Google Maps leverage A* to
provide users with efficient and accurate directions for driving, walking, or public transit.
• Robotics: In the field of robotics, A* plays a crucial role in path planning for
autonomous robots. It helps robots navigate through dynamic environments, avoiding
obstacles and reaching their destinations efficiently. This is particularly important in
industries such as warehouse automation, where robots are employed for tasks like
picking and transporting goods.
• Video Games: A* is a key algorithm in the gaming industry for pathfinding of non-
player characters (NPCs) and entities within game environments. Video games,
especially those with complex and dynamic terrains, use A* to enable characters to
navigate intelligently, avoiding obstacles and providing a realistic and engaging gaming
experience. Games like strategy games, role-playing games, and simulations often rely on
A* for efficient pathfinding.
01/24/2025 BMEE407L-Module 2 27