From 2987eca0c35853f29c217561140d4c4217fe3c4d Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Sat, 18 Jun 2022 01:59:29 +1000 Subject: [PATCH] Do not defer a surplus distribution if it exactly equals the difference between the 2 trailing candidates (as, depending on tie-breaking rules, this could change the order of exclusion) --- docs/options.md | 13 +++++++------ src/stv/mod.rs | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/options.md b/docs/options.md index 1fe9368..a33eb35 100644 --- a/docs/options.md +++ b/docs/options.md @@ -21,10 +21,10 @@ The preset dropdown allows you to choose from a hardcoded list of preloaded STV | Dáil Éireann STV | Rules from the [*Electoral Act 1992* (Ireland)](http://www.irishstatutebook.ie/eli/1992/act/23/enacted/en/print), using stratified random sample transfers. | [E4] [E7] | ✓ | | [Wright STV](https://www.aph.gov.au/Parliamentary_Business/Committees/House_of_Representatives_Committees?url=em/elect07/subs/sub051.1.pdf) | Rules proposed by Anthony van der Craats designed for computer counting, involving reset and re-iteration of the count after each candidate exclusion. | | ✓ | | [PRSA 1977](https://www.prsa.org.au/rule1977.htm) | Simple rules designed for hand counting, using the exclusive Gregory method, with counting performed in thousandths of a vote. | | ✓ | -| [ERS97](https://www.electoral-reform.org.uk/latest-news-and-research/publications/how-to-conduct-an-election-by-the-single-transferable-vote-3rd-edition/) | More complex rules designed for hand counting, using the exclusive Gregory method. | [E8] | ✓ | -| • ERS76 | Former rules from the 1976 2nd edition. | [E8] [E9] | ✓ | -| • ERS73 | Former rules from the 1973 1st edition. | [E8] [E9] | | -| Church of England | Rules from the Church of England [*Single Transferable Vote Rules 2020*](https://www.churchofengland.org/sites/default/files/2020-02/STV%20Rules%202020%20-%20final.pdf), similar to ERS73. | | ✓ | +| [ERS97](https://www.electoral-reform.org.uk/latest-news-and-research/publications/how-to-conduct-an-election-by-the-single-transferable-vote-3rd-edition/) | More complex rules designed for hand counting, using the exclusive Gregory method. | [E8] [E9] | ✓ | +| • ERS76 | Former rules from the 1976 2nd edition. | [E8] [E9] [E10] | ✓ | +| • ERS73 | Former rules from the 1973 1st edition. | [E8] [E9] [E10] | | +| Church of England | Rules from the Church of England [*Single Transferable Vote Rules 2020*](https://www.churchofengland.org/sites/default/files/2020-02/STV%20Rules%202020%20-%20final.pdf), similar to ERS73. | [E8] | ✓ | Exceptions: @@ -35,8 +35,9 @@ Exceptions: * [E5] The legislation is drafted such that a consistent interpretation is impossible – see Conway for a discussion. In practice, the New South Wales Electoral Commission has applied the ‘by parcel’ method of rounding subtransfers, which OpenTally follows. * [E6] The ‘mathematically eliminated by the sum of all ranked-choice votes comparison’ is not implemented. * [E7] The ‘quarter of a quota’ provision is disregarded when determining whether to defer surplus distributions. -* [E8] No distinction is made between stages and substages (during exclusion). This affects only the numbering of stages and not the result. -* [E9] By default, the quota is always calculated to 2 decimal places. For full ERS76 (ERS73) compliance, set *Round quota to 0 d.p.* when the quota is more than 100 (100 or more). +* [E8] The distribution of a surplus is not deferred if it exactly equals the difference between the 2 trailing continuing candidates. +* [E9] No distinction is made between stages and substages (during exclusion). This affects only the numbering of stages and not the result. +* [E10] By default, the quota is always calculated to 2 decimal places. For full ERS76 (ERS73) compliance, set *Round quota to 0 d.p.* when the quota is more than 100 (100 or more). For details of validation, see [validation.md](https://yingtongli.me/git/OpenTally/about/docs/validation.md). diff --git a/src/stv/mod.rs b/src/stv/mod.rs index 26df742..b9c88e6 100644 --- a/src/stv/mod.rs +++ b/src/stv/mod.rs @@ -1239,7 +1239,7 @@ where } hopefuls.sort_unstable_by(|(_, cc1), (_, cc2)| cc1.votes.cmp(&cc2.votes)); - if total_surpluses > &(&hopefuls[1].1.votes - &hopefuls[0].1.votes) { + if total_surpluses >= &(&hopefuls[1].1.votes - &hopefuls[0].1.votes) { return false; } @@ -1250,7 +1250,7 @@ where if num_to_exclude > 0 { let total_excluded = to_exclude.into_iter() .fold(N::new(), |acc, c| acc + &state.candidates[c].votes); - if total_surpluses > &(&hopefuls[num_to_exclude].1.votes - &total_excluded) { + if total_surpluses >= &(&hopefuls[num_to_exclude].1.votes - &total_excluded) { return false; } }