Fix --round-votes being ignored in first stage

This commit is contained in:
RunasSudo 2021-09-04 23:54:28 +10:00
parent e3ca9fac47
commit 90971e976a
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 10 additions and 3 deletions

View File

@ -28,7 +28,8 @@ use std::collections::HashMap;
use std::ops; use std::ops;
/// Distribute first preference votes according to the Gregory method /// Distribute first preference votes according to the Gregory method
pub fn distribute_first_preferences<N: Number>(state: &mut CountState<N>) { pub fn distribute_first_preferences<N: Number>(state: &mut CountState<N>, opts: &STVOptions)
{
let votes = state.election.ballots.iter().map(|b| Vote { let votes = state.election.ballots.iter().map(|b| Vote {
ballot: b, ballot: b,
up_to_pref: 0, up_to_pref: 0,
@ -45,7 +46,13 @@ pub fn distribute_first_preferences<N: Number>(state: &mut CountState<N>) {
}; };
let count_card = state.candidates.get_mut(candidate).unwrap(); let count_card = state.candidates.get_mut(candidate).unwrap();
count_card.parcels.push(parcel); count_card.parcels.push(parcel);
count_card.transfer(&entry.num_ballots);
let mut vote_transfers = entry.num_ballots.clone();
if let Some(dps) = opts.round_votes {
vote_transfers.floor_mut(dps);
}
count_card.transfer(&vote_transfers);
count_card.ballot_transfers += entry.num_ballots; count_card.ballot_transfers += entry.num_ballots;
} }

View File

@ -749,7 +749,7 @@ where
{ {
match opts.surplus { match opts.surplus {
SurplusMethod::WIG | SurplusMethod::UIG | SurplusMethod::EG | SurplusMethod::Cincinnati | SurplusMethod::Hare => { SurplusMethod::WIG | SurplusMethod::UIG | SurplusMethod::EG | SurplusMethod::Cincinnati | SurplusMethod::Hare => {
gregory::distribute_first_preferences(state); gregory::distribute_first_preferences(state, opts);
} }
SurplusMethod::Meek => { SurplusMethod::Meek => {
meek::distribute_first_preferences(state, opts); meek::distribute_first_preferences(state, opts);