Implementation of A Star (A*) Algorithm in Java

 ̄綄美尐妖づ 提交于 2019-11-28 21:33:49

Try several, measure, pick the fastest, adapt to your needs. Performance is mostly determined by the choice of heuristic function, which is independent of A* proper.

If the heuristic is fixed, the implementation of the priority queue is likely to become the bottleneck, so try pairing heaps. These are some of the fastest heap data structures in practice, and they have the advantage over binary heaps that they allow for O(1) insertion time + amortized O(log n) pop-min. This is important in the expected case of many A* loops, where the queue is filled, but never entirely emptied, i.e., the number of insertions is much greater than the number of pops.

If memory becomes an issue, switch to iterative-deepening A* (IDA*) or recursive best-first search (RBFS).

If nothing works, consider using an approximation algorithm (greedy search). Simply optimizing a decently written A* loop isn't going to give you tremendous speed-ups.

See Russell and Norvig for algorithms and a good discussion of the issues.

If performance is your top priority, A* is probably not your best choice. A* provides an exact solution, and as a result will keep processing away until it finds the correct answer. There are other lightweight solutions that give good enough solutions in much faster time: e.g enforced hill climbing or best-first, even a simple depth first.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!