Skip to content

Improved PriorityQueue#1196

Merged
dmeoli merged 6 commits into
aimacode:masterfrom
Ewindar:master
Jun 26, 2026
Merged

Improved PriorityQueue#1196
dmeoli merged 6 commits into
aimacode:masterfrom
Ewindar:master

Conversation

@Ewindar

@Ewindar Ewindar commented Sep 10, 2020

Copy link
Copy Markdown
Contributor

Explaining 861853b:
If the first element of two tuples are equal, then python tries to compare the 2nd elements, which will throw a TypeError if the 2nd elements can't be compared.
This change prevents that Error from happening in that special case.

@Ewindar

Ewindar commented Sep 11, 2020

Copy link
Copy Markdown
Contributor Author

dmeoli added 2 commits June 26, 2026 23:39
heapq compares the (priority, item) tuples element-wise, so two items with the
same priority get compared directly - a TypeError for non-comparable items
(dicts, objects without __lt__). Insert a monotonic counter as a tie-breaker:
(priority, counter, item), giving deterministic FIFO ordering on ties and never
comparing items. Add a test; update two ForwardPlan tests whose air_cargo/
shopping plans (equally optimal) changed with the new deterministic tie-break.
@dmeoli dmeoli merged commit b57c2e5 into aimacode:master Jun 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants