Skip to content

Optimise A* Search #175

@tetv

Description

@tetv

During the A* Search problem, every time a state/node is explored the following procedure is applied:

  1. call action function to retrieve a list of actions that can be applied to that specific state;
  2. call the transition function for each action retrieved in 1.
  3. call the cost function (g) for each new generated state in 2.
  4. call the estimate function (h) for each new generated state in 2.
  5. insert the new generated states into the "sorted by f=g+h queue" of states to be explored.
  6. explore the next state in the "sorted queue" which have smaller f.

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.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions