19

I don't understand how IDA* saves memory space. From how I understand IDA* is A* with iterative deepening.

What's the difference between the amount of memory A* uses vs IDA*.

Wouldn't the last iteration of IDA* behave exactly like A* and use the same amount of memory. When I trace IDA* I realize that it also has to remember a priority queue of the nodes that are below the f(n) threshold.

I understand that ID-Depth first search helps depth first search by allowing it to do a breadth first like search while not having to remember every every node. But I thought A* already behaves like depth first as in it ignores some sub-trees along the way. How does Iteratively deepening make it use less memory?

Another question is Depth first search with iterative deepening allows you to find the shortest path by making it behave breadth first like. But A* already returns optimal shortest path (given that heuristic is admissible). How does iterative deepening help it. I feel like IDA*'s last iteration is identical to A*.

Tamir Vered
  • 10,187
  • 5
  • 45
  • 57
tcui222
  • 319
  • 2
  • 3
  • 10

1 Answers1

19

In IDA*, unlike A*, you don't need to keep a set of tentative nodes which you intend to visit, therefore, your memory consumption is dedicated only to the local variables of the recursive function.

Although this algorithm is lower on memory consumption, it has its own flaws:

Unlike A*, IDA* doesn't utilize dynamic programming and therefore often ends up exploring the same nodes many times. (IDA* In Wiki)

The heuristic function still needs to be specified for your case in order to not scan the whole graph, yet the scan's memory required in every moment is only the path you are currently scanning without its surrounding nodes.

Here is a demo of the memory required in each algorithm:

Memory Map

In the A* algorithm all of the nodes and their surrounding nodes needs to be included in the "need to visit" list while in the IDA* you get the next nodes "lazily" when you reach its previews node so you don't need to include it in an extra set.

As mentioned in the comments, IDA* is basically just IDDFS with heuristics:

IDDFS vs IDA*

Tamir Vered
  • 10,187
  • 5
  • 45
  • 57
  • 2
    But doesn't IDA* still need to store the nodes it intends to visit since it still backtracks, and when backtracking, it wants to find the best path to go down next. A* needs to store nodes, isn't IDA* the same as A* but you stop after a certain f(n) and restart again? Are you saying IDA* is just IDDFS except with heuristics. As in all nodes below a threshold are treated equally and that visiting the children of a node is not in particular order as long as all the children's f(n) is below threshold? – tcui222 Oct 08 '15 at 22:31
  • Each node the `IDA*` visits already contains its reference to its neighbour nodes, so when you have this node in your call stack (Yellow in the picture above), you can iterate them. – Tamir Vered Oct 08 '15 at 22:33
  • So In A* when you are going down a path, you might realize another node has a better f(n) value and start going down another path. but IDA* won't do that because it doesn't store nodes in a priority queue, it just ignores f(n) values when selecting which child to go down next unless that f(n) value is > than the threshold? – tcui222 Oct 08 '15 at 22:47
  • Sorry I edited my last comment, can you verify that it is correct? – tcui222 Oct 08 '15 at 22:49
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/91793/discussion-between-tcui222-and-tamir-vered). – tcui222 Oct 08 '15 at 22:49