Calculate loss by fraction in Meek STV
This commit is contained in:
parent
ca54b94953
commit
151c9e484e
|
@ -239,10 +239,14 @@ where
|
|||
}
|
||||
|
||||
// Recalculate transfers
|
||||
let mut checksum = N::new();
|
||||
for (candidate, count_card) in state.candidates.iter_mut() {
|
||||
count_card.transfers = &count_card.votes - &orig_candidates.get(candidate).unwrap().votes;
|
||||
checksum += &count_card.transfers;
|
||||
}
|
||||
state.exhausted.transfers = &state.exhausted.votes - &orig_exhausted.votes;
|
||||
checksum += &state.exhausted.transfers;
|
||||
state.loss_fraction.transfer(&-checksum);
|
||||
|
||||
// Remove intermediate logs on quota calculation
|
||||
state.logger.entries.clear();
|
||||
|
@ -294,8 +298,12 @@ where
|
|||
distribute_preferences(state);
|
||||
|
||||
// Recalculate transfers
|
||||
let mut checksum = N::new();
|
||||
for (candidate, count_card) in state.candidates.iter_mut() {
|
||||
count_card.transfers = &count_card.votes - &orig_candidates.get(candidate).unwrap().votes;
|
||||
checksum += &count_card.transfers;
|
||||
}
|
||||
state.exhausted.transfers = &state.exhausted.votes - &orig_exhausted.votes;
|
||||
checksum += &state.exhausted.transfers;
|
||||
state.loss_fraction.transfer(&-checksum);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue