TriaRight:
The New Era of Learning
Welcome
To PACK
365
Module 02
A* Algorithm in AI
 What is an A* Algorithm in AI?
 Components of A* Algorithm
 How Does A* Algorithm Work?
 Applications of the A* Algorithm in AI
 Advantages of the A* Algorithm in AI
 Disadvantages of the A* Algorithm in AI
A* Algorithm in AI?
A* algorithm is a popular and effective algorithm used in
artificial intelligence for finding optimal paths and graph
traversal. It efficiently searches for the shortest path between
nodes in a graph by maintaining the cost to reach each node.
Each node represents a specific position in the grid.
A* algorithm is an example of informed search, as it combines the advantages of Dijkstra’s
algorithm (which guarantees the shortest path) and greedy best-first search (which uses
heuristics to prioritize nodes likely to lead to the goal). It uses a heuristic function (often
denoted as h(n)) that estimates the cost from a given node to the goal that leads to the most
optimal path to the desired node.
The algorithm maintains two lists: the open list and the closed list. It evaluates nodes based
on the sum of the costs to reach the node from the start (denoted as g(n)) and the heuristic
estimate to the goal (h(n)). The node with the lowest total cost (f(n) = g(n) + h(n)) is selected
from the open list for expansion. This process continues until the goal node is reached or
there are no more nodes to explore.
Components of A* Algorithm
The algorithm is implemented on a graph consisting of nodes (or vertices) connected by edges (or links).
Each node represents a state or a position in a space
•Cost Functions: A* uses two cost functions.
• g(n): The actual cost to reach a node from the start node
• h(n): The heuristic function estimating the cost from a node to the goal
The total cost for a node is given by the sum of these two functions: F(n)=G(n)+H(n)
•Open and Closed Lists: The algorithm maintains two lists: the open list and the closed list.
• The open list stores nodes that are candidates for evaluation.
• The closed list keeps track of nodes that have already been evaluated.
How Does A* Algorithm
Work?
To implement the A* algorithm in code, one must first understand how A* algorithm
works in the background. Here is a step-by-step guide on the working of A* algorithm:
Step 1: Initialization
•First, define the starting node and the goal node within the graph.
•Then, create two empty sets.
• Open Set: Stores nodes to be explored, initially containing only the starting node.
• Closed Set: Stores explored nodes.
Step 2: Start Iterating the Graph
•While the open set is not empty, select the node with the lowest f-score from the open set.
•This node will be the most eligible to reach the goal.
•Move the selected node from the open set to the closed set.
•Expand the current node: explore all its neighbors and their connections.
•For each neighbor, calculate g(n) and h(n), and then calculate the f-score for the starting node
using the
formula: f(n) = g(n) + h(n)
f(n): Initial f-score of the starting node
g(n): g-score of the starting node (always 0 for the starting node)
h(n): A heuristic estimate of the cost to reach the goal node from the starting node
A* algorithm iterates the whole graph by following the following steps:
•If the neighbor is not in the closed set
•If the neighbor is not in the open set, add it with its f-score.
•If the neighbor is already in the open set
•Update the neighbor’s g-score and f-score if the new ones are lower.
•If the neighbor is the goal node
•Reconstruct and return the shortest path from the starting node to the goal node by
tracing back through the g-score values.
Step 3: Termination
•If the open set becomes empty and the goal node is not found, there is no path from
the starting node to the goal node.
•By repeatedly selecting the node with the lowest f-score for expansion, the A*
algorithm efficiently explores the graph and ultimately finds the shortest path to the
goal.
Applications of the A* Algorithm in AI
 Robotics and Autonomous Vehicles
 Game Development
 GPS and Navigation Systems
 Logistics and Supply Chain Management
 Network Routing and Traffic Management
Advantages of the A* Algorithm in AI
 Optimal Searching
 Versatility
 Heuristic Approach
 Adaptability
Disadvantages of the A* Algorithm in AI
ₓ Memory Intensive
ₓ Heuristic Dependency
ₓ Doesn’t Adapt to Dynamic Environments
ₓ Not Always Efficient with High Costs
THANK
YOU

A-star Algorithm in artificial intelligence.pptx

  • 1.
    TriaRight: The New Eraof Learning Welcome To PACK 365
  • 2.
  • 3.
     What isan A* Algorithm in AI?  Components of A* Algorithm  How Does A* Algorithm Work?  Applications of the A* Algorithm in AI  Advantages of the A* Algorithm in AI  Disadvantages of the A* Algorithm in AI
  • 4.
    A* Algorithm inAI? A* algorithm is a popular and effective algorithm used in artificial intelligence for finding optimal paths and graph traversal. It efficiently searches for the shortest path between nodes in a graph by maintaining the cost to reach each node. Each node represents a specific position in the grid.
  • 5.
    A* algorithm isan example of informed search, as it combines the advantages of Dijkstra’s algorithm (which guarantees the shortest path) and greedy best-first search (which uses heuristics to prioritize nodes likely to lead to the goal). It uses a heuristic function (often denoted as h(n)) that estimates the cost from a given node to the goal that leads to the most optimal path to the desired node. The algorithm maintains two lists: the open list and the closed list. It evaluates nodes based on the sum of the costs to reach the node from the start (denoted as g(n)) and the heuristic estimate to the goal (h(n)). The node with the lowest total cost (f(n) = g(n) + h(n)) is selected from the open list for expansion. This process continues until the goal node is reached or there are no more nodes to explore.
  • 6.
    Components of A*Algorithm The algorithm is implemented on a graph consisting of nodes (or vertices) connected by edges (or links). Each node represents a state or a position in a space •Cost Functions: A* uses two cost functions. • g(n): The actual cost to reach a node from the start node • h(n): The heuristic function estimating the cost from a node to the goal The total cost for a node is given by the sum of these two functions: F(n)=G(n)+H(n) •Open and Closed Lists: The algorithm maintains two lists: the open list and the closed list. • The open list stores nodes that are candidates for evaluation. • The closed list keeps track of nodes that have already been evaluated.
  • 8.
    How Does A*Algorithm Work? To implement the A* algorithm in code, one must first understand how A* algorithm works in the background. Here is a step-by-step guide on the working of A* algorithm: Step 1: Initialization •First, define the starting node and the goal node within the graph. •Then, create two empty sets. • Open Set: Stores nodes to be explored, initially containing only the starting node. • Closed Set: Stores explored nodes.
  • 9.
    Step 2: StartIterating the Graph •While the open set is not empty, select the node with the lowest f-score from the open set. •This node will be the most eligible to reach the goal. •Move the selected node from the open set to the closed set. •Expand the current node: explore all its neighbors and their connections. •For each neighbor, calculate g(n) and h(n), and then calculate the f-score for the starting node using the formula: f(n) = g(n) + h(n)
  • 10.
    f(n): Initial f-scoreof the starting node g(n): g-score of the starting node (always 0 for the starting node) h(n): A heuristic estimate of the cost to reach the goal node from the starting node A* algorithm iterates the whole graph by following the following steps: •If the neighbor is not in the closed set •If the neighbor is not in the open set, add it with its f-score. •If the neighbor is already in the open set •Update the neighbor’s g-score and f-score if the new ones are lower. •If the neighbor is the goal node •Reconstruct and return the shortest path from the starting node to the goal node by tracing back through the g-score values.
  • 11.
    Step 3: Termination •Ifthe open set becomes empty and the goal node is not found, there is no path from the starting node to the goal node. •By repeatedly selecting the node with the lowest f-score for expansion, the A* algorithm efficiently explores the graph and ultimately finds the shortest path to the goal.
  • 12.
    Applications of theA* Algorithm in AI  Robotics and Autonomous Vehicles  Game Development  GPS and Navigation Systems  Logistics and Supply Chain Management  Network Routing and Traffic Management
  • 14.
    Advantages of theA* Algorithm in AI  Optimal Searching  Versatility  Heuristic Approach  Adaptability
  • 15.
    Disadvantages of theA* Algorithm in AI ₓ Memory Intensive ₓ Heuristic Dependency ₓ Doesn’t Adapt to Dynamic Environments ₓ Not Always Efficient with High Costs
  • 16.