Presentation is loading. Please wait.

Presentation is loading. Please wait.

0 The animation which I am proposing here will be a 2D animation and can be developed in JAVA or Flash.

Similar presentations


Presentation on theme: "0 The animation which I am proposing here will be a 2D animation and can be developed in JAVA or Flash."— Presentation transcript:

1 0 The animation which I am proposing here will be a 2D animation and can be developed in JAVA or Flash.

2 1 A Star Algorithm CS344:Artificial Intelligence-B - Swati Priyam

3 2 Basic Keywords Used: A Star algorithm:Basic Definition A Star algorithm is a best first graph search algorithm that finds a least cost path from a given initial node to one goal node. Basic Terminologies Used:  Problem Space :The set of all possible configurations is the space of problem states or the problem space.

4 Keywords used : Functions used in the algorithm: Evaluation Function f(n): At any node n,it estimates the sum of the cost of the minimal cost path from the start node s to node n plus the cost of a minimal cost path from node n to a goal node. f(n)=g(n)+h(n) Where g(n)=cost of the path in the search tree from s to n; h(n)=cost of the path in the search tree from n to a goal node; Function f*(n): At any node n,it is the actual cost of an optimal path from node s to node n plus the cost of an optimal path from node n to a goal node. f*(n)=g*(n)+h*(n) Where g*(n)=cost of the optimal path in the search tree from s to n; h*(n)=cost of the optimal path in the search tree from n to a goal node; 3

5 Keywords Continued: 4 h*(n):It is the cost of the minimal cost path from n to a goal node and any path from node n to a goal node that acheives h*(n) is an optimal path from n to a goal. h is an estimate of h*. h(n) is calculated on the heuristic information from the problem domain.

6 A star Algorithm-An Example Given: A graph of nodes, is start, is goal. Aim of the Experiment:To find out the path from to with the minimum cost. Procedure: 1.Create a search graph G,consisting solely of the start node s.Put s on a list called OPEN. 2.Create a list called CLOSED that is initially empty. 3.LOOP:if OPEN is empty,exit with failure. 5

7 4.Select the first node on OPEN,remove it from OPEN and put it on CLOSED.Call this node n. 5.If n is a goal node,exit successfully with the solution obtained by tracing a path along the pointers from n to s in G. 6.Expand node n,generating the set,M,of its successors and install them as successors of n in G. 7.Establish a pointer to n from those members of M that were not already in G(I.e, not already on either OPEN or CLOSED). Add these members of M to OPEN.For each member of M that was already on OPEN or CLOSED,decide whether or not to redirect its pointer to n.For each member of M already on CLOSED,decide for each of its descendents in G whether or not to redirect its pointer. 6

8 8.Reorder the list OPEN,either according to some scheme or some heuristic merit. 9.Goto LOOP (NOTE:The above algorithm I have taken from the book Principles of Artificial Intelligence by Nils J.Nilsson.) 7

9 An Example: The proposed animation will look like this: 8 The user will be asked to set the start node S by clicking on a node in the graph search tree. The user will also be to set the goal node G by clicking on another node in the graph search tree. When the user clicks on START,the algorithm begins,and it is executed step by step indicating the status of OPEN and CLOSED list after every step. When the goal node is reached,the least costly path can be seen in the graph itself in a different color by clicking on “Show the least costly path”.

10 We can show the f value of each node as it enters the closed list by highlighting that particular node in red and displaying it in the animated graph itself and after the traversal is over,we can show the Winner node, i.e. the node which has the minimal f-value. The final Graph after the traversal is over is shown is slide- 14. After the algorithm is over,the final graph with winner nodes and the minimal path to the final node G should be shown in the animation. 9

11 A Graph search tree: Here the Starting node S is represented in RED and the goal node is represented in GREEN. Our aim is to reach the goal node G by tracing out the algorithm described in the previous slides. 10

12 OBSERVATION: Status of OPEN and CLOSED list after each step: NOTE: OPEN list and CLOSED list will be abbreviated as OL and CL from henceforth. Whenever a node enters the OL,the value of its parent node and its total cost from the starting node S will be included within simple braces(). Step 1: OL: S ( ; 0) CL: 10

13 Step 2: OL: A (S,1), B(S,3), C(S,10) CL:S Step 3: OL: B(S,3), C( S,10), D(A,6) CL: S,A Step 4: OL:C(S,10), D(A,6), E(B,7) CL: S,A,B The arrows in the diagram show that those nodes have been visited till step 4 S A B C D E F G 11

14 Step 5: OL: D(A,6), E(B,7) CL: S,A,B,C Step 6: OL: E(B,7), F(D,8) CL: S,A,B,C,D Step 7: OL: F(D,8),G(E,14) CL: S,A,B,C,D,E Step 8: OL: G(E,14) CL: S,A,B,C,D,E,F Step 9: OL: -- CL: S,A,B,C,D,E,F,G S A B C D E F G 12

15 F(n)=g(n)+h(n) Calculating the f value for each of the following nodes, we get f as: A: 1+5+3=9 B:3+4+7=14 C:10+6+7=23 D:1+5+3=9 E:3+4(10+6 is not minimal so not taken)+7 F:the goal node G cannot be reached from F 13

16 So,we can say that node A or node D is the winner as they have the least f-value. S B D E G F A C Winner nodes After the complete traversal is over,the final graph will show the winner nodes and the least estimated distance to the goal, which is 1+5+3=9,starting from S and reaching G via A and D. Least costly path:S  A  D  G 14

17 15 Questionnaire: Q1. What are the applications of A Star algorithm? A. A Star algorithm is often used to search for the lowest cost path from the q_start to the q_goal location in a graph of cells/voronoi/visibility/quad tree. Q2.Give some real life problems which uses the above algorithm. A. The algorithm solves problems like 8-puzzle problem and missionaries & Cannibals problem. Q3. List some differences between the A Star algorithm and Dijkshtra’s algorithm. A. A Star is generally considered to be the best pathfinding algorithm.Also Djikshtra’s algorithm is essentially the same as A *,except that there is no heuristic(H is always 0).Because it has no heuristic,it searches by expanding out equally in every direction.So it usually ends up exploring a much larger area before the target is found.This generally makes it slower than A *.

18 References and further Reading: 1.Principles of Artificial Intelligence by Nils J. Nilsson. 2. http://en.wikipedia.org/wiki/A*_search_algorithm 3. http://www.policyalmanac.org/games/aStarTutorial.htm A * pathfinding for beginners by Patrick Lester. 4. CDEEP Lecture :CS 344-lecture no. 2 notes. Prof. Pushpak Bhattacharya 16


Download ppt "0 The animation which I am proposing here will be a 2D animation and can be developed in JAVA or Flash."

Similar presentations


Ads by Google