-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Open
Description
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.
In class PriotityQueue
Lines 726 to 728 in 5889656
def __contains__(self, item): | |
"""Return True if item in PriorityQueue.""" | |
return (self.f(item), item) in self.heap |
Inside best_first_graph_search method (lines 276 and 278).
Lines 275 to 282 in 5889656
for child in node.expand(problem): | |
if child.state not in explored and child not in frontier: | |
frontier.append(child) | |
elif child in frontier: | |
incumbent = frontier[child] | |
if f(child) < f(incumbent): | |
del frontier[incumbent] | |
frontier.append(child) |
Metadata
Metadata
Assignees
Labels
No labels