Fix --round-votes being ignored in first stage
This commit is contained in:
parent
e3ca9fac47
commit
90971e976a
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user