You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Best First Search priority queue presents a weird behavior #919
Looks like this modification to PriorityQueue.contains() method makes the Best First Search original implementation fails with the frontier management. The queue will not work as expected by BFS algorithm and the frontier will grow in size every time a repeated situation/state is found.
You are correct, frontier size will increase not only in the case of BFS but also in the instances of A* algorithm where the heuristic function has different values for the same node depending on the path taken. Thanks for pointing this out. I will try to resolve this issue ASAP :-).
Resolved by #1196 (commit b57c2e5). The weird behavior was caused by PriorityQueue.__contains__ comparing the whole (f, item) tuple, so a same-state node with a different f-value failed the membership test and got appended as a duplicate (unbounded frontier growth) instead of replacing the costlier entry. __contains__/__getitem__/__delitem__ now match on the item only (via Node.__eq__, state-based), so best_first_graph_search's replacement works correctly. Verified on current master. Closing as resolved.
Activity
rajatjain1997 commentedon Feb 10, 2019
You are correct, frontier size will increase not only in the case of BFS but also in the instances of A* algorithm where the heuristic function has different values for the same node depending on the path taken. Thanks for pointing this out. I will try to resolve this issue ASAP :-).
dmeoli commentedon Jun 27, 2026
Resolved by #1196 (commit
b57c2e5). The weird behavior was caused byPriorityQueue.__contains__comparing the whole(f, item)tuple, so a same-state node with a different f-value failed the membership test and got appended as a duplicate (unbounded frontier growth) instead of replacing the costlier entry.__contains__/__getitem__/__delitem__now match on the item only (viaNode.__eq__, state-based), sobest_first_graph_search's replacement works correctly. Verified on current master. Closing as resolved.