BestFirst(StartState s)
while (isNotGoal(s))
generate successors to s
point successors back to s
add successors to open
add s to closed
s ← best from open
FLimitDFS(StartState s, Limit l)
done ← false
min ← ∞
while (!done)
if (f(s) ≤ l)
if(isGoal(s))
return path to s
generate successors to s
point successors back to s
push successors on open stack
else
if (f(s) < min) min ← f(s)
s ← pop next state from open
if pop failed, done ← true
return min
Note that if we don't find the path in this iteration, we return the smallest
f-cost on the open list. This enables us to increase the cutoff the right
amount. Otherwise we might not increase the f-cost cutoff enough and not
search any new nodes next iteration.
The Now that we have our limited DFS, all we need to do is:
IDA*(StartState s)
l ← f(s)
r ← ⌀
while (isNotPath(r))
r ← FLimitDFS(s,l)
if (isNumber(r)) l ← r
return r