Heuristic Search Algorithms
Heuristic Search Algorithms
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).
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