diff --git a/src/stv/meek.rs b/src/stv/meek.rs index 50ad88d..ce79cd9 100644 --- a/src/stv/meek.rs +++ b/src/stv/meek.rs @@ -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); }