Skip to content

Floating point errors may break ties that should not be broken #29

@andersk

Description

@andersk

The following Schulze STV election should have two tied winner sets ABC and ABD. However, small floating point errors in the vote management strength computation result in only ABC being shown as winning. Specifically, the strength of ABE against C is computed as 2.571428571, while the strengths of ABF against D and AEF against D are computed as 2.571428572; the correct result is exactly 18/7 for all three.

(I am working on an independent implementation of Schulze STV in Rust using exact big-rational arithmetic, which is one way to get around this problem. Adding tolerance to the floating point comparisons may also work. I found this example after many hours of random testing against my implementation, so fortunately this condition seems to be extremely rare.)

SchulzeSTV([
    {'ballot': [['A', 'B', 'C', 'D']]},
    {'ballot': [['A', 'B', 'E'], ['D']]},
    {'ballot': [['A', 'C', 'D'], ['B']]},
    {'ballot': [['A', 'C', 'F'], ['B']]},
    {'ballot': [['A', 'D'], ['E']]},
    {'ballot': [['A'], ['D', 'E', 'F']]},
    {'ballot': [['B'], ['E'], ['D']]},
    {'ballot': [['C', 'E']]},
    {'ballot': [['F'], ['D']]},
], required_winners=3, ballot_notation=SchulzeSTV.BALLOT_NOTATION_GROUPING)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions