Fix rounding of subtransfers by parcel
Was erroneously segmenting transfers by outgoing parcel rather than incoming parcel
This commit is contained in:
parent
9fc0457844
commit
c140ef0a90
|
@ -241,7 +241,7 @@ where
|
||||||
let mut exhausted_ballots = N::new();
|
let mut exhausted_ballots = N::new();
|
||||||
let mut exhausted_votes = N::new();
|
let mut exhausted_votes = N::new();
|
||||||
|
|
||||||
for parcel in parcels {
|
for (parcel_num, parcel) in parcels.into_iter().enumerate() {
|
||||||
// Count next preferences
|
// Count next preferences
|
||||||
let result = super::next_preferences(state, parcel.votes);
|
let result = super::next_preferences(state, parcel.votes);
|
||||||
|
|
||||||
|
@ -253,7 +253,14 @@ where
|
||||||
exhausted_ballots += &result.exhausted.num_ballots;
|
exhausted_ballots += &result.exhausted.num_ballots;
|
||||||
exhausted_votes += &result.exhausted.num_ballots * &parcel.value_fraction;
|
exhausted_votes += &result.exhausted.num_ballots * &parcel.value_fraction;
|
||||||
|
|
||||||
parcels_next_prefs.push((parcel.value_fraction, parcel.source_order, result));
|
// Determine which column of the transfer table to use
|
||||||
|
let table_column_num = match opts.round_subtransfers {
|
||||||
|
RoundSubtransfersMode::ByValueAndSource => Some(parcel.source_order),
|
||||||
|
RoundSubtransfersMode::ByParcel => Some(parcel_num),
|
||||||
|
_ => Some(0)
|
||||||
|
};
|
||||||
|
|
||||||
|
parcels_next_prefs.push((parcel.value_fraction, table_column_num, result));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate and print surplus fraction
|
// Calculate and print surplus fraction
|
||||||
|
@ -320,16 +327,12 @@ where
|
||||||
surplus.clone(), surplus_fraction.clone(), surplus_numer.clone(), surplus_denom.clone()
|
surplus.clone(), surplus_fraction.clone(), surplus_numer.clone(), surplus_denom.clone()
|
||||||
);
|
);
|
||||||
|
|
||||||
for (value_fraction, source_order, result) in parcels_next_prefs {
|
for (value_fraction, table_column_num, result) in parcels_next_prefs {
|
||||||
for (candidate, entry) in result.candidates.into_iter() {
|
for (candidate, entry) in result.candidates.into_iter() {
|
||||||
// Record transfers
|
// Record transfers
|
||||||
transfer_table.add_transfers(
|
transfer_table.add_transfers(
|
||||||
&value_fraction,
|
&value_fraction,
|
||||||
match opts.round_subtransfers {
|
table_column_num,
|
||||||
RoundSubtransfersMode::ByValueAndSource => Some(source_order),
|
|
||||||
RoundSubtransfersMode::ByParcel => None, // Force new column per parcel
|
|
||||||
_ => Some(0)
|
|
||||||
},
|
|
||||||
candidate,
|
candidate,
|
||||||
&entry.num_ballots
|
&entry.num_ballots
|
||||||
);
|
);
|
||||||
|
@ -366,11 +369,7 @@ where
|
||||||
// Record exhausted votes
|
// Record exhausted votes
|
||||||
transfer_table.add_exhausted(
|
transfer_table.add_exhausted(
|
||||||
&value_fraction,
|
&value_fraction,
|
||||||
match opts.round_subtransfers {
|
table_column_num,
|
||||||
RoundSubtransfersMode::ByValueAndSource => Some(source_order),
|
|
||||||
RoundSubtransfersMode::ByParcel => None, // Force new column per parcel
|
|
||||||
_ => Some(0)
|
|
||||||
},
|
|
||||||
&result.exhausted.num_ballots
|
&result.exhausted.num_ballots
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue