From 509768c07190e5e03662c910fe8fb2d097c47915 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Tue, 29 Dec 2020 02:43:37 +1100 Subject: [PATCH] Separate out parcel handling logic --- docs/options.md | 20 ++- html/index.html | 15 +- html/index.js | 21 ++- html/worker.js | 4 +- pyRCV2/cli/stv.py | 16 +- pyRCV2/method/base_stv.py | 335 ++++++++++++++++++++++++++------------ pyRCV2/method/parcels.py | 177 -------------------- pyRCV2/model.py | 8 +- pyRCV2/transcrypt.py | 2 +- 9 files changed, 298 insertions(+), 300 deletions(-) delete mode 100644 pyRCV2/method/parcels.py diff --git a/docs/options.md b/docs/options.md index 3965293..4072891 100644 --- a/docs/options.md +++ b/docs/options.md @@ -49,7 +49,7 @@ This dropdown allows you to select how numbers (vote totals, etc.) are represent * Native float: Numbers are represented as floating-point numbers. This is fast, but not recommended as unexpectedly large rounding errors may be introduced in some circumstances. * Native int: Numbers are represented as integers. -Note that, when unweighted inclusive Gregory surplus transfers are used (see *Method*), ballot weights are always represented internally as fractions, while candidate totals are represented according to this option. +Note that, during some calculations, in order to reduce rounding errors, ballot weights and intermediate may be represented internally as fractions irrespective of this option. ## Surplus order (-s/--surplus-order) @@ -64,18 +64,26 @@ Some STV counting rules provide, for example, that ‘no surplus shall be transf This dropdown allows you to select how ballots are transferred during surplus transfers or exclusions. The 2 recommended methods are: -* Weighted inclusive Gregory: During surplus transfers, a transfer value is calculated as the candidate's excess votes divided by the candidate's votes. Ballot weights are multiplied by the transfer value. +* Weighted inclusive Gregory: During surplus transfers, all applicable ballot papers of the transferring candidate are examined. Transfers are weighted according to the weights of the ballot papers. * Wright STV: Same as weighted inclusive Gregory, but when a candidate is excluded, the count is reset from the beginning (minus the excluded candidate). Other methods are supported, but not recommended: -* Unweighted inclusive Gregory: During surplus transfers, a transfer value is calculated as the candidate's excess votes divided by the candidate's ballot papers. Ballot weights are set to the transfer value. -* Exclusive Gregory (by parcel): During surplus transfers, only transferable papers in the ‘last bundle’ are examined. During exclusions, transfers are performed ‘parcel by parcel’, and each parcel forms a separate stage, i.e. if a parcel allows another candidate to be elected, no further transfers are made to that candidate. - -Note that, when unweighted inclusive Gregory or exclusive Gregory surplus transfers are used, ballot weights are always represented internally as fractions, while candidate totals are represented according to the *Numbers* option. +* Unweighted inclusive Gregory: During surplus transfers, all applicable ballot papers of the transferring candidate are examined. Transfers are not weighted, and each ballot paper has equal value in the calculation. +* Exclusive Gregory (last bundle): During surplus transfers, only the ballot papers received in the last transfer are examined. Transfers are not weighted. Other surplus transfer methods, such as non-fractional transfers (e.g. random sample) are not supported at this time. +### Papers to examine in surplus transfer (--transferable-only) + +* Include non-transferable papers (default): When this option is selected, all ballot papers of the transferring candidate are examined. Non-transferable papers are always exhausted at the relevant transfer values. +* Use transferable papers only (CLI: --transferable-only): When this option is selected, only transferable papers of the transferring candidate are examined. Non-transferable papers are exhausted only if the value of the transferable papers is less than the surplus. + +### Exclusion method (--exclusion) + +* Exclude in one round (default): When excluding a candidate, transfer all their ballot papers in one round. +* Exclude by parcel (by order): When excluding a candidate, transfer their ballot papers one parcel at a time, in their order each was received. Each parcel forms a separate round, i.e. if a transfer allows another candidate to meet the quota criterion, no further papers are transferred to that candidate. + ## Ties (-t/--ties) This dropdown allows you to select how ties (in surplus transfer or exclusion) are broken. The options are: diff --git a/html/index.html b/html/index.html index 8a3783d..3629a9e 100644 --- a/html/index.html +++ b/html/index.html @@ -105,10 +105,23 @@ + +