Prefer election by quota/VRE to early bulk election

This commit is contained in:
RunasSudo 2021-07-28 00:12:57 +10:00
parent a5a61731b5
commit 49feb09bf8
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
1 changed files with 7 additions and 7 deletions

View File

@ -846,13 +846,6 @@ fn elect_sure_winners<'a, N: Number>(state: &mut CountState<'a, N>, opts: &STVOp
/// Declare elected all candidates meeting the quota, and (if enabled) any candidates who can be early bulk elected because they have sufficiently many votes
fn elect_hopefuls<'a, N: Number>(state: &mut CountState<'a, N>, opts: &STVOptions) -> Result<bool, STVError> {
// Determine if early bulk election can be effected
if opts.early_bulk_elect {
if elect_sure_winners(state, opts)? {
return Ok(true);
}
}
let mut cands_meeting_quota: Vec<(&Candidate, &CountCard<N>)> = state.election.candidates.iter() // Present in order in case of tie
.map(|c| (c, &state.candidates[c]))
.filter(|(_, cc)| { (cc.state == CandidateState::Hopeful || cc.state == CandidateState::Guarded) && meets_vre(state, cc, opts) })
@ -918,6 +911,13 @@ fn elect_hopefuls<'a, N: Number>(state: &mut CountState<'a, N>, opts: &STVOption
}
}
// Determine if early bulk election can be effected
if opts.early_bulk_elect {
if elect_sure_winners(state, opts)? {
return Ok(true);
}
}
return Ok(elected);
}