19 Heuristic Algorithms
19 Heuristic Algorithms
Heuristics
2
Definition
Heuristic: Derived from Greek word,
heuriskien, means “to search, to discover”
From Wikipedia:
“A heuristic is a technique designed to solve a problem
that ignores whether the solution can be proven to be
correct, but usually produces a good solution”
“Heuristics are intended to gain computational
performance or conceptual simplicity, potentially at
the cost of accuracy or precision”.
3
Metaheuristics
Metaheuristics is a high level framework that
provides guidelines to develop heuristic algorithms
for a large number of problems
Applicable areas include:
• Engineering Design in VLSI, aerodynamics,
robotics, fluid dynamics and others
• Genetic and Evolutionary Algorithms (key elements
of Machine Learning)
• System Modelling in control, signal and image
processing
• Scheduling, Logistics & Transportation, Route
planning
4
Graph Search
Route Planning: Find the shortest route between
two locations in a city (Google Map?)
System Modelling: Use a graph to model the path
and apply shortest path algorithms
Shortest Path Algorithms
• Un-weighted graph: BFS
• Weighed graph: Dijkstra
Disadvantage: In large graphs, evaluation of all
alternate paths (exhaustive search) takes a long
time to complete
5
Best First Search
Best First Search avoids exhaustive search by
applying a heuristic:
• A measure of distance of the target from the current
position
Method of Computing distance:
• Euclidean Method
• Manhattan Method
Easy to compute measures, but is an
approximation of the actual distance
6
Best First Search
Algorithm Approach:
1. At every node, derive the following:
f(n) = h(n), where
h(n) is estimated distance to the target
2. Choose the node with minimum value of f(n)
and proceed till target is reached
7
Example
1st Road S
2nd Road
G
3rd Road
9th Lane
3rd Lane
5th Lane
6th Lane
7th Lane
4th Lane
8th Lane
1st Lane
2nd Lane
8
Dijkstra
Go through all possible combinations …
1st Road S
2nd Road
G
3rd Road
4th Road
5th Road
9th Lane
3rd Lane
4th Lane
5th Lane
6th Lane
7th Lane
8th Lane
1st Lane
2nd Lane
9
Best First Search
Reach G from S using a short route …
1st Road S
2nd Road
G
3rd Road
9th Lane
3rd Lane
5th Lane
6th Lane
7th Lane
4th Lane
8th Lane
1st Lane
2nd Lane
10
Best First Search
Blocked by an obstacle … Alternate path?
1st Road S
2nd Road
G
3rd Road
9th Lane
3rd Lane
5th Lane
6th Lane
7th Lane
4th Lane
8th Lane
1st Lane
2nd Lane
11
Best First Search
Advantages:
Fast
Disadvantages:
May not give optimal result when obstacles are in
the way from source to target
12
A* Search
More refined heuristic:
Minimises the function:
f(n) = g(n) + h(n), where
g(n) is actual distance from source
h(n) is estimated distance to target
Finds an optimal path to the target, even in
presence of obstacles
It is a Fast Algorithm
13
14
9th Lane
Optimised path around the obstacle
8th Lane
7th Lane
6th Lane
A* Search
5th Lane
4th Lane
3rd Lane
2nd Lane
S
1st Lane
3rd Road
2nd Road
1st Road
Summary
15
Applicable Areas
Route Planning – computer networks,
airlines
VLSI Layout – cell layout & routing
Production Planning
Protein Sequence Alignment
Many NP Complete problems – where no
exact algorithms exist, heuristic search is
the only option available
16
The End
17