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

Closed
@kral-alex

Description

@kral-alex

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

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