Open In App

Iterative Deepening A* algorithm (IDA*) – Artificial intelligence

Last Updated : 28 Mar, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Iterative deepening A* (IDA*) is a graph traversal and path-finding method that can determine the shortest route in a weighted graph between a defined start node and any one of a group of goal nodes. It is a kind of iterative deepening depth-first search that adopts the A* search algorithm’s idea of using a heuristic function to assess the remaining cost to reach the goal.
A memory-limited version of A* is called IDA*. It performs all operations that A* does and has optimal features for locating the shortest path, but it occupies less memory.
Iterative Deepening A Star uses a heuristic to choose which nodes to explore and at which depth to stop, as opposed to Iterative Deepening DFS, which utilizes simple depth to determine when to end the current iteration and continue with a higher depth.

Key points

  • The graph traversal algorithm.
  • Find the shortest path in a weighted graph between the start and goal nodes using the path search algorithm.
  • An alternative to the iterative depth-first search algorithm.
  • Uses a heuristic function, which is a technique taken from A* algorithm.
  • It’s a Depth-First Search algorithm, So it used less memory than the A* algorithm.
  • IDA* is an admissible heuristic because it never overestimates the cost of reaching the goal.
  • It’s focused on searching the most promising nodes, so, it doesn’t go to the same depth everywhere.
     

The evaluation function in IDA* looks like this:

f(n) = g(n) + h(n) \\ f(n) = Actual\;cost + Estimated \; cost

Where h is admissible.
here,
          f(n)  = Total cost evaluation function.
          g(n) = The actual cost from the initial node to the current node.
          h(n) = Heuristic estimated cost from the current node to the goal state. it is based on the approximation according to the problem characteristics.

What is the f score?

In the IDA* algorithm, F-score is a heuristic function that is used to estimate the cost of reaching the goal state from a given state. It is a combination of two other heuristic functions, g(n) and h(n).
It is used to determine the order in which the algorithm expands nodes in the search tree and thus, it plays an important role in how quickly the algorithm finds a solution. A lower F-score indicates that a node is closer to the goal state and will be expanded before a node with a higher F-score.
Simply it is nothing but g(n) + h(n).

How IDA* algorithm work?

Step 1: Initialization

Set the root node as the current node, and find the f-score.

Sep 2: Set threshold

Set the cost limit as a threshold for a node i.e the maximum f-score allowed for that node for further explorations.

Step 3: Node Expansion

Expand the current node to its children and find f-scores.

Step 4: Pruning

If for any node the f-score > threshold, prune that node because it’s considered too expensive for that node. and store it in the visited node list.

Step 5:  Return Path

If the Goal node is found then return the path from the start node Goal node.

Step 6: Update the Threshold

 If the Goal node is not found then repeat from step 2 by changing the threshold with the minimum pruned value from the visited node list. And Continue it until you reach the goal node.  
 

Example

In the below tree, the f score is written inside the nodes means the f score is already computed and the start node is 2 whereas the goal node is 15. the explored node is colored green color.

so now we have to go to a given goal by using IDA* algorithm.

Iteration 1

Iteration 1

  • Root node as current node i.e 2 
  • Threshold = current node value (2=2). So explore its children.
  • 4 > Threshold & 5>Threshold. So, this iteration is over and the pruned values are 4, and 5.

Iteration 2

Iteration 2

  • In pruned values, the least is 4, So threshold = 4
  • current node = 2  and 2< threshold, So explore its children. i.e two children explore one by one
  • So, first children 4, So, set current node = 4 i.e equal to the threshold, so, explored its children also i.e  5, 4 having 5> threshold so, pruned it and explore second child of node 4 i.e 4, so set current node = 4 = threshold, and explore its children i.e 8 & 7 having both 8 & 7 > threshold so, pruned it. At the end of this, our pruned value is 5,8,7
  • Similarly, Explore the second child of root node 2 i.e 5 as the current node, i.e 5>threshold, So pruned it.
  • So, our pruned value is 5,8,7.

Iteration 3

Iteration 3

  • In pruned values, the least is 5, So threshold = 5
  • current node = root node = 2  and 2< threshold, So explore its children. i.e two children explore one by one
  • So, first children 4, So, set current node = 4 < threshold, so, explored its children also i.e  5, 4 having 5= threshold so explore its child also 7&8 > threshold. So, pruned it and explore the second child of node 4 i.e 4, so set current node = 4 < threshold, and explore its children i.e 8 & 7 here, both 8 & 7 > threshold so, pruned it. At the end of this, our pruned value is 7 & 8
  • Similarly, Explore the second child of root node 2 i.e 5 as the current node, i.e 5 = threshold, so, explored its children also i.e  6 & 6, i.e both 6 & 6 > threshold. So pruned it
  • So, our pruned value is 7,8 & 6

Iteration 4

 

  • In pruned values, the least value is 6, So threshold = 6
  • current node = root node = 2  and 2< threshold, So explore its children. i.e two children explore one by one
  • So, the first child is 4, So, set current node = 4 < threshold, so, explored its children also i.e  5, 4 having 5< threshold so explore its child also 7&8 > threshold. So, pruned it and explore the second child of node 4 i.e 4, so set current node = 4 < threshold, and explore its children i.e 8 & 7 here, both 8 & 7 > threshold so, pruned it. At the end of this, our pruned value is 7 & 8
  • Similarly, Explore the second child of root node 2 i.e 5 as the current node, i.e 5 = threshold, so, explored its children also i.e  6 & 6, i.e both 6 & 6 = threshold, So, explore one by one,
  •  The first 6 has two children i.e 6 & 8, having 6 = threshold. So, explore its child also i.e 13 & 7. here both 13 & 7 > Threshold. So, pruned it. next is 8 > Threshold. pruned it, So, pruned value at this stage is 13,7 & 8.
  • Explore the second child of 5 i.e 6 = Threshold. So, explore its child i.e 7 & 9. Both are greater than Threshold. So, pruned it
  • So, our pruned values are 13,7,8 & 9. 

Iteration 5

 

  • In pruned values, the least value is 7, So threshold = 7
  • current node = root node = 2  and 2< threshold, So explore its children. i.e two children explore one by one
  • So, the first child is 4, So, set current node = 4 < threshold, so, explored its children also i.e  5, 4 
  • The first child of 4 is 5 i.e 5< threshold so explore its child also 7&8, Here 7 = threshold. So, explore its children i.e 12 & 14, both > Threshold. So, pruned it. And the second child of 5 is 8 > Threshold, So, pruned it. At this stage, our pruned value is 12, 14  & 7.
  • Now explore the second child of node 4 i.e 4, so set current node = 4 < threshold, and explore its children i.e 8 & 7 here, 8 > threshold so, pruned it. then go to the second child i.e 7 = Threshold, So explore its children i.e 13 & 8. having both > Threshold. So pruned it. At the end of this, our pruned value is 12,14,8 & 13
  • Similarly, Explore the second child of root node 2 i.e 5 as the current node, i.e 5 < threshold, so, explored its children also i.e  6 & 6, i.e both 6 & 6 < threshold, So, explore one by one,
  •  The first 6 has two children i.e 6 & 8, having 6 < threshold. So, explore its child also i.e 13 & 7. here 13 > Threshold. So, pruned it. And 7= Threshold. And it hasn’t any child. So, the shift to the next sub-child of 6 i.e 8 > threshold, So, pruned it. The pruned value at this stage is  12,14,8 &13
  • Explore the second child of 5 i.e 6 < Threshold. So, explore its child i.e 7 & 9. Here 7 = Threshold, So, explore its children i.e  8 & 14, Both are greater than Threshold. So, pruned it, Now the sub child of 6 is 9 > Threshold, So, pruned it.  
  • So, our pruned values are 12,14,8,13 & 9.

Iteration 6

Iteration 6

  • In pruned values, the least value is 8, So threshold = 8
  • current node = root node = 2  and 2< threshold, So explore its children. i.e two children explore one by one
  • So, the first child is 4, So, set current node = 4 < threshold, so, explored its children also i.e  5, 4 
  • The first child of 4 is 5 i.e 5< threshold so explore its child also 7&8, Here 7 < threshold. So, explore its children i.e 12 & 14, both > Threshold. So, pruned it. And the second child of 5 is 8 = Threshold, So,  So, explore its children i.e 16 & 15, both > Threshold. So, pruned it. At this stage, our pruned value is 12, 14, 16 & 15.
  • Now explore the second child of node 4 i.e 4, so set current node = 4 < threshold, and explore its children i.e 8 & 7 here, 8 = Threshold, So,  So, explore its children i.e 12 & 9, both > Threshold. So, pruned it. then go to the second child i.e 7 < Threshold, So explore its children i.e 13 & 8. having 13 > Threshold. So pruned it.  and 8 = Threshold and it hasn’t any child. At the end of this, our pruned values are 12, 14, 16, 15, and 13.
  • Similarly, Explore the second child of root node 2 i.e 5 as the current node, i.e 5 < threshold, so, explored its children also i.e  6 & 6, i.e both 6 & 6 < threshold, So, explore one by one,
  •  The first 6 has two children i.e 6 & 8, having 6 < threshold. So, explore its child also i.e 13 & 7. here 13 > Threshold. So, pruned it. And 7<Threshold. And it hasn’t any child. So, the shift to the next sub-child of 6 i.e 8 = threshold. So,  explored its children also i.e  15 & 16, Here 15 = Goal Node. So, stop this iteration. Now no need to explore more.
  • The goal path is 2–>5–>6–>8–>15

IDA* can be used to solve various real-life problems that are:

The 15-Puzzle Problem:

The 15-puzzle problem is a classic example of a sliding puzzle game. It consists of a 4×4 grid of numbered tiles with one tile missing. The aim is to rearrange the tiles to form a specific goal configuration. The state space of the puzzle can be represented as a tree where each node represents a configuration of the puzzle and each edge represents a legal move. IDA* can be used to find the shortest sequence of moves to reach the goal state from the initial state.

The 8-Queens Problem:

The 8-Queens problem is a classic example of the n-Queens problem where n queens have been placed on an n x n chessboard such that no two queens attack each other. The state space of the problem can be represented as a tree where each node represents a configuration of the chessboard and each edge represents the placement of a queen. IDA* can be used to find the minimum number of queens that need to be moved to reach the goal state.

In both of these examples, IDA* is used to find the optimal solution by using a combination of depth-first search and a heuristic function to limit the search space. The algorithm incrementally increases the depth bound, allowing it to find the solution without exploring the entire state space, which would be infeasible for larger problems.

Advantages and disadvantages

Advantages

  1. IDA* is guaranteed to find the optimal solution if one exists.
  2. IDA* avoids the exponential time complexity of traditional Depth First Search. by using an “iterative deepening” approach, where the search depth is gradually increased.
  3. IDA* uses a limited amount of memory as compared to the A* algorithm because it uses Depth First Search.
  4. IDA* is an admissible heuristic, it never overestimates the cost of reaching the goal.
  5. It’s efficient in handling large numbers of states and large branch factors.

Disadvantages

  1. Explore the visited node again and again. it doesn’t keep track of the visited nodes.
  2. IDA* may be slower to get a solution than other search algorithms like A* or Breadth-First Search because it explores and repeats the explore node again and again.
  3. It takes more time and power than the A* algorithm.

It’s important to note that IDA* is not suitable for all types of problems, and the choice of algorithm will depend on the specific characteristics of the problem you’re trying to solve.

Conclusion

In every branch, we have visited depth till the f score value is greater than the threshold value but we are not going above the threshold but going in depth so this is the difference between the iterative depth-first search algorithms. and IDA* algorithm. 

 

iterative depth-first search algorithms(IDDFS)

Iterative deepening A* (IDA*) 

1

Systematic

Not Systematic

2

Optimal

Optimal but never expands the node where f-score > Threshold

3

Never expands the same node twice

Expands the same node many times if f-score < Threshold

4

Not good for infinite Search traversal

For infinite Search traversal, it is better than IDDFS.



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads