A Algorithm
A Algorithm
css
1
2
3
4
‘A*’ Algorithm {
5
6 [For Robotics Presentation]
7
8 < Presented by
9 Bikash Sharma_2015018;
10 Agnibh Rajkonwar_2015027;
Sunit Pathak_2015029;
11
Dhiraj Yadav_2015075;
12
13 } Reisa Ahmed_2013102 >
14
A* Algorithm
A*.html Algorithm.css
1
2
Table Of ‘Contents’ {
3
4 01 Introduction
5 < What is A* Algorithm ?!
6 What are its properties ?! >
7
8 02 Algorithm Operation
9 < How does it works ? Let’s find out
with an example! >
10
11
12
03 Demonstration
< Practical demonstration by running the
13 algorithm code. >
14 }
A* ALgorithm
A*.html Algorithm.css
1
2
3 01 {
4
5
6 [Introduction]
7
8 < What is A* Algorithm?!
9 Heuristic Function?!
10 Over & Under Estimation! >
11
}
12
13
14
A* ALgorithm
A*.html Algorithm.css
1
2
A* Algorithm {
3
4
5 ● < A pathfinding algorithm based on ‘best-first search’ commonly used in
6 artificial intelligence. >
● < Informed search algorithm that utilizes heuristics to guide its search and
7 make informed decisions. >
8 ● < Formulates weighted graphs to find the best path involving the smallest
9 cost in terms of distance and time. >
10 ● < Widely used in applications such as robotics, video games, and route
planning. >
11
12 {
13
14
A* ALgorithm
A*.html Algorithm.css
1
2
Heuristic Function; {
3
4 ‘Heuristics’
5 < A strategy used to guide problem-solving and decision-making processes by
6 estimating the cost from start to end goal to provide an optimal or the best solution. >
7 Heuristic Function -> h(n) is the heuristic value used in A* for estimating the cost for
8 traversing from a node to reach end node.
9 A* Algorithm extends the path that minimizes the function Estimated Cost f(n) = g(n)
10 + h(n), where:
11
g(n) -> Actual Cost from Start Node to current node ‘n’
12
h(n) -> Estimated Cost from ‘n’ to End Node
13
14 }
A* Algorithm
A*.html Algorithm.css
1
2
Over & Under Estimation {
3
‘Over Estimation’
4
5 Heuristic Function h(n) must satisfy h(n) ≥ True Cost from Node ‘n’ to Goal for all
nodes n.
6
7 ● Non-Admissible heuristic, leads to suboptimal paths.
8 ‘Under Estimation’
9
Heuristic Function h(n) must satisfy h(n) ≤ True Cost from Node ‘n’ to Goal for all
10 nodes n.
11
● Admissible heuristic, guarantees optimal paths.
12
13 A* Algorithm is always preferred to be ‘admissible’ to always find the optimal path.
14 }
A* Algorithm
A*.html Algorithm.css
1
2
3 02 {
4
5
6 [Algorithm Operation]
7
8
9 < How does the Algorithm work ?
Explanation with an Example! >
10
11
}
12
13
14
A* ALgorithm
A*.html Algorithm.css
1
2
How the Algorithm Works{
3
A* Algorithm extends the path that minimizes the following function- f(n) = g(n) + h(n)
4
5 ● 'n' is the last node on the path
6 ● g(n) is the cost of the path from start node to node 'n'
7 ● h(n) is a heuristic function that estimates cost of the cheapest path from node 'n' to the goal
node
8
9 Algorithm-
10 ● The implementation of A* Algorithm involves maintaining two lists- OPEN and CLOSED.
11 ● OPEN contains those nodes that have been evaluated by the heuristic function but have not
12 been expanded into successors yet.
● CLOSED contains those nodes that have already been visited.
13
14
{
A* Algorithm
A*.html Algorithm.css
1
2
How the Algorithm Works {
● Define a list OPEN.
3 Step 01 ● Initially, OPEN consists solely of a single node, the start
4 node S.
5
6 Step 02 If the list is empty, return failure and exit.
7
8
● Remove node n with the smallest value of f(n) from OPEN and
9 Step 03 move it to list CLOSED.
10 ● If node n is a goal state, return success and exit.
11
12
13 Step 04 Expand node n.
14 }
A* Algorithm
A*.html Algorithm.css
1
2
How the Algorithm Works {
3
● If any successor to n is the goal node, return success and the solution by
4 Step 05 tracing the path from goal node to S.
5 ● Otherwise, go to Step-06.
6
7
8 For each successor node,
9 Step 02 ● Apply the evaluation function f to the node.
10 ● If the node has not been in either list, add it to OPEN.
11
12
13 Step 03 Go back to Step-02
14 }
A* Algorithm
A*.html Algorithm.css
1
2
Example with Solution {
3
4
● The numbers written on edges represent the distance
5 between the nodes.
6
7
8 ● The numbers written on nodes represent the heuristic
value.
9
10
11 ● Find the most cost-effective path to reach from start
12 state A to final state J using A* Algorithm.
13
14 }
A* Algorithm
A*.html Algorithm.css
1
2
Example with Solution {
3
4
Step-01:
5
6 ● We start with node A and Node B and Node F can be
reached from node A.
7 ● A* Algorithm calculates f(B) and f(F). Estimated Cost
8 f(n) = g(n)+h(n)
9 ● f(B) = 6+8=14 f(F)=3+6=9
10 ● Since f(F) < f(B), so it decides to go to node F.
● Closed list(F)
11
● Path-A-F
12
13
14
}
A* Algorithm
A*.html Algorithm.css
1
2
Example with Solution {
3
4 Step-02:
5 ● Node G and Node H can be reached from node
6 F.
7 ● A* Algorithm calculates f(G) and f(H).
● f(G)=(3+1)+5=9
8 ● f(H) = (3+7)+3=13
9 ● Since f(G) < f(H), so it decides to go to node G.
10 ● Closed list(G)
11 ● Path-A-F-G
12
13
14
}
A* Algorithm
A*.html Algorithm.css
1
2
Example with Solution {
3
4
Step-03:
5
6 ● Node I can be reached from node G.
7 ● A* Algorithm calculates f(I).
● f(1) = (3+1+3) + 1 = 8
8 ● It decides to go to node I.
9 ● Closed list(1)
10 ● Path- A-F-G→I
11
12
13
14
}
A* Algorithm
A*.html Algorithm.css
1
2
Example with Solution {
3 Step-04:
4
● Node E, Node H and Node J can be reached from
5
node I.
6 ● A* Algorithm calculates f(E), f(H) and f(J).
7 ● f(E) = (3+1+3+5)+ 3 = 15
8
f(H) = (3+1+3+2)+ 3 = 12
9
f(J) = (3+1+3+3) + 0 = 10
10
11 ● Since f(J) is least, so it decides to go to node J.
12 ● ->Closed list()
● Shortest Path-A-F-G-I→J
13
14
}
A* Algorithm
A*.html Algorithm.css
1
Time Complexity {
2
3
4 The time complexity of the A* algorithm depends on various factors :
5
1. Characteristics of the problem, the efficiency of the heuristic function, and the data
6 structures used for implementation.
7
8
9 2. In the worst case, A* has an exponential time complexity because it explores all possible
paths until it finds the optimal one
10
11 O(V+E) -> V= no. of vertices, E= no. of edges
12
13
14 }
A* ALgorithm
A*.html Algorithm.css
1
Space Complexity {
2
3 1.The space complexity of A* is typically proportional to the size of the set of nodes to be
4 evaluated.
5
6
2. It also depends on the characteristics of the problem and the data structures used for
7 implementation.
8
9
10 3. In the worst case, A* could store all generated nodes, resulting in exponential space
complexity.
11
12 O(b)^d -> b= branching factor, d=maximum depth
13
14 }
A* ALgorithm
A*.html Algorithm.css
1
2
Advantages; {
3
4
Optimization
5 < A* is an optimal algorithm,it finds the shortest path from the
start node to the goal node. >
6
7
Flexibility
8
< A* is applicable to various problem domains, including
9 pathfinding, robotics, AI >
10
11 Convergence
12 < With a well-designed and admissible heuristic function, A* can
13 efficiently explore the search space and quickly converge to the
14 } optimal solution. >
A* Algorithm
A*.html Algorithm.css
1
2
Disadvantages; {
3
4
More Memory
5 < A* may require significant memory. >
6
7
Performance
8
< The performance of A* is highly dependent on the quality of the
9 heuristic function. >
10
11 Effectiveness
12
< Designing an effective heuristic that is both admissible and
13
consistent can be challenging >
14 }
A* Algorithm
A*.py Algorithm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
A* Algorithm Code
A*.html algorithm.css
1
2
3
4
5
Software Output {
6
7
8
9
10
11
12
13
14 }
A* Algorithm
A*.html Algorithm.css
1
2
3
Thank You; {
4
5
6
7
8 < Your Engagement has been invaluable >
9
10
}
11
12
13
14
A* Algorithm