Thanks to visit codestin.com
Credit goes to github.com

Skip to content

PriorityQueue needs rework #1024

Open
Open
@rajatjain1997

Description

@rajatjain1997

As pointed out by #919 and #941, A* search is behaving incorrectly. This is partly due to the way the A* implementation interfaces with the PriorityQueue (in utils.py). Due to how __contains__ is implemented in PriorityQueue, if the heuristic function passed to A* produces non-unique values for the same state (As in the case of #919), A* would re-visit the same state multiple times.

#829 also raises some concerns about the implementation of __getitem__ and __contains__ in PriorityQueue. While these methods seem similar, they are quite distinct. Using __getitem__ instead of __contains__ should fix A*. However, since both these functions are confused many times (#828), we should include at least some documentation and test cases to illustrate this use. Another solution to this confusion would be altering the roles of __getitem__ and __contains__ such that for a priority queue A and element x:

  • x in A returns whether a copy is present regardless of its function value

  • A[x] returns the function value of a copy if it is present in the queue, else throws a KeyError like other dicts in python.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions