Skip to content

Missing Statutory Tie-Breaking Logic for Surplus Transfers and Eliminations #19

@ohcedar

Description

@ohcedar

Issue Description:
The algorithm lacks the mandatory tie-breaking procedures required by the Scottish STV rules. When a tie occurs (either
for the highest surplus or the lowest vote count), the implementation handles it arbitrarily.

Current Behavior:
The max() and min() utility functions select the first candidate they encounter in the tally object that matches the
target value. This makes the outcome of a tie dependent on the arbitrary order of object keys, which is not compliant
with the statute.

Expected Behavior:
The Scottish Local Government Elections Order 2007 specifies a clear tie-breaking ladder:

  1. Rule 49 (Surplus Tie): If two candidates have an equal surplus, the surplus of the candidate with the most votes at
    the earliest stage where they had unequal votes is transferred first.
  2. Rule 51 (Elimination Tie): If two candidates are tied for the lowest vote count, the candidate with the fewest votes
    at the earliest stage where they had unequal votes is eliminated.
  3. By Lot: If the candidates' votes were equal at all stages, the tie must be resolved "by lot", i.e. randomly.

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