Implement --bulk-exclude and --defer-surpluses in web UI

This commit is contained in:
RunasSudo 2021-06-09 12:42:47 +10:00
parent 79f0f55942
commit 990704a56a
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
3 changed files with 19 additions and 17 deletions

View File

@ -164,11 +164,11 @@
d.p.
</label>
</div>
<!--<div class="col-12 subheading">
<div class="col-12 subheading">
Count optimisations:
</div>
<label class="col-6">
<input type="checkbox" id="chkBulkElection" checked>
<input type="checkbox" id="chkBulkElection" checked disabled>
Bulk election
</label>
<label class="col-6">
@ -178,7 +178,7 @@
<label class="col-12">
<input type="checkbox" id="chkDeferSurpluses">
Defer surpluses
</label>-->
</label>
<div class="col-12 subheading">
Rounding:
</div>

View File

@ -102,6 +102,8 @@ async function clickCount() {
document.getElementById('selSurplus').value,
document.getElementById('selPapers').value == 'transferable',
document.getElementById('selExclusion').value,
document.getElementById('chkBulkExclusion').checked,
document.getElementById('chkDeferSurpluses').checked,
parseInt(document.getElementById('txtPPDP').value),
];
@ -293,9 +295,9 @@ function changePreset() {
document.getElementById('selQuotaCriterion').value = 'geq';
document.getElementById('selQuota').value = 'droop';
document.getElementById('selQuotaMode').value = 'static';
//document.getElementById('chkBulkElection').checked = true;
//document.getElementById('chkBulkExclusion').checked = false;
//document.getElementById('chkDeferSurpluses').checked = false;
document.getElementById('chkBulkElection').checked = true;
document.getElementById('chkBulkExclusion').checked = false;
document.getElementById('chkDeferSurpluses').checked = false;
document.getElementById('selNumbers').value = 'fixed';
document.getElementById('txtDP').value = '5';
document.getElementById('txtPPDP').value = '2';
@ -313,9 +315,9 @@ function changePreset() {
document.getElementById('selQuotaCriterion').value = 'geq';
document.getElementById('selQuota').value = 'droop';
document.getElementById('selQuotaMode').value = 'static';
//document.getElementById('chkBulkElection').checked = true;
//document.getElementById('chkBulkExclusion').checked = true;
//document.getElementById('chkDeferSurpluses').checked = false;
document.getElementById('chkBulkElection').checked = true;
document.getElementById('chkBulkExclusion').checked = true;
document.getElementById('chkDeferSurpluses').checked = false;
document.getElementById('selNumbers').value = 'fixed';
document.getElementById('txtDP').value = '5';
document.getElementById('txtPPDP').value = '0';
@ -334,9 +336,9 @@ function changePreset() {
document.getElementById('selQuotaCriterion').value = 'geq';
document.getElementById('selQuota').value = 'droop';
document.getElementById('selQuotaMode').value = 'static';
//document.getElementById('chkBulkElection').checked = true;
//document.getElementById('chkBulkExclusion').checked = false;
//document.getElementById('chkDeferSurpluses').checked = true;
document.getElementById('chkBulkElection').checked = true;
document.getElementById('chkBulkExclusion').checked = false;
document.getElementById('chkDeferSurpluses').checked = true;
document.getElementById('selNumbers').value = 'fixed';
document.getElementById('txtDP').value = '5';
document.getElementById('txtPPDP').value = '3';
@ -357,9 +359,9 @@ function changePreset() {
document.getElementById('selQuotaCriterion').value = 'geq';
document.getElementById('selQuota').value = 'droop_exact';
document.getElementById('selQuotaMode').value = 'ers97';
//document.getElementById('chkBulkElection').checked = true;
//document.getElementById('chkBulkExclusion').checked = true;
//document.getElementById('chkDeferSurpluses').checked = true;
document.getElementById('chkBulkElection').checked = true;
document.getElementById('chkBulkExclusion').checked = true;
document.getElementById('chkDeferSurpluses').checked = true;
document.getElementById('selNumbers').value = 'fixed';
document.getElementById('txtDP').value = '5';
document.getElementById('txtPPDP').value = '2';

View File

@ -550,7 +550,7 @@ fn elect_meeting_quota<N: Number>(state: &mut CountState<N>, opts: &STVOptions)
}
}
fn can_defer_surpluses<N: Number>(state: &CountState<N>, opts: &STVOptions, has_surplus: &Vec<(&&Candidate, &CountCard<N>)>, total_surpluses: &N) -> bool
fn can_defer_surpluses<N: Number>(state: &CountState<N>, opts: &STVOptions, total_surpluses: &N) -> bool
where
for<'r> &'r N: ops::Sub<&'r N, Output=N>
{
@ -593,7 +593,7 @@ where
if has_surplus.len() > 0 {
// Determine if surplues can be deferred
if opts.defer_surpluses {
if can_defer_surpluses(state, opts, &has_surplus, &total_surpluses) {
if can_defer_surpluses(state, opts, &total_surpluses) {
state.logger.log_literal(format!("Distribution of surpluses totalling {:.2} votes will be deferred.", total_surpluses));
return false;
}