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

AI Notes - Module 3

Chapter 4 discusses informed search strategies in AI, focusing on heuristic methods that estimate the cost or distance to a goal. It details three common heuristics: Euclidean Distance, Manhattan Distance, and Misplaced Tiles, each with specific use cases and properties. Additionally, it covers the A* algorithm and Greedy Best-First Search, highlighting their advantages, disadvantages, and the impact of heuristic accuracy on search efficiency.

Uploaded by

ATHARVA SUBHEDAR
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

AI Notes - Module 3

Chapter 4 discusses informed search strategies in AI, focusing on heuristic methods that estimate the cost or distance to a goal. It details three common heuristics: Euclidean Distance, Manhattan Distance, and Misplaced Tiles, each with specific use cases and properties. Additionally, it covers the A* algorithm and Greedy Best-First Search, highlighting their advantages, disadvantages, and the impact of heuristic accuracy on search efficiency.

Uploaded by

ATHARVA SUBHEDAR
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Chapter 4: INFORMED (HEURISTIC) SEARCH STRATEGIES

1. Heuristic Search Methods in AI:

In informed search, the search algorithm uses a heuristic function to estimate the cost or
distance from a given state to the goal. These heuristics guide the search towards the goal more
efficiently by selecting the most promising paths first.

A heuristic is a problem-solving technique or strategy that provides a good-enough solution for a


problem, especially when finding the exact solution is difficult or time-consuming. In Artificial
Intelligence (AI), a heuristic function estimates the cost or distance from a current state to a goal
state to guide the search process efficiently.

Below are three commonly used heuristic functions:

1. Euclidean Distance Heuristic:

The Euclidean Distance measures the straight-line (as-the-crow-flies) distance between two
points in space, such as between the current state and the goal state.

Formula:

Where:

• (x1,y1) = coordinates of the current state

• (x2,y2) = coordinates of the goal state


Use Case:
It’s commonly used in pathfinding problems (like in A* search) when movement occurs diagonally,
and the distance between points is continuous.

Example:
To apply Euclidean distance in a more realistic context, let’s assume we are finding the straight-
line distance (as-the-crow-flies) between Belgaum and Panaji (Goa). The straight-line (or
Euclidean) distance is based on the geographical coordinates (latitude and longitude) of these
cities.

• Belgaum (Latitude, Longitude): 15.8497°N, 74.4977°E

• Panaji (Goa, Latitude, Longitude): 15.4909°N, 73.8278°E

Where:

• x1,y1 = Latitude and Longitude of Belgaum

• x2,y2 = Latitude and Longitude of Panaji

• k= Earth radius constant in kilometers (~111 km/degree)

h(n) = 84.4 km

The Euclidean (straight-line) distance between Belgaum and Panaji (Goa) is approximately
84.4 kilometers. However, the actual driving distance will be longer (around 100-110 km)
since roads are not perfectly straight.

Key Property:

• This heuristic is admissible (it never overestimates) because it provides the shortest
straight-line path.
2. Manhattan Distance Heuristic

The Manhattan Distance measures the total distance traveled along grid lines (horizontal and
vertical paths only). This is often used in grid-based games or puzzles, such as when the agent can
only move up, down, left, or right.

Formula:

Use Case:
It’s used when movements are restricted to orthogonal directions (no diagonals), such as in
navigating through city blocks or in puzzles.

Example:
The Manhattan distance heuristic calculates how far each tile is from its correct position in terms
of horizontal and vertical moves only (like moving on a grid). It sums the individual distances of all
tiles from their goal positions.

2 8 3 1 2 3
1 6 4 4 5 6
7 5 7 8
Initial State Goal State

h(n)=1+1+0+2+2+1+0+2 = 9

Key Property:

• The Manhattan heuristic works well in grid environments but may underestimate in cases
where diagonal moves are allowed.

3. Misplaced Tiles Heuristic (for the 8-puzzle problem):

This heuristic counts the number of tiles not in their correct position in a puzzle, such as the 8-
puzzle or 15-puzzle. The fewer the misplaced tiles, the closer the state is to the goal.

Formula:
Use Case:
Used specifically for sliding-tile puzzles like the 8-puzzle, where tiles need to be arranged to match
a goal configuration.

Example:
Consider the following initial and goal states:

2 8 3 1 2 3
4 1 6 4 5 6
7 5 7 8

Initial State Goal State

Here, 1, 2, 5 and 8 are misplaced so h(n) = 4

Key Property:

• This heuristic is admissible because it never overestimates the number of moves required
to reach the goal.

Heuristic Use Case Admissibility Optimal For


Pathfinding with
Euclidean Distance Yes Continuous spaces
diagonal moves
Manhattan Orthogonal
Grid-based navigation Yes
Distance movement only

Sliding tile puzzles (8-


Misplaced Tiles Yes Puzzle-solving
puzzle)

2. A *Algorithm in AI: ***** IMPORTANT *****


A* is one of the most popular informed search algorithms used in Artificial Intelligence. It
combines features of Uniform Cost Search and Greedy Best-First Search to find the shortest
path from a start node to a goal node, ensuring both completeness and optimality.

Key Concepts of A*:

• g(n): The cost from the start node to the current node n.
• h(n): The heuristic estimate of the cost from n to the goal.

• f(n) = g(n) + h(n): The total estimated cost of the path through node n.

The A* algorithm explores the node with the lowest f(n) value, ensuring that it balances both the
actual cost from the start (g(n)) and the predicted cost to the goal (h(n)).
Advantages of A*:

• Complete: It will always find a solution if one exists.

• Optimal: It guarantees the shortest path if the heuristic is admissible (does not
overestimate the cost).

• Efficient: Explores fewer nodes compared to uninformed search algorithms.

Disadvantages of A*:

• Memory-intensive: It stores all generated nodes, which can be a problem for large graphs.

• Performance depends on the heuristic: If the heuristic is not accurate, the algorithm’s
efficiency reduces.

2.1 Overestimation and Underestimation in A Algorithm*

The A algorithm* is an informed search technique that uses both the actual cost from the start node
to the current node (g(n)) and the estimated cost from the current node to the goal (h(n)). It selects
the path with the lowest f(n) = g(n) + h(n) at each step.

The heuristic function h(n) plays a crucial role in determining the efficiency and optimality of the A*
algorithm. The behavior of A* depends on whether the heuristic is overestimating or
underestimating the actual cost to the goal.

1. Overestimation of the Heuristic Function (h(n) > h*(n))

• Overestimation means that the heuristic value is greater than the actual cost from the
current node to the goal.

• This can lead the algorithm to believe a path is more promising than it actually is, which
might result in non-optimal solutions.

Effects of Overestimation:

1. Loss of Optimality: A* may no longer guarantee finding the shortest or least-cost path.

2. Faster but Incorrect: It may reach the goal faster but not via the best possible path.
3. Greedy-like behavior: Overestimation can make A* behave like Greedy Best-First Search
by focusing too much on the heuristic and ignoring the actual path cost.

Example of Overestimation:

Imagine in a route-finding problem, the actual remaining distance from a city to the goal is 100 km,
but the heuristic function predicts it to be 150 km. This overestimation might cause the algorithm to
explore paths that appear cheaper but are not optimal.

2. Underestimation of the Heuristic Function (h(n) < h*(n))

• Underestimation occurs when the heuristic predicts a cost less than the actual remaining
cost to the goal.

• While this makes A* more cautious, it ensures that the algorithm finds the optimal solution
because it explores all relevant paths.

Effects of Underestimation:

1. Optimal but Slow: A* will still guarantee the shortest or least-cost path but may explore more
nodes, leading to higher time complexity.

2. More Complete Search: The algorithm expands more nodes than necessary, increasing
computational overhead.

Example of Underestimation:

If the actual remaining cost from a city to the goal is 100 km, but the heuristic estimates it to be 50
km, A* will explore additional nodes unnecessarily to confirm the optimal path.
3. Greedy Best-First Search in AI:
Greedy Best-First Search (GBFS) is an informed search algorithm that focuses on expanding
the node that appears to be closest to the goal, according to a given heuristic function h(n). It tries
to reach the goal as fast as possible by selecting the node with the lowest heuristic value, but it
doesn’t consider the cost to reach the current node from the start (g(n)). Uses priority queue
method.

How Greedy Best-First Search Works

• Heuristic function h(n) estimates the cost from the current node to the goal.
• GBFS chooses the node with the smallest h(n) value from the open list (nodes waiting to
be explored).

• It focuses entirely on the goal, ignoring the cost of the path already traversed. This makes
it fast but prone to errors, as it can get stuck in local optima (suboptimal paths).

Analysis of GBFS:
Fast but not optimal: The search is goal-oriented and may not always find the shortest path. In this
example, it selected Karwar because of the lower heuristic value, but it ignored the actual cost (g(n))
to reach that node.
Advantages of Greedy Best-First Search:

1. Fast and simple: It selects the node that seems closest to the goal.

2. Useful for large state spaces: Focuses only on the goal, reducing the search space.

3. Easy to implement: It only requires a heuristic function.

Disadvantages of Greedy Best-First Search:

1. Not optimal: It may not find the shortest or most cost-effective path (local optimum issue).

2. Incomplete: It can get stuck in loops if the graph is not properly handled.

3. Heuristic-dependent: The efficiency heavily relies on the accuracy of the heuristic function.

You might also like