0% found this document useful (0 votes)
8 views

Heuristic Search Algorithms

Search algorithm of artificial intelligence.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Heuristic Search Algorithms

Search algorithm of artificial intelligence.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Heuristic Search Algorithms

Heuristic search algorithms are a class of search algorithms that use a


heuristic function to guide the search process toward the goal more
efficiently.

 These algorithms attempt to find solutions faster than uninformed


search methods by estimating the cost or distance from the current
node to the goal.

What is a Heuristic Function?

A heuristic function (denoted as h(n)) is a function used in heuristic


search algorithms to estimate the cost from a given node n to the goal. It
provides an "educated guess" to guide the search toward the most
promising paths, reducing the number of nodes that need to be
expanded.

The heuristic function plays a critical role in determining the efficiency


and effectiveness of search algorithms like Greedy Best-First Search and
A*. Its accuracy can directly affect the quality of the solution and the
speed of the search.

Heuristic Function Characteristics

 Admissible Heuristic: A heuristic is called admissible if it never


overestimates the cost to reach the goal. This ensures that the
solution found by the algorithm will be optimal.
 Consistent Heuristic: A heuristic is consistent if the estimated
cost from the current node to the goal is always less than or equal
to the actual cost of reaching a neighbor plus the cost from that
neighbor to the goal. Consistency ensures that the algorithm
behaves efficiently.
Underestimation and Overestimation of Heuristic Function

1. Underestimation of Heuristic (h(n) is less than the actual cost)


o Definition: When a heuristic underestimates the actual cost to
the goal, it is optimistic. It provides a lower estimate than the
true cost.
o Admissibility: A heuristic that underestimates the cost is
admissible, meaning it guarantees finding the optimal
solution.
o Example:
In a path finding problem on a map, if the heuristic function
calculates the straight-line distance between two cities (say
from Arad to Bucharest), the actual path might involve
winding roads or detours, making the actual distance longer.
However, the heuristic remains optimistic and provides a
shorter estimated distance than reality, ensuring that the
algorithm will still find the shortest path.
 Straight-Line Distance Heuristic:
 From Arad to Bucharest, the straight-line distance
might be 250 km, while the actual path could be
longer due to road conditions or detours (300 km).
 The heuristic (h(n)) underestimates the cost but
ensures that we never choose a path longer than
necessary.
o Outcome:
The algorithm will explore paths in an efficient manner but
still find the optimal solution due to this admissibility.

2. Overestimation of Heuristic (h(n) is greater than the actual cost)


o Definition: When a heuristic overestimates the cost to the
goal, it is pessimistic. It gives a higher estimate than the true
cost, which can lead the algorithm away from the optimal
path.
o Admissibility: A heuristic that overestimates is not
admissible, and it may cause the algorithm to find a
suboptimal solution.
o Example:
Consider the same map-based problem. Suppose the heuristic
function overestimates the distance between two cities (e.g.,
from Arad to Bucharest) by 350 km when the actual distance
is only 250 km. This inflated value could mislead the
algorithm into avoiding the shorter, optimal path and
exploring less promising paths.
 Overestimated Heuristic:
 The heuristic calculates the distance from Arad to
Bucharest as 350 km, while the real cost is 250
km.
 The algorithm may ignore the correct path due to
this overestimation, potentially finding a longer,
less efficient route.
o Outcome:
Overestimation can lead the search algorithm astray, causing
it to miss the optimal solution and increasing the search cost.
Heuristic Function & Path Cost

 Definition:
A heuristic function (denoted by h(n)) estimates the cost of the
cheapest path from a node n to the goal. It provides guidance
during search algorithms by predicting how close a node is to the
goal state.
 Relation with Path Cost (g(n)):
The total cost of reaching a node is denoted as g(n), which
represents the accumulated cost from the start node to n.
o Path Cost (g(n)): The actual cost incurred so far in reaching
node n.
o Heuristic (h(n)): An estimate of the remaining cost from
node n to the goal.
 Difference Between Heuristic and Path Cost:
o The path cost is the known, actual cost from the start node,
while the heuristic function provides an estimate of the
future cost.
o Greedy Search uses only the heuristic function h(n), while A
Search* combines both g(n) and h(n) to form f(n).

Best First Search Algorithm

 Overview:
Best First Search (BFS) is an algorithm that selects the most
promising adjacent node to explore based on an evaluation
function. The function estimates the cost or desirability of
expanding a node, guiding the search toward the goal.
 Evaluation Function:

The evaluation function often combines the path cost g(n) and the
heuristic h(n) to decide the next node to expand. BFS is a
generalized search technique, with Greedy Best-First Search and
A Search* as specific types.
Greedy Best-First Search
 Definition:
Greedy Best-First Search is a variant of Best First Search where
the algorithm expands the node that appears closest to the goal
based only on the heuristic function (h(n)), ignoring the actual
path cost so far.
 Key Characteristics:
o Uses only the heuristic (h(n)) to guide the search, trying to
minimize the estimated distance to the goal.
o It does not take into account the actual cost of reaching the
current node (g(n)), which may lead to suboptimal paths.
 How It Works:
1. At each step, the node with the lowest heuristic value (h(n))
is selected and expanded.
2. The algorithm repeatedly evaluates and expands the most
promising node until the goal is reached.
Pros and Cons:
o Advantage: Greedy search can find solutions quickly
because it prioritizes paths that seem promising in the short
term.
o Disadvantage: It is not guaranteed to find the optimal
solution, as it ignores the cost to reach the current node
(g(n)).
Example:
In a graph search problem like finding the shortest path from Arad to
Bucharest, Greedy Search would prioritize nodes that seem
geographically closest to the goal, possibly missing a shorter overall
route.
A* Search Algorithm
 Definition:
A* Search is a more advanced form of Best First Search that
combines both the heuristic function (h(n)) and the path cost
(g(n)) to ensure that it finds the optimal solution.
 Evaluation Function:
o The evaluation function f(n) in A* Search is the sum of:
 g(n): The actual cost incurred to reach node n.
 h(n): The estimated cost to reach the goal from node n.
o Therefore, f(n) = g(n) + h(n) represents the estimated total
cost of reaching the goal through node n.
 Admissibility:
For A* Search to be optimal, the heuristic function must be
admissible, meaning it should never overestimate the actual cost to
reach the goal. This ensures that the algorithm finds the optimal
path.
 How A Works*:
1. The algorithm evaluates nodes using the f(n) function and
expands the one with the lowest f(n) value.
2. By considering both the cost so far (g(n)) and the estimated
remaining cost (h(n)), A* balances between finding the
shortest path and efficiently reaching the goal.
Pros and Cons:
o Advantage: A* is both complete and optimal, meaning it
will always find the shortest path, provided the heuristic is
admissible.
o Disadvantage: A* can be computationally expensive, as it
needs to store all generated nodes in memory.
Example:
In the same route-finding problem from Arad to Bucharest, A* would
find the shortest path by considering both the actual travel cost and the
remaining distance, ensuring the most efficient route is chosen.

Summary

 The heuristic function (h(n)) estimates the remaining cost to the


goal, while path cost (g(n)) represents the actual cost incurred so
far.
 Best First Search uses an evaluation function to guide the search
by selecting the most promising nodes.
 Greedy Best-First Search relies solely on the heuristic (h(n)) and
may find suboptimal solutions.
 A Search* combines both path cost (g(n)) and heuristic (h(n)),
ensuring that it finds the optimal solution with the lowest total cost
(f(n) = g(n) + h(n)).

You might also like