Algorithm A*
The algorithm is a first search algorithm that is both complete and optimal. It maintains two lists.
i) LIST_OPENED: It stores those nodes that have been generated and on which heuristic function have been applied. But they have not yet been examined. This is a priority list between wherein nodes with higher promising value are given higher priority.
i) LIST_OPENED: It stores those nodes that have been generated and on which heuristic function have been applied. But they have not yet been examined. This is a priority list between wherein nodes with higher promising value are given higher priority.
ii) LIST_CLOSED: It stores those nodes that have been examined already, Whenever, a new node is generated, LIST_CLOSED is searched to check whether or not that node is already examined.
A* algorithm evaluates nodes using a heuristic function f(n), which is a combination of two functions i.e.,
f(n)=g(n) + h(n)
where,
g(n) ➝ It returns the cost of path from the starting node to node ‘n’.
h(n) ➝ It returns the estimated cost of the most inexpensive path from node 'n' to the goal node.
Therefore, f(n) = g(n) + h(n) will give the estimated cost of the cheapest path to the goal node (i.e, optimal solution)
h(n) ➝ It returns the estimated cost of the most inexpensive path from node 'n' to the goal node.
Therefore, f(n) = g(n) + h(n) will give the estimated cost of the cheapest path to the goal node (i.e, optimal solution)
A* algorithm finds the least cost path from a starting node to goal node. A* algorithm is admissible, meaning that it finds an optimal path to a goal (if it exists), provided that h(n) never over estimates the cost to reach the goal. Admissible heuristics are always optimistic because they assume the cost of solution to be lesser than its actual cost.
The major limitation of A* algorithm is its space requirement (for storing lists). therefore, it is not used in large scale problems.
The major limitation of A* algorithm is its space requirement (for storing lists). therefore, it is not used in large scale problems.
A* Algorithm
Step 1: Place the initial node in ‘LIST_OPENED’ and set LIST_CLOSED to an empty list.
Step 2: initialize g(n) = 0,
h(n) = Heuristic estimate of distance from initial node to goal node.
f(n) = g(n) + h(n)
Step 3: Repeat the following steps till a goal node is found.
- If the LIST_OPENED is empty then report failure and exit.
- Select a node from LIST_OPENED such that its f(n) value is the lowest. Lets call it PROMISING NODE.
- Move the PROMISING_NODE from LIST_OPENED to LIST_CLOSED.
- Check whether PROMISING_NODE is goal node. If yes, then report solution and exit. Otherwise expand the PROMISING_NODE (i.e., generate its SUCCESSORS) and for every SUCCESSOR perform the following steps
- i) Create a pointer and make it point back to PROMISING_NODE. These back pointers will help us to trace the path once a solution is found.
- ii) Calculate g(n) for SUCCESSOR as,
- g(SUCCESSOR) = g(PROMISING_NODE) + The cost of moving from PROMISING NODE to SUCCESSOR.
- iii) Search the LIST_OPENED to determine whether the SUCCESSOR is already present in the list (i.e., if it was already generated but not examined).
- iv) If it is present then we call this node as OLD_NODE. Now, we check to see whether it is cheaper to visit to OLD_NODE via its current parent or to visit to SUCCESSOR via PROMISING_NODE. If OLD_NODE is cheaper, then nothing is performed, else if SUCCESSOR is cheaper, then we have to reset OLD_NODE’S parent link to point to PROMISING_NODE. (Note that OLD_NODE and SUCCESSOR are both same, we have given different names only because of their different paths)
- v) If SUCCESSOR is not present in LIST OPENED, then check whether it is on LIST_CLOSED. If yes, call it as OLD_NODE and add it to list of PROMISING NODE’S_SUCCESSORS. Now, here also we check whether the old path is better or the new one. If path through OLD NODE is better, then we have to propagate the improvement to OLD’s SUCCESSORS. This is done by performing a depth first traversal and calculating new cost. Otherwise, if the path through current parent is better, continue propagation from that node.
- vi) If SUCCESSOR is not present in either LIST_OPENED or LIST_CLOSED, then we move the SUCCESSOR to LIST_OPENED and add it to list of PROMISING NODE's successors. Finally, we calculate,
f(SUCCESSOR) = g(SUCCESSOR) + h(SUCCESSOR).
Example: Consider the following graph.
![Algorithm A* A GENERAL GRAPH SEARCHING ALGORITHM in AI,Algorithm for Graph Search in AI, AI notes,AI lecture notes jntu,AI Class room notes jntu,ai notes unitwise,Estudies4you,AI A* Algorithm,Desirable Properties of Heuristic Search Algorithms,A* Algorithm with Example,explanation ofA* Algorithm,A* Algorithm Examples,A* AI](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi63RG0KSy5MJK2y4cBOCNluhlXFQ8VbiLCOZXhRQhVNdE1PHnCQV8BAaBTyI-jgRR56Dx0wYDV9uw5Q7w4gM4q4QQp4kFdHep5GsC-akeYL6IIZKh7BqSrqg4C-HYWHPvAjaByzD1LX4/w320-h232/Astar+Algorithm-Artificial+Intelligence.png)
![Algorithm A* A GENERAL GRAPH SEARCHING ALGORITHM in AI,Algorithm for Graph Search in AI, AI notes,AI lecture notes jntu,AI Class room notes jntu,ai notes unitwise,Estudies4you,AI A* Algorithm,Desirable Properties of Heuristic Search Algorithms,A* Algorithm with Example,explanation ofA* Algorithm,A* Algorithm Examples,A* AI](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ_LMwLKb2YSDeOQzOvewrnfFKiJcPhv1wgkq_2oDq8uRDqhnOzqJN0ZOSDYc6qcP5Cjdp2nQA6m46vMiVZ2t6sX-A9TOR_e-QO8jtFbalBSzu-5y_yS6dfx78hyZG8rQf6yaNNcsuEhQ/s16000/Astar+Algorithm-Artificial+Intelligence.png)
Step 1:
![A* Algorithm A GENERAL GRAPH SEARCHING ALGORITHM in AI,Algorithm for Graph Search in AI, AI notes,AI lecture notes jntu,AI Class room notes jntu,ai notes unitwise,Estudies4you,AI A* Algorithm,Desirable Properties of Heuristic Search Algorithms,A* Algorithm with Example,explanation ofA* Algorithm,A* Algorithm Examples,A* AI](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiH0_GfcXj306KjjkXPjQBQrrFTM_yCRMa9fmmi3vlFpMh4pm7XWcRFuqIVYENw2a7Rk6iLHA0nspYpB-A7Re24-JNJuqSiGbX3dfcaBgwuD5dcGYFjHlXzIAF-4NczRNlB2b7dZOlIyS8/s16000/Astar+Algorithm-Artificial+Intelligence.png)
![A* Algorithm A GENERAL GRAPH SEARCHING ALGORITHM in AI,Algorithm for Graph Search in AI, AI notes,AI lecture notes jntu,AI Class room notes jntu,ai notes unitwise,Estudies4you,AI A* Algorithm,Desirable Properties of Heuristic Search Algorithms,A* Algorithm with Example,explanation ofA* Algorithm,A* Algorithm Examples,A* AI](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnuZbFBsRxxOmGwMtvwdBxSKSw2N5bkSI-g_S7-5pr4W5MnK2NSWNfNovo_h36-3_e0RdInNmFwTFTBbgfBo9R_Y22WwvA1dpfCcxagchsC-Esux9EhyphenhyphenV6qmXl3ukYGam0Bzs2j74sdqQ/s16000/Astar+Algorithm-Artificial+Intelligence.png)
Step 3
![A* Algorithm A GENERAL GRAPH SEARCHING ALGORITHM in AI,Algorithm for Graph Search in AI, AI notes,AI lecture notes jntu,AI Class room notes jntu,ai notes unitwise,Estudies4you,AI A* Algorithm,Desirable Properties of Heuristic Search Algorithms,A* Algorithm with Example,explanation ofA* Algorithm,A* Algorithm Examples,A* AI](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicsoFj9IJvI-LLa-VjgLnEhxmC9lLpT0cq4pOSGza6f3kxvWYxhtCXMPSWycZlaYC8a7E27Cwye7y9d4BgfKtoVHumMVb2jVumOi27iWUAy51K9P0SoWMgW71wdewgZCppMk1B5fMzE6U/w431-h417/Astar+Algorithm-Artificial+Intelligence.png)
![A* Algorithm A GENERAL GRAPH SEARCHING ALGORITHM in AI,Algorithm for Graph Search in AI, AI notes,AI lecture notes jntu,AI Class room notes jntu,ai notes unitwise,Estudies4you,AI A* Algorithm,Desirable Properties of Heuristic Search Algorithms,A* Algorithm with Example,explanation ofA* Algorithm,A* Algorithm Examples,A* AI](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuUhVb6hWWfeX7zA7vCak1OqM9rzeqKDqElFi-45RQXj_6WZBflXSfXcqnp92Ak29dfkSaJTj1D_TZmugB3OXSJK_gDeSCQaE9EjHBzsKoCHrmLVab2PmSGzBvFJuQhStNZ2YU2qqVlVk/w421-h517/AI-18.jpg)
Desirable Properties of Heuristic Search Algorithms: Some important properties of heuristic search algorithms which evaluates its performance optimality are,
- Admissibility Condition: An algorithm is admissible if it is guaranteed to return an optimal solution if it exists.
- Completeness Condition: An algorithm is complete if it always terminated with a solution, if it exists.
- Dominance Property: In two admissible algorithms A₁, (heuristic estimated value h'(1)] and A₂, [heuristic estimated value h'(2)], A₁ is said to be more dominant and more informed than A₂, if h’(1) > h'(2).
- Optimality Property: A solution to problem is a path from the initial state to the goal state. Solution quality is measured by the path cost function and an optimal solution has the lowest path cost among all solutions.