Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is A* the best pathfinding algorithm?

It is generally said that A* is the best algorithm to solve pathfinding problems.

Is there any situation when A* is not the best algorithm to find solution?

How good is A* compared to BFS, DFS, UCS, etc?

like image 669
Zombie Avatar asked Mar 01 '12 05:03

Zombie


People also ask

What is the best pathfinding algorithm?

A* pathfinding algorithm is arguably the best pathfinding algorithm when we have to find the shortest path between two nodes. A* is the golden ticket, or industry standard, that everyone uses. Dijkstra's Algorithm works well to find the shortest path, but it wastes time exploring in directions that aren't promising.

Why is A * the best algorithm?

A* achieves better performance by using heuristics to guide its search. Compared to Dijkstra's algorithm, the A* algorithm only finds the shortest path from a specified source to a specified goal, and not the shortest-path tree from a specified source to all possible goals.

Is A * better than Dijkstra?

In general A* is more performant than Dijkstra's but it really depends the heuristic function you use in A*. You'll want an h(n) that's optimistic and finds the lowest cost path, h(n) should be less than the true cost. If h(n) >= cost, then you'll end up in a situation like the one you've described.

What is the fastest pathfinding algorithm?

Dijkstra's algorithm is used for our fastest path algorithm because it can find the shortest path between vertices in the graph. The coordinates on the arena are considered as the vertices in the graph.


2 Answers

The short answer is yes, there are situations in which A* is not the best algorithm to solve a problem. However, there are a number of ways to assess what constitutes the best algorithm for finding a solution.

If you are considering best in terms of performance of multiple searches from a single source to many destinations, then you should consider using a more suitable approach (Dijkstra's algorithm).

If you are considering best in terms of performance, then in some special cases DFS and BFS will significantly outperform A*. From past experience, this occurs for very small, almost trivial graphs, but would require careful testing and profiling to make a stronger statement.

If you are considering best in terms of path-length, that is how long the final path produced by the algorithm is, then A* is equivalent to any other optimal search algorithm.

If you are considering best in terms of completeness, that is, will the algorithm always find a path to the goal if such a path exists. If so, then A* is equivalent to any other complete algorithm (for example, breadth-first-search).

If you are considering best in cases where some of the weights in the graph are negative, then you will need to use a special algorithm to solve those problems (for example bellman-ford)

If you are considering best in cases where the no heuristic is available then you must fall back on h(x,y)=0 forall states x and y. In this case A* is equivalent to best first search.

If you are considering best in cases related to motion planning in continuous configuration spaces, then A* may work adequately in low dimensions, but storage of the search graph starts to become impractical at high dimensions, and the need to use probabilistically complete algorithms increases (for example RRT, Bi-RRT, RDT)

If you are considering best in cases where the graph is partially observable, you only know a subset of all the possible vertices and edges within the graph at any time, and you need to change state to observe more of the graph, then you need an alternative algorithm designed for this (for example, Keonig's Lifelong Planning A*, LPA*, does exactly this).

If you are considering best in cases where the graph changes over time, which occurs frequently in robotics when you incorporate moving obstacles, then you need an algorithm which is designed for this (for example Stentz's D* or Koenig & Likhachev's D*-Lite).

like image 137
Andrew Walker Avatar answered Nov 21 '22 10:11

Andrew Walker


A* is special because can be morphed into other path-finding algorithms by playing with how it evaluates nodes and the heuristics it uses. You can do this to simulate Djikstra's, best-first-search, breadth-first-search, and depth-first-search.

Furthermore, it's often easy to speed it up. For instance, if you multiply an admissible heuristic by a constant, c, you can guarantee that the cost of the resulting sequence of nodes is no more than c times the optimal result.

For instance, take this awesome paper by Ian Davis (written for Star Trek Armada). A* is used with a hierarchical set of waypoints, which results in a rough path. THEN, in order to smooth the path, they run A* again on a new, generated graph containing the nodes on the path and those nearby to get a more reasonable path. Finally, they run rubber-banding to remove redundant nodes.

So, A* isn't the solution to everything, but it's a very versatile tool.

like image 20
sjdlgjsljg Avatar answered Nov 21 '22 10:11

sjdlgjsljg