Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

A* SEARCH ALGORITHM

Presented By Group 19

Krishna Kumar(IT2018/122)
Kishan Raj(IT2018/025)
Aavriti Dutta(IT2018/101)
HEURISTIC SEARCH

Heuristic function- Heuristic is a function which is used in Informed


Search, and it finds the most promising path.This function estimates how
close a state is to the goal.It is represented by h(n), and it calculates the
cost of an optimal path between the pair of states.
Heuristic search – It is the simplest form of informed search algorithms
that expands the nodes based on their heuristic value ie. h(n).
A* SEARCH ALGORITHM

A* search is the most commonly known form of best-first search.It uses heuristic function
h(n), and the cost to reach the node n from the start state ie. g(n).This search algorithm
expands less search tree and provides optimal result faster. And it is also worth mentioning
that many games and web-based maps use this algorithm to find the shortest path very
efficiently.
It is formulated in terms of weighted graphs: starting from a specific starting node of a
graph, it aims to find a path to the given goal node having the smallest cost (least distance
travelled, shortest time, etc.) It does this by maintaining a tree of path originating at the
start node and extending those paths one edge at a time until the goal node is reached.
At each point in the search space, only those nodes are expanded which have the lowest
value of f(n), and the algorithm terminates when the goal node is found.
Function of A* Search Algorithm
f(n) = g(n) + h(n)

Estimated cost of Cost to reach n Cost to reach from


the cheapest node from start node n to goal
solution state node

g(n) : the exact cost of moving from the Starting node to the current
node. Basically, it is the sum of all the cells that have been visited since
leaving the first cell.

h(n) : the heuristic value associated with each node, it is


the estimated cost of moving from the current node to the final node.
The actual cost cannot be calculated until the final cell is reached. Hence,
h(n) is the estimated cost.

f(n): estimated cost of the cheapest solution ie. Sum of the values of g(n)
and h(n).
How A* Search Algorithm works?
Let us understand the process of A* search algorithm with the help of an example

S → Starting Node Red values: Heurist cost


G → Goal Node Black values: exact cost
f(n)=g(n)+h(n)

Initialization: f(S)=0+5=5

Graph Iteration1: Cost for path S→A=1+3=4 S→G=0+10=10


Path after iteration1:- {(S→ A, 4), (S→G, 10)}
(S→ A) is chosen
Iteration2: Cost for path S→A→C=1+1+2=4 S→A→B=1+2+4=7
S→G=0+10=10
Path after iteration2:- {(S→ A→C, 4), (S→ A→B, 7), (S→G, 10)}
(S→A→C) is chosen
Iteration3: Cost for path S→A→C→G=1+1+4=6 S→A→C→D=1+1+3+6=11
S→A→B=1+2+4=7 S→G=0+10=10
Path after iteration3:- {(S→ A→C→G, 6), (S→A→C→D, 11), (S→A→B, 7),
(S→G, 10)}

Iteration 4 will give the final result, as S→A→C→G it provides the optimal
path with cost 6.
Tree
Advantages of A* search algorithm:-

i. This algorithm can solve many complex problems.


ii. This algorithm is optimal and complete.
iii. It is the best search algorithm and is used in many fields of computer science
and various web based games.

Disadvantages of A* search algorithm:-

i. It does not always produce the shortest path as it is mostly based on heuristic
and approximation.
ii. A* algorithm has some complexity issues as we have to explore every nodes
to find the optimal path.
iii. The algorithm is complete only if the branching factor is finite and every action
has fixed cost.
Points to be remembered:-
i. A* algorithm returns the path which occurred first, and it does not
search for all remaining paths.
ii. The efficiency of A* algorithm depends on the quality of heuristic.
iii. A* algorithm expands all nodes which satisfy the condition f(n).
iv. It is not practical for various large scale problems because there is
memory requirement as it keeps all generated nodes in the
memory.
v. Time Complexity: The time complexity of A* search algorithm
depends on heuristic function, and the number of nodes expanded
is exponential to the depth of solution “d”.So the time complexity is
O(b^d), where “b” is the branching factor.
vi. Space Complexity: The space complexity of A* search algorithm
is O(b^d).
Conclusion:-
A* is a mighty algorithm in Artificial Intelligence with a wide
range of usage. However, it is only as good as its heuristic
function( which can be highly variable considering the nature
of a problem).
A* is the most popular choice for pathfinding because it’s
reasonably flexible.
It has found applications in many software systems, from
Machine Learning and search Optimization to game
development where characters navigate through complex
terrain and obstacles to reach the player.
THANK YOU

You might also like