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

Skip to content

Variable indices are compared in the Solver, which results in TypeError for indices of incomparable types. #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kral-alex opened this issue Mar 30, 2025 · 2 comments

Comments

@kral-alex
Copy link

Description

In getSolutionIter, a list of 3-tuples is sorted, where the 3rd tuple item is a problem variable index. This throws a TypeError when the type(s) of variable indices are incomparable. There is no reason to assume a variable ID to be comparable, only identity (hashability) should be assumed.

Proposed solution

Only sort by the first two tuple items (which seems to be the intended logic).
In getSolutionIter change:
lst.sort() ----> lst.sort(key=lambda x: (x[0], x[1]))

Alternatively, if comparability is required by the programme logic, specify it in documentation and ideally via typing.

Library version: 2.2.1
Python: 3.12.5

@fjwillemsen
Copy link
Member

@kral-alex thank you for reporting this issue! You are right, I have adjusted the sorting based on your suggestion. I have released this in 2.2.2.

@kral-alex
Copy link
Author

@fjwillemsen thanks for the quick resolution!

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

No branches or pull requests

2 participants