From bd33aaeea059fc7639c347b1af15c5f6e67c28ae Mon Sep 17 00:00:00 2001 From: Armin Samii Date: Tue, 17 Sep 2024 12:34:53 -0400 Subject: [PATCH] fix incorrect transfers --- src/main/java/network/brightspots/rcv/RoundTally.java | 5 +++-- .../2013_minneapolis_park_expected_summary.csv | 2 +- .../2013_minneapolis_park_hare_expected_summary.csv | 2 +- ...is_multi_seat_threshold_expected_pc1_precinct_summary.csv | 2 +- ...is_multi_seat_threshold_expected_pc2_precinct_summary.csv | 2 +- .../minneapolis_multi_seat_threshold_expected_summary.csv | 2 +- ..._set_allow_only_one_winner_per_round_expected_summary.csv | 2 +- ...set_allow_only_one_winner_per_round_expected_summary.json | 2 +- ...et_multi_winner_fractional_threshold_expected_summary.csv | 2 +- ...est_set_multi_winner_whole_threshold_expected_summary.csv | 2 +- 10 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/network/brightspots/rcv/RoundTally.java b/src/main/java/network/brightspots/rcv/RoundTally.java index 079be0cd..98c03860 100644 --- a/src/main/java/network/brightspots/rcv/RoundTally.java +++ b/src/main/java/network/brightspots/rcv/RoundTally.java @@ -204,14 +204,15 @@ public List getSortedCandidatesByTally() { private void countBallots() { inactiveBallotSum = BigDecimal.ZERO; + activeBallotSum = BigDecimal.ZERO; ballotStatusTallies.forEach( (statusForRound, tally) -> { if (statusForRound.isInactiveBallot()) { inactiveBallotSum = inactiveBallotSum.add(tally); + } else { + activeBallotSum = activeBallotSum.add(tally); } }); - - activeBallotSum = ballotStatusTallies.get(StatusForRound.ACTIVE); } private void ensureFinalized() { diff --git a/src/test/resources/network/brightspots/rcv/test_data/2013_minneapolis_park/2013_minneapolis_park_expected_summary.csv b/src/test/resources/network/brightspots/rcv/test_data/2013_minneapolis_park/2013_minneapolis_park_expected_summary.csv index 820ca3e5..874338c4 100644 --- a/src/test/resources/network/brightspots/rcv/test_data/2013_minneapolis_park/2013_minneapolis_park_expected_summary.csv +++ b/src/test/resources/network/brightspots/rcv/test_data/2013_minneapolis_park/2013_minneapolis_park_expected_summary.csv @@ -29,7 +29,7 @@ MARY LYNN MCPHERSON,3373,5.67%,5,3378,5.68%,101,3479,5.85%,0.0000,3479.0000,5.85 ISHMAEL ISRAEL,3305,5.55%,5,3310,5.56%,64,3374,5.67%,0.0000,3374.0000,5.67%,-3374.0000,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0 CASPER HILL,1280,2.15%,4,1284,2.15%,-1284,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0 Undeclared Write-ins,342,0.57%,-342,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0 -Active Ballots,59463,,,59174,,,58876,,,58876.0000,,,57861.0000,,,56780.0000,,,54875.0000,,,51478.0000,,,48418.0000,,,42155.0000,,,41977.0000,, +Active Ballots,59463,,,59174,,,58876,,,58876.0000,,,57861.0000,,,56780.0000,,,54875.0000,,,51478.0000,,,48418.0000,,,42155.0000,,,42154.5192,, Current Round Threshold,14866,,,14866,,,14866,,,14866,,,14866,,,14866,,,14866,,,14866,,,14866,,,14866,,,14866,, Inactive Ballots by Overvotes,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0 Inactive Ballots by Skipped Rankings,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0 diff --git a/src/test/resources/network/brightspots/rcv/test_data/2013_minneapolis_park_hare/2013_minneapolis_park_hare_expected_summary.csv b/src/test/resources/network/brightspots/rcv/test_data/2013_minneapolis_park_hare/2013_minneapolis_park_hare_expected_summary.csv index d47a9215..91a5c9fc 100644 --- a/src/test/resources/network/brightspots/rcv/test_data/2013_minneapolis_park_hare/2013_minneapolis_park_hare_expected_summary.csv +++ b/src/test/resources/network/brightspots/rcv/test_data/2013_minneapolis_park_hare/2013_minneapolis_park_hare_expected_summary.csv @@ -29,7 +29,7 @@ MARY LYNN MCPHERSON,3373,5.67%,5,3378,5.68%,101,3479,5.85%,202,3681,6.19%,-3681, ISHMAEL ISRAEL,3305,5.55%,5,3310,5.56%,64,3374,5.67%,-3374,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0 CASPER HILL,1280,2.15%,4,1284,2.15%,-1284,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0 Undeclared Write-ins,342,0.57%,-342,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0 -Active Ballots,59463,,,59174,,,58876,,,57926,,,56924,,,55274,,,52027,,,49968,,,47268,,,45439.0000,, +Active Ballots,59463,,,59174,,,58876,,,57926,,,56924,,,55274,,,52027,,,49968,,,47268,,,47266.2600,, Current Round Threshold,19821,,,19821,,,19821,,,19821,,,19821,,,19821,,,19821,,,19821,,,19821,,,19821,, Inactive Ballots by Overvotes,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0 Inactive Ballots by Skipped Rankings,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0 diff --git a/src/test/resources/network/brightspots/rcv/test_data/minneapolis_multi_seat_threshold/minneapolis_multi_seat_threshold_expected_pc1_precinct_summary.csv b/src/test/resources/network/brightspots/rcv/test_data/minneapolis_multi_seat_threshold/minneapolis_multi_seat_threshold_expected_pc1_precinct_summary.csv index ba5a9f92..807d9474 100644 --- a/src/test/resources/network/brightspots/rcv/test_data/minneapolis_multi_seat_threshold/minneapolis_multi_seat_threshold_expected_pc1_precinct_summary.csv +++ b/src/test/resources/network/brightspots/rcv/test_data/minneapolis_multi_seat_threshold/minneapolis_multi_seat_threshold_expected_pc1_precinct_summary.csv @@ -24,7 +24,7 @@ E,5,20.83%,0,5,20.83%,0.0000,5.0000,20.83%,0.0000,5.0000,20.83%,-5.0000,0,0.0%,0 B,4,16.66%,0,4,16.66%,0,4,16.66%,2.0000,6.0000,25.0%,2.0000,8.0000,33.33%,-1.6000,6.4000,26.66%,0 F,3,12.5%,0,3,12.5%,0.0000,3.0000,12.5%,-3.0000,0,0.0%,0,0,0.0%,0,0,0.0%,0 D,2,8.33%,-2,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0 -Active Ballots,24,,,23,,,23.0000,,,23.0000,,,23.0000,,,19.6000,, +Active Ballots,24,,,23,,,23.0000,,,23.0000,,,23.0000,,,23.0000,, Inactive Ballots by Overvotes,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0 Inactive Ballots by Skipped Rankings,1,,1,2,,0,2,,0,2,,0.0000,2.0000,,0.0000,2.0000,,0 Inactive Ballots by Exhausted Choices,0,,0,0,,0,0,,0,0,,0.0000,0.0000,,0.0000,0.0000,,0 diff --git a/src/test/resources/network/brightspots/rcv/test_data/minneapolis_multi_seat_threshold/minneapolis_multi_seat_threshold_expected_pc2_precinct_summary.csv b/src/test/resources/network/brightspots/rcv/test_data/minneapolis_multi_seat_threshold/minneapolis_multi_seat_threshold_expected_pc2_precinct_summary.csv index 7f91e5c8..a65d3cc4 100644 --- a/src/test/resources/network/brightspots/rcv/test_data/minneapolis_multi_seat_threshold/minneapolis_multi_seat_threshold_expected_pc2_precinct_summary.csv +++ b/src/test/resources/network/brightspots/rcv/test_data/minneapolis_multi_seat_threshold/minneapolis_multi_seat_threshold_expected_pc2_precinct_summary.csv @@ -24,7 +24,7 @@ E,1,20.0%,0,1,20.0%,0.0000,1.0000,20.0%,0.0000,1.0000,20.0%,-1.0000,0,0.0%,0,0,0 B,1,20.0%,0,1,20.0%,0,1,20.0%,0,1,20.0%,1,2,40.0%,-0.4000,1.6000,32.0%,0 F,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0 D,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0 -Active Ballots,5,,,5,,,5.0000,,,5.0000,,,5.0000,,,4.4000,, +Active Ballots,5,,,5,,,5.0000,,,5.0000,,,5.0000,,,5.0000,, Inactive Ballots by Overvotes,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0 Inactive Ballots by Skipped Rankings,0,,0,0,,0,0,,0,0,,0.0000,0.0000,,0.0000,0.0000,,0 Inactive Ballots by Exhausted Choices,0,,0,0,,0,0,,0,0,,0.0000,0.0000,,0.0000,0.0000,,0 diff --git a/src/test/resources/network/brightspots/rcv/test_data/minneapolis_multi_seat_threshold/minneapolis_multi_seat_threshold_expected_summary.csv b/src/test/resources/network/brightspots/rcv/test_data/minneapolis_multi_seat_threshold/minneapolis_multi_seat_threshold_expected_summary.csv index 23521a67..13a43222 100644 --- a/src/test/resources/network/brightspots/rcv/test_data/minneapolis_multi_seat_threshold/minneapolis_multi_seat_threshold_expected_summary.csv +++ b/src/test/resources/network/brightspots/rcv/test_data/minneapolis_multi_seat_threshold/minneapolis_multi_seat_threshold_expected_summary.csv @@ -24,7 +24,7 @@ E,6,20.68%,0,6,20.68%,0.0000,6.0000,20.68%,0.0000,6.0000,20.68%,-6.0000,0,0.0%,0 B,5,17.24%,0,5,17.24%,0,5,17.24%,2.0000,7.0000,24.13%,3.0000,10.0000,34.48%,-2.0000,8.0000,27.58%,0 F,3,10.34%,0,3,10.34%,0.0000,3.0000,10.34%,-3.0000,0,0.0%,0,0,0.0%,0,0,0.0%,0 D,2,6.89%,-2,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0 -Active Ballots,29,,,28,,,28.0000,,,28.0000,,,28.0000,,,24.0000,, +Active Ballots,29,,,28,,,28.0000,,,28.0000,,,28.0000,,,28.0000,, Current Round Threshold,8,,,8,,,8,,,8,,,8,,,8,, Inactive Ballots by Overvotes,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0 Inactive Ballots by Skipped Rankings,1,,1,2,,0,2,,0,2,,0.0000,2.0000,,0.0000,2.0000,,0 diff --git a/src/test/resources/network/brightspots/rcv/test_data/test_set_allow_only_one_winner_per_round/test_set_allow_only_one_winner_per_round_expected_summary.csv b/src/test/resources/network/brightspots/rcv/test_data/test_set_allow_only_one_winner_per_round/test_set_allow_only_one_winner_per_round_expected_summary.csv index 0db0e50d..edf4fddb 100644 --- a/src/test/resources/network/brightspots/rcv/test_data/test_set_allow_only_one_winner_per_round/test_set_allow_only_one_winner_per_round_expected_summary.csv +++ b/src/test/resources/network/brightspots/rcv/test_data/test_set_allow_only_one_winner_per_round/test_set_allow_only_one_winner_per_round_expected_summary.csv @@ -22,7 +22,7 @@ A,3,33.33%,-0.7499,2.2501,25.0%,0.0000,2.2501,25.0%,0.0000,2.2501,25.0%,0 B,3,33.33%,0.7497,3.7497,41.66%,-1.4996,2.2501,25.0%,0.0000,2.2501,25.0%,0 C,3,33.33%,0,3,33.33%,1.4994,4.4994,49.99%,-2.2493,2.2501,25.0%,0 D,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0 -Active Ballots,9,,,8.9998,,,8.9996,,,6.7503,, +Active Ballots,9,,,8.9998,,,8.9996,,,8.9994,, Current Round Threshold,2.2501,,,2.2501,,,2.2501,,,2.2501,, Inactive Ballots by Overvotes,0,,0,0,,0,0,,0,0,,0 Inactive Ballots by Skipped Rankings,0,,0,0,,0,0,,0,0,,0 diff --git a/src/test/resources/network/brightspots/rcv/test_data/test_set_allow_only_one_winner_per_round/test_set_allow_only_one_winner_per_round_expected_summary.json b/src/test/resources/network/brightspots/rcv/test_data/test_set_allow_only_one_winner_per_round/test_set_allow_only_one_winner_per_round_expected_summary.json index d8874ede..fed63d99 100644 --- a/src/test/resources/network/brightspots/rcv/test_data/test_set_allow_only_one_winner_per_round/test_set_allow_only_one_winner_per_round_expected_summary.json +++ b/src/test/resources/network/brightspots/rcv/test_data/test_set_allow_only_one_winner_per_round/test_set_allow_only_one_winner_per_round_expected_summary.json @@ -98,4 +98,4 @@ "totalNumBallots" : "9", "undervotes" : 0 } -} \ No newline at end of file +} diff --git a/src/test/resources/network/brightspots/rcv/test_data/test_set_multi_winner_fractional_threshold/test_set_multi_winner_fractional_threshold_expected_summary.csv b/src/test/resources/network/brightspots/rcv/test_data/test_set_multi_winner_fractional_threshold/test_set_multi_winner_fractional_threshold_expected_summary.csv index 460b3448..257b5afa 100644 --- a/src/test/resources/network/brightspots/rcv/test_data/test_set_multi_winner_fractional_threshold/test_set_multi_winner_fractional_threshold_expected_summary.csv +++ b/src/test/resources/network/brightspots/rcv/test_data/test_set_multi_winner_fractional_threshold/test_set_multi_winner_fractional_threshold_expected_summary.csv @@ -24,7 +24,7 @@ Candidate E Name,6,20.68%,0,6,20.68%,0.6559,6.6559,22.95%,0.0000,6.6559,22.95%,- Candidate B Name,5,17.24%,0,5,17.24%,0,5,17.24%,2.0937,7.0937,24.46%,3.0000,10.0937,34.8%,-2.8436,7.2501,25.0%,0 Candidate F Name,3,10.34%,0,3,10.34%,0.0937,3.0937,10.66%,-3.0937,0,0.0%,0,0,0.0%,0,0,0.0%,0 Candidate D Name,2,6.89%,-2,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0 -Active Ballots,29,,,28,,,27.9997,,,27.9997,,,27.6249,,,21.7503,, +Active Ballots,29,,,28,,,27.9997,,,27.9997,,,27.6249,,,27.6244,, Current Round Threshold,7.2501,,,7.2501,,,7.2501,,,7.2501,,,7.2501,,,7.2501,, Inactive Ballots by Overvotes,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0 Inactive Ballots by Skipped Rankings,1,,1,2,,0,2,,0,2,,0.1874,2.1874,,0.0000,2.1874,,0 diff --git a/src/test/resources/network/brightspots/rcv/test_data/test_set_multi_winner_whole_threshold/test_set_multi_winner_whole_threshold_expected_summary.csv b/src/test/resources/network/brightspots/rcv/test_data/test_set_multi_winner_whole_threshold/test_set_multi_winner_whole_threshold_expected_summary.csv index ab030dc8..b90c40da 100644 --- a/src/test/resources/network/brightspots/rcv/test_data/test_set_multi_winner_whole_threshold/test_set_multi_winner_whole_threshold_expected_summary.csv +++ b/src/test/resources/network/brightspots/rcv/test_data/test_set_multi_winner_whole_threshold/test_set_multi_winner_whole_threshold_expected_summary.csv @@ -24,7 +24,7 @@ Candidate B Name,5,17.24%,0,5,17.24%,0,5,17.24%,2.1111,7.1111,24.52%,2.1111,9.22 Candidate E Name,4,13.79%,0.7777,4.7777,16.47%,1.0000,5.7777,19.92%,0.0000,5.7777,19.92%,-5.7777,0,0.0%,0,0,0.0%,0 Candidate F Name,3,10.34%,0.1111,3.1111,10.72%,0.1111,3.2222,11.11%,-3.2222,0,0.0%,0,0,0.0%,0,0,0.0%,0 Candidate D Name,2,6.89%,0.1111,2.1111,7.27%,-2.1111,0,0.0%,0,0,0.0%,0,0,0.0%,0,0,0.0%,0 -Active Ballots,29,,,28.9999,,,27.9999,,,27.9999,,,27.5555,,,24.0000,, +Active Ballots,29,,,28.9999,,,27.9999,,,27.9999,,,27.5555,,,27.5549,, Current Round Threshold,8,,,8,,,8,,,8,,,8,,,8,, Inactive Ballots by Overvotes,0,,0,0,,0,0,,0,0,,0,0,,0,0,,0 Inactive Ballots by Skipped Rankings,1,,0,1,,1,2,,0,2,,0.2222,2.2222,,0.0000,2.2222,,0