-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimise A* Search #175
Comments
Hi @tetv , and first of all thanks for sharing your thoughts on this question. Although what you say is true, it must be taken into account that exploring the queue to remove obsolete elements is not trivial, and executing this operation whenever a node changes its position in the queue might cause a significant impact in the performance of the search algorithm. So, we found that a better approach is the current implementation, at least regarding execution time. It is not perfect, tough. For problems in which nodes are regularly re-visited the consequence is the preservation of unused references, which are never cleaned up. This impacts the memory usage and the performance of the garbage collector, as you pointed out. I agree with you on the need of cleaning up the priority, although this should be an operation only triggered under certain circumstances (i.e. memory wasted in storing unuseful elements, number of copies... something like that). Though, the triggering condition you mentioned will only happen in the last iterations of the search. We haven't thought about this issue so far, but probably something more is required to find a generic solution. Regarding to your question, stats collection is not implemented so far. However, you can count the number of calls to Best regards, |
Thank you for your answer. With regard the suggestion, one idea is to change the priority queue implementation to use the MinMaxPriorityQueue from guava, which also tracks the |
Thanks for your suggestion. I am probably missing something, but what is the benefit of having access to the latest node (apart from the fact that the nodes with obsolete costs tend to appear at the end of the queue)? The main issue in my opinion is that the nodes "to-remove" can appear in any position of the queue and a complete cleanup will require iterating over all its elements. Thus, the benefits of Also, currently the JARs weight about 0.5MB, which is desirable if you use the library in Android projects. In previous versions we depended on Guava, but decided to avoid it since the size shot up to more than 8MB. Introducing this dependency again will only make sense if the benefits are strong enough. |
Hi @gonzalezsieira, thank you for your feedback.
This is just my 2 cents for your great library collection. |
In terms of priority queue, probably the min max priority queue is not the ideal queue for this problem. Mathematically should be possible to have an implementation of remove all low priority elements (priority less than a specific number) in one go, that means O(log(n)) instead O(x . log(n)). Typically Priority queues are implemented using heaps, but maybe a solution using binary trees can be more efficient here. E.g. Deleting one branch and reorganising the tree is O(log(n)). |
During the A* Search problem, every time a state/node is explored the following procedure is applied:
However I think a good optimisation is to call, before 5., the search predicate function (isGoal) for each new generated state, and if it is a goal state, then, after inserting into the "sorted queue", all the states in that queue which f is greater than the inserted state f could be removed, because they won't be never explored, and with that, a bunch of memory is saved during the search, which turn the Garbage Collector happier.
By the way, during the search and before the result, how can I have access to some basic stats?
Like: number of explored nodes and number of nodes that are in the queue to be explored?
Thank you.
The text was updated successfully, but these errors were encountered: