Talk:A* search algorithm

message: Someone moved this from A Star Search algorithm, but it should be located at A Star search algorithm since "Star" is part of the title.  It is usually written A*, but pronounced like the title of the article.  It is "A Star," not "A star" like "A square" or "A circle."  It is a specific algorithm—using lowercase makes it sound like it describes a generic sort of algorithm.  Anyone else have any input on this?  -Frecklefoot
:I think A-Star search algorithm is about right.  Better would be A* search algorithm, but apparently that's not an option?
Bart Massey
::A* search algorithm as a topic works fine, as you can see. :) --ZeroOne 21:55, 17 Nov 2004 (UTC)
thread_title: Article title

message: I added this section because it reflects exactly how I initially recognized that the search algorithm proposed by Nils Nilsson and Bert Raphael was "the best we'll ever find".
See the original A* paper (which incidentally we had a hard time publishing, leading journals of the day were pleased to reject it as trivial or of no interest):
Hart, P. E., N. J. Nilsson, and B. Raphael, "A Formal Basis for the Heuristic Determination of Minimum Cost Paths in Graphs," IEEE Trans. on Systems Science and Cybernetics, Vol. SSC-4, No. 2, pp 100-107, (July 1968)
It seems to me that this intuitive view is still of interest, I hope that it's more than a purely historical curiousity.
=== Difficult to extend heuristic ===
The intuition section of the article claims that A* does not take into account non-crossing and spatially close nodes, and that such considerations would be difficult or expensive to encode into the heuristic. Why so?! In my latest version distance to the neighbour node is one aspect of the heuristic and spatially close nodes will therefore tend to be prioritised. It was both trivial and cheap to implement. However, the question id if this is preferable, especially in non-symmetric spaces, where one long jump can be cheaper than several short. Mikademus 07:56, 16 September 2006 (UTC)
thread_title:  Intuition on why A* is admissible and optimal 

message: The intuition section of the article claims that A* does not take into account non-crossing and spatially close nodes, and that such considerations would be difficult or expensive to encode into the heuristic. Why so?! In my latest version distance to the neighbour node is one aspect of the heuristic and spatially close nodes will therefore tend to be prioritised. It was both trivial and cheap to implement. However, the question id if this is preferable, especially in non-symmetric spaces, where one long jump can be cheaper than several short. Mikademus 07:56, 16 September 2006 (UTC)
thread_title:  Difficult to extend heuristic 

message: Hi, I just translated my article for the A* search algorithm I wrote for the german wikipedia (which was once founded on the old version of this article)  into english, and uploaded it here. But since my mothertounge is german, I am sure there are not just dozens of typos, but also tons of wordings where native speakers just want to run away screeming :-) So I would be very pleased if some of you could correct my choice of words :-) Regnaron 18:58, 15 December 2005 (UTC)
replies: text: I think your translated article is very comprehensive, if a bit overly "textbooky" for Wikipedia. (Have you considered Wikibooks?) However, it's full of typos, grammatical atrocities, and just generally things that are wrong in English. It's very difficult to get any sense of what A* is or what it does simply by reading the article from start to finish, because nobody who starts reading will finish! So I'm reverting to the old English article — but with an encouraging word for any native English speaker who wants to try to translate the German article from scratch. (But please, less wordy!) --Quuxplusone 02:50, 16 December 2005 (UTC)
replies: text:  Hi! Hm, well, in fact I tried to make the article somewhat comprehensive through the big example section and explaining how it works, and I still would say this can help the reader to grasp the idea of "how an A* search works". (Nevertheless, all aspects of the algorithm had been covered in the article) But as I stated in my initial post here: I already assumed that there is (or now was :-)) a lot of wording that would simply be wrong in english. (I just did not expect it to be that much *g*) Getting to the point: I belive you that your comments and critics are correct, so I will not start yelling and hunting for you for reverting the article. Despite, in case anyone still wants to invest some time "translating" my old article: It will stay being acessible via my Playground on my userpage Regnaron 08:32, 16 December 2005 (UTC)
thread_title:  Rewriting of article 

message: This section points out that A* may not be computationally optimal for non-planar graphs.
The proof of the optimality of A* relies on the fundamental assumption that the triangle inequality is satisfied for every 3-node subset of the graph being searched.  A non-planar graph may violate this assumption.
Huw:  Actually the way I read this section it states that A* is not computationally optimal for planar graphs because A* does not take advantage of certain features of planar graphs.  I claim that this is nonsense.  I claim that A* depends for its quality entirely on the heuristic being used.  For example, if :h(x) = h*(x)  \forall x then A* will walk straight to the solution regardless of the type of graph being examined.  Typically, for planar graphs, h(x) is defined to be the linear planar distance from x to the goal.  This makes A* take advantage of precisely the planar features that the author claims it does not.  This means that A* will be computationally optimal for these graphs.
Matt: The previous comments are correct. This section needs to be deleted, or at least retitled and heavily edited! The optimality of A* is a fundamental principle of search algorithms. Every A.I. textbook teaches it, and any debate should be left to researchers in the field. Explaining why it doesn't make sense to you should not be posted in the main article, bring it up in discussion and we can clear up any misunderstandings. People get confused because: a) they think 'optimal' means 'fast'. b) they forget that A*'s optimality proof assumes the heuristic is admissable and consistent.
: I've deleted the section. It should be clear that topology of the graph is something the heuristic should take into consideration, not A*. Here's the original proof, which I'm adding as a reference in the article. falsedef 07:26, 11 December 2006 (UTC)
replies: text: Not sure what the above statement means. A* expands the minimal number nodes for a given informedness (heuristic) compared with other algorithms while guaranteeing finding an optimal least cost path. Thus it is both optimal in its execution and the result.  If you have an alternate algorithm that beats A*, then you have provided the alternate algorithm more a priori information about the problem than you have provided A*. Ripe 14:55, 31 August 2007 (UTC)

text: How do you know your car navigation system uses A*? It's actually pretty likely it uses a later derivative. (For instance, the mars rover Curiosity uses one called D*.) --Blogjack (talk) 17:07, 13 October 2014 (UTC)

text: I mean, that anecdotal GPS might be using A* with a non-admissible heuristic -- one that sometimes underestimates the cost instead of overestimating. In that case, it can give a suboptimal route. I often suspect that's what Google Maps is doing when it sends me along slow roads with seventeen left turns that inch toward my destination, instead of one fast one that goes around them all. (I suspect sometimes that if someone could come up with a non-trivial admissible heuristic for driving time in Boston, they could get it published.) But I digress. This caveat is well described by the article, so it's not an error or omission in the article. rspεεr (talk) 05:43, 15 October 2014 (UTC)
thread_title:  Intuition about why A* is not computationally optimal 

message: polynomial... what polynomial, n^2 is mutch mutch better than n^3
: I would doubt the correctness of that paragraph as a whole... First of all I do not see any exponential running time of the algorithm. It has to visit each vertex in a graph exactly once, as well as it has to consider every edge once. That is linear in the number of vertices and edges. You get some overhead from maintaining the priority queue, but still nothing exponential. Furthermore: If you have a graph that is a list, you can have the best heuristic, but still will do no better than with no heuristic at all, since you have to go the complete path up to the goal node. E.g. s \rightarrow a_1 \rightarrow a_2 \rightarrow \dots \rightarrow a_n \rightarrow g where s is the start node and g the goal node. Here you may have a perfect heuristic, but the running time does not change at all since you cannot skip any nodes. Regnaron 17:24, 14 July 2006 (UTC)
replies: text: O(log(h^{*}(x)) is the asymptotic growth of the perfect heuristic h^{*}. I explained this and inserted a reference. Btw., visiting each edge and each node once is only possible for finite graphs. A* can be used for infinite graphs, or at least graphs that do not fit in any computer memory using an "explicit" representation. Qwertyus 00:44, 21 July 2006 (UTC)
thread_title:  complexity 

message: The algorithm psuedo-code proposed in the article (as of now) is incorrect for non-monotonous h(x). A counter-example is available on page 4 of this article: http://www.autonlab.org/tutorials/astar08.pdf. If x is in closed (line 7), a correct algorithm should check whether the g(x) value entered when x was inserted is larger than the g() for the current path and if so - update it's value. Similarly, it is possible that x is in the priority queue already waiting to be popped; this case should be considered by the algorithm as well. An example demonstrating why this is important is on page 5 of the same article. In addition I think the article should include a proof that A* finds an optimal solution assuming an admissable heuristic. I can write one up if no one else volunteers (I'm a 4th year CS student). —The preceding unsigned comment was added by Morph555 (talk • contribs) 16:22, 17 December 2006 (UTC)
replies: text: I'm familiar with the version of A* that you are, which requires monotonicity. I'm not familiar with the one in this article, but I'm told that the "open" and "closed" lists are used to avoid the situation that requires monotonicity (at the expense of taking longer to compute). Meanwhile, the paragraph I wrote on monotonicity was removed as "inaccurate" by User:Qwertyus. Does anyone have a text that describes A* both with and without monotonicity which would help clarify this matter? rspeer / ɹəədsɹ  03:08, 26 April 2007 (UTC)
thread_title:  Correctness 

message: In my opinion BFS as an abreviation is ambiguous. It could mean both best first search and breath first search. Moreover it is first used without introduction. From later passages in the text I assume that it means best first search, but am not experienced enough to make the changes myself. Upon a second thought, dijkstra must be some kind of best first search, so I will just make the changes. If you are happy with the changes in the article, delete this message --Markulf 20:36, 6 June 2007 (UTC)
thread_title:  BFS 

message: Good luck with that pseudo code.  —The preceding unsigned comment was added by 71.195.200.155 (talk) 05:04, August 22, 2007 (UTC) 
I think http://www.geocities.com/jheyesjones/pseudocode.html has the best pseudo code Lio 14:23, 4 November 2007 (UTC)
thread_title:  Pseudo Code 

message: A bit of pervasive misinformation about A* search is that, as long as the heuristic never overestimates the distance to the goal, then the search is admissible. This is wrong.
As a counterexample: make a graph that you want to search, with a start and goal node, and give it an inadmissible heuristic, one that overestimates the distance somewhere so that A* chooses the wrong path. For the purpose of this counterexample, this heuristic shouldn't have any values over 1000000.
Now extend this graph by adding a new goal node, connecting it to the old goal node with an edge with a cost of 1000000. Suddenly the heuristic isn't an overestimate anywhere; if you're anywhere but the goal, it will cost at least 1000000 to get to the goal, and the heuristic is lower than that everywhere. So by the commonly-stated requirement for A* search, it should find the right path - but it doesn't. It finds the same path it found before, plus the new edge.
The requirement is that the heuristic can't overestimate the distance to anywhere; that is, if there's a path from A to B, then h(A) - h(B) is not greater than the shortest-path distance from A to B.
Course web pages, teaching assistants, and even textbooks leave this part out and make a provably false statement. Should I expand on this more in the article? RSpeer 08:06, Dec 25, 2004 (UTC)
Hmm. I've looked up a little more, and found a possible reason why the second condition is often left out; you can use a less efficient version of A* that always finds the correct path without that condition. However, the usually-stated algorithm requires both conditions. These notes describe both algorithms, and call the second condition "monotonic". RSpeer 18:04, Dec 26, 2004 (UTC)
Blah. I screwed up. The page was describing that less-efficient version all along. I moved the thing about monotonic heuristics to its own section. Sorry. RSpeer 19:23, Dec 27, 2004 (UTC)
:The argument above is incorrect. When A* arrives at the new goal state, the high cost of the solution node (which has a cost over 1000000) will force A* to expand all nodes that could possibly have a better score, which will include the shorter path to the old goal node.  Additionally, the monotonicity requirement is required when using a GraphSearch type algorithm, but not when using a TreeSearch (see R&N p99).  EdwinOlson (talk) 21:01, 11 September 2008 (UTC)
replies: text: *BUMP*! I believe this actually is correct; when A* arrives at the new goal state, the high cost of the edge to the solution node (which has a cost over 1000000) will force A* to expand all nodes that could possibly have a better score, but this will NOT include the shorter path to the old goal node, since the node where the paths meet again will have been added to the closed set. See my example to the right. --Kri (talk) 03:16, 7 November 2009 (UTC)
replies: text: Okay, I have now realized that this is not the case. The article mentions that if a closed set of nodes is going to be used, the heuristic estimate must be consistent too, not only admissible. So, I guess my image illustrates what could happen if a closed set is used although the heuristic is not consistent. --Kri (talk) 11:05, 21 November 2009 (UTC)
thread_title: Admissible heuristics

message: I have encountered the same problem that a few others have with the openset/closedset issue, where the heuristic function has to be consistent for the algorithm to work. I've done a few changes to the pseudocode, and would love feedback.
 function A*(start,goal) 
     openset := set containing the initial node // The set of tentative nodes to be evaluated.
     came_from := the empty map                 // The map of navigated nodes.
     g_score[start] := 0                        // Distance from start along optimal path.
     h_score[start] := heuristic_estimate_of_distance(start, goal)
     f_score[start] := h_score[start]           // Estimated total distance from start to goal through y.
     while openset is not empty
         x := the node in openset having the lowest f_score[] value
         if x = goal
             return reconstruct_path(came_from, came_from[goal])
         remove x from openset
         foreach y in neighbor_nodes(x)
             tentative_g_score := g_score[x] + dist_between(x,y)
             
             if g_score[y] is not set or tentative_g_score < g_score[y]
                 add y to openset
                 came_from[y] := x
                         
                 g_score[y] := tentative_g_score
                 h_score[y] := heuristic_estimate_of_distance(y, goal)
                 f_score[y] := g_score[y] + h_score[y]
     return failure
 function reconstruct_path(came_from, current_node)
     if came_from[current_node] is set
         p = reconstruct_path(came_from, came_from[current_node])
         return (p + current_node)
     else
         return current_node
Amitron94 (talk) 08:13, 19 January 2011 (UTC)
thread_title:  Better Pseudocode for algorithm 

message: is there a separate article on weighted A*? I couldn't find one. Weighted A* is important - it lets one "inflate" an admissible heuristics to speed up the search, and yet have a bound on the sub-optimality. If h_a(x) is an admissible heuristics function, in the weighted version of the A* search we use h_w(x) = \epsilon h_a(x), \epsilon > 1 as our heuristics function, and perform the A* search as usual (which happens much faster than using h_a). The path hence found by the search can have a cost of at most \epsilon times the least cost path. [Reference: J. Pearl, "Heuristics: Intelligent Search Strategies for Computer Problem Solving.",
Addison-Wesley, 1984.]  — Preceding unsigned comment added by Subh83 (talk • contribs) 22:06, 11 March 2011 (UTC)
thread_title:  weighted A* 

message: What is the line "Update(openset,y)" doing? The "Update" function is not explained anywhere. Is the purpose to sort the openset? I guess that's not required to mention explicitly since the line where we choose x it's already mentioned "x := the node in openset having the lowest f_score[] value". The maintainance of the openset will then be an implimentational detail. Moreover, the comments at the beginning of the code in individual likes look annoying. Why cant they stay on the same line of the code that they are explaining? -  Subh83 (talk | contribs) 02:05, 18 March 2011 (UTC)
replies: text: Any thought on this? Otherwise I will clean-up the pseudo-code in a day or so. -  Subh83 (talk | contribs) 19:53, 7 April 2011 (UTC)
thread_title:  Pseudo-code, again! 

message: I have recently created a few animations that demonstrate the working of Dijkstra's, A* and weighted A*. They illustrate a more intuitive and realistic example from robot path planning that will be helpful to grasp the high-level concepts of the algorithms and their differences. I am hence planning to place them somewhere in the article. Below is the planned content. Suggestions on the captions and where in the article to place them will be helpful.
The above figures illustrate a typical example from motion planning in robotics using 3 different search algorithms (all variants of A*). The graph is created by uniform square discretization of a 2-dimensional planar region, placing a node in each discretized cell, and connecting each node with its 8 neighbors using bidirectional edges. Cost of edges are same as their Euclidean lengths. The gray shape represents an obstacle. The filled circles in red & green represent expanded nodes (nodes in closed set). The color indicate the g-score (red: lower g-score, green: higher g-score). The empty nodes with blue boundary are the ones in open set. The nodes of the graph are generated on the fly, and nodes falling inside the obstacle are discarded as inaccessible. The objective is to find the least cost path (restricted to the graph) from a given start to a given goal node. A consistent heuristic in this problem is the Euclidean distance of a node to goal. That is, ha(n) = |g - n|2, where n represents the Euclidean coordinate of the node n, g is the goal node, and | . |2 is the 2-norm.</tr>
-  Subh83 (talk | contribs) 05:52, 15 April 2011 (UTC)
replies: text: Since there was no suggestion, and I personally think that adding all the content above may be distracting, I will add just the animation for A* along with a brief caption along with the present graphics in the process section. The present graphics does not seem to be very helpful. Thus, eventually replacing that with the animated gif may be desirable. Please discuss the possible replacement below. -  Subh83 (talk | contribs) 20:38, 17 April 2011 (UTC)
thread_title:  Animated illustration 

message: I check the reference,eecs.berkeley.edu, doesn't have any informations about the history of A*. And, in previous discussion, does the name "A*" came from statistical literature. Also, in the "A Formal Basis for the Heuristic Determination of Minimum Cost Paths" doesn't contain anything about it. --Thiti Watanasrimongkol (talk) 12:40, 13 September 2011 (UTC)
replies: text: I have a few questions about the sources for some of the statements in the current section on the History of A*. I wrote them as a separate topic but perhaps I was supposed to put them here (I am brand new to wikipedia editing). I have gathered quite a lot of information about the history of A* so will be updating this section sometime soon. I can't say where the name came from but I doubt it was from the statistical literature. -- 142.244.108.42 (talk) 17:26, 14 October 2017 (UTC)
thread_title:  History 

message: I don't currently see the AO* algorithm listed on wiki. Its a useful "extension" of A* to hypergraphs. Not sure if anyone wants to take on that challenge.  — Preceding unsigned comment added by 150.135.222.160 (talk) 21:39, 2 October 2012 (UTC)
thread_title:  Extension to hypergraphs (and-or graphs)? 

message: The pseudo code relies on a function called "heuristic_cost_estimate".
Is this so custom that it is not possible to show an example pseudo code for it?
Maybe for a standard grid (like the grid animation)?  — Preceding unsigned comment added by Vaccano (talk • contribs) 23:03, 3 December 2012 (UTC)
thread_title:  Seems to be missing heuristic pseudo code 

message: The remark at the psudocode says: "the above pseudocode assumes that the heuristic function is monotonic" which means that we do not need to revisit old states, we already have a optimal path to that node. The above pseudocode does not assume monotonic because it does infact revisit old nodes, the algoritm should imideately check if the node is in the closed set and discard the node if it is.
Even the article on consistent (monotonic) heuristic backs me up: "In the A* search algorithm, using a consistent heuristic means that once a node is expanded, the cost by which it was reached is the lowest possible"  — Preceding unsigned comment added by 130.243.154.32 (talk) 10:22, 15 September 2013 (UTC)
thread_title:  The Psudocode once again 

message: In the implementation details, it is noted that when a path needs to be reconstructed it's important to make sure if a node is about to be inserted and it's already in the open set, that it should update the node in the open set with the lowest cost path. I think this is understated and should be included as part of the process; in fact I think the reason it's important is not for reconstructing a path, but in order to avoid a lot of redundant calculations.
Without this check, it's possible for a node to add a neighbor (call it N) with a high g(x). Then later another node adds the same neighbor (N), with a different g(x) value. Depending on which g(x) was lower, the shorter path will process first and add all the neighbors of N, but it's still possible for the second path to N to be popped even though it's now already in the closed set, and to redundantly add (albeit a more expensive path to) all of the children before they are added to the closed set. This process could easily continue if the h(x) to the neighbor is far from the actual g(x) cost to the neighbor.
Checking the open set before adding neighbors would avoid continued processing of the redundant less optimal path.
Johnb003 (talk) 05:10, 23 April 2014 (UTC)
thread_title:  Implementation Details 

message: I implemented the graph version of pseudo code.  This is the one with the explored set.  It works wonderfully.  I am very interested in this new tree version that will work with non-monotonic heuristics (admissible but not consistent).  I cannot get it to work.  It seems that there is only one path being stored in the came_from list.  For a tree type search I think you would need a separate path for each leaf of the tree to store how you got there.  There could be several leaves of the same node with different paths to get there (and different g values).
Damon4-com (talk) 02:51, 2 November 2014 (UTC)
thread_title:  This latest tree version of pseudo code does not seem to work 

message: Hello fellow Wikipedians,
I have just modified one external link on A* search algorithm. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
*Added archive https://web.archive.org/web/20140806200328/http://ijcai.org/Past%20Proceedings/IJCAI-83-VOL-2/PDF/048.pdf to http://ijcai.org/Past%20Proceedings/IJCAI-83-VOL-2/PDF/048.pdf
When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.
Cheers.—InternetArchiveBot (Report bug) 15:24, 23 June 2017 (UTC)
thread_title:  External links modified 

message: In my research into the history of A* I have never seen the names A1 and A2 used for preliminary versions of it. What are the sources of this information?  I have the same question about Peter Hart's contribution.  My understanding is that he was instrumental in the definitions of admissible and consistent heuristics and the proofs based on them but did not make any changes at all to the algorithm, contrary to what is said in the current article. Again, what are the sources of this information?
I will probably be editing this article sometime soon and of course I would like to leave this information in if it is well documented.
142.244.108.42 (talk) 17:18, 14 October 2017 (UTC)
thread_title:  History of A* -- sources? 

message: The animation demonstrating the algorithm in a random maze is huge, about 25 MB. Surely it doesn't need to be that big.  — Preceding unsigned comment added by 157.52.4.163 (talk) 17:42, 13 April 2021 (UTC)
thread_title:  Why the gargantuan animation? 

message: Currently, the article does not mention that the A* algorithm (and specifically its heuristic function) only works in spaces with clearly defined distance measures. E.g. the introduction reads as if the A* algorithm works on any graph. However, this is not the case, since the “heuristics” comes from having additional knowledge of the structure of the graph and using this knowledge to construct the heuristic function, see further explanation here https://stackoverflow.com/questions/26568552/what-heuristic-functions-can-i-use-for-a-graph-based-non-grid-a Without additional knowledge of the stucture of the graph it is not possible to construct the heuristic function, and hence not possible to use the A* algorithm. A the very least I would mention the space/distance requirement when comparing with the Dijkstra's algorithm. 185.162.138.206 (talk) 10:57, 8 May 2024 (UTC)
replies: text: I agree that this is not covered well by the introductory material of our article. But, there are versions of A* that apply to arbitrary weighted graphs, using preprocessing to construct a heuristic that can then be used to make subsequent applications of A* faster. See e.g.:  —David Eppstein (talk) 17:33, 8 May 2024 (UTC)
thread_title:  Notion of space and distance