Python heapq,处理两个对象的相同值?

Python heapq,处理两个对象的相同值?,python,heap,sliding-tile-puzzle,Python,Heap,Sliding Tile Puzzle,我在尝试将具有相同值的对象推入堆时发现了一个问题 for neighbor in neighbors: if neighbor.get_config() not in explored and neighbor.get_config() not in frontier_set: print(frontier_heap) heapq.heappush(frontier_heap, ((neighbor.get_cost() +

我在尝试将具有相同值的对象推入堆时发现了一个问题

    for neighbor in neighbors:
        if neighbor.get_config() not in explored and neighbor.get_config() not in frontier_set:
            print(frontier_heap)
            heapq.heappush(frontier_heap, ((neighbor.get_cost() + calculate_manhattan_dist(neighbor)), neighbor))
            frontier_set.add(neighbor.get_config())
我得到以下输出:

[(12, <__main__.PuzzleState object at 0x008B5EB0>)]

[(10, <__main__.PuzzleState object at 0x008B5E90>), (12, <__main__.PuzzleState object at 0x008B5EB0>)]

Traceback (most recent call last):
  File "c:/stuff/python/AI/P1/driver_3.py", line 343, in <module>
    print(A_star_search(PuzzleState((6,1,8,4,0,2,7,3,5))))
  File "c:/stuff/python/AI/P1/driver_3.py", line 277, in A_star_search
    heapq.heappush(frontier_heap, ((neighbor.get_cost() + calculate_manhattan_dist(neighbor)), neighbor))
TypeError: '<' not supported between instances of 'PuzzleState' and 'PuzzleState'
[(12,)]
[(10, ), (12, )]
回溯(最近一次呼叫最后一次):
文件“c:/stuff/python/AI/P1/driver_3.py”,第343行,在
打印(星号搜索(拼图状态((6,1,8,4,0,2,7,3,5)))
文件“c:/stuff/python/AI/P1/driver_3.py”,第277行,在搜索中
heapq.heappush(frontier\u heap,((neighbor.get\u cost()+计算曼哈顿区(neighbor)),neighbor))

TypeError:“您读过heapq文档中的吗?谢谢,我没有意识到我可以将两个以上的元素放入堆中。”。