A Star Material
A Star Material
A* search algorithm is a Branch and Bound Search with an estimate of remaining distance (best first Search)
combined with principle of Dynamic Programming. It is one of the most popular techniques used in finding
paths and in traversing graphs. It traverses the graph by moving in the direction of the most promising node
defined according to some rule or heuristic. Hence, unlike breadth-first search and depth-first search, which
keep on expanding the nodes without using any information about them, the algorithm considers the information
about all the candidate nodes and then traverses the best node. Therefore to calculate the fitness of a node, the
algorithm requires a heuristic evaluation function, which depends on the description of the goal, the description
gathered till the current node and most importantly the knowledge about the problem domain. Most common
form of this search methodology is using a heuristic which calculates how close the current position is to the
destination node. This kind of approach is called greedy best-first search or pure heuristic search. In order to
efficiently select the most suitable node according to the heuristic, a priority queue of nodes is used.
A* is a best first search technique that employs a heuristic function to find a path from the initial position to the
destination by traversing the graph on the basis of the heuristic function used. The algorithm is basically used on
weighted graphs, and tries to find the least cost path from the starting position to the destination. At each
iteration, A* algorithm has to decide from amongst the various paths which one to traverse. It does so
considering the cost to move to an arbitrary next position and the cost to reach the destination from this arbitrary
node. Of course, the cost to reach from the new node to the destination isn’t known and hence has to be taken
into account by making a smart guess. Therefore the heuristic used by A* is given by the following equation:
cost(n)=f(n)=a(n)+b(n) where n is the current position on the path, a(n) calculates the cost of the path from the
initial state to the current position n, and b(n) calculates the least cost of going from current position n to the
destination. The termination condition includes obtaining the path from the initial position to the destination or
when no more paths can be extended. The definition of the heuristic function depends on the problem domain.
If A* search doesn’t overestimate b(n) at nodes along the path, the algorithm guarantees to find the least cost
path from starting position to destination.
A* uses a heap to keep track of all nodes or places visited along the path so far and to efficiently pop the nodes
that have the minimum heuristic value. At each iteration, the location to be visited with the minimum cost value
is popped from the heap and the a and b values of its unvisited neighbors are updated which are then added as
children to the current location being traversed in this BFS approach. A* search continues to iterate until there
are no more locations in the heap or the destination is the node with the minimum heuristic value. For the
destination node the value of cost function is zero since the cost of reaching a node from itself is zero.
Therefore, the value of the heuristic cost function for the goal node is equal to a (destination node) that is the
value of the least cost path from the start node to the goal node.
A* search pseudocode:
else
calculate f for successors and append to open]
end for
Example 1:
Consider the following graph search problem in figure 11. Here the heuristics value for each node are already
given and the edges are labelled with the costs, f is the goal state here.
Example 2: Show the step by step generation of the A* search tree to reach the goal state ‘L’ in the tree of figure
12. Assume here that if there is a duplicate node that exists in the graph, then it was generated before the same
node which is on the current path.
f= (a+b)
L Goal State
A Initial State
Figure 12: A* search example
Hence, the GOAL STATE ‘L’ is reached with an f value of (0+4) i.e. 4. through the path (ACGKL)
thereby generating the A* search tree.