Add validation test for Church of England rules
This commit is contained in:
parent
cb97a44b73
commit
31cdf3d99d
@ -22,7 +22,7 @@ The preset dropdown allows you to choose from a hardcoded list of preloaded STV
|
|||||||
| [ERS97](https://www.electoral-reform.org.uk/latest-news-and-research/publications/how-to-conduct-an-election-by-the-single-transferable-vote-3rd-edition/) | More complex rules designed for hand counting, using the exclusive Gregory method. | [E6] | ✓ |
|
| [ERS97](https://www.electoral-reform.org.uk/latest-news-and-research/publications/how-to-conduct-an-election-by-the-single-transferable-vote-3rd-edition/) | More complex rules designed for hand counting, using the exclusive Gregory method. | [E6] | ✓ |
|
||||||
| • ERS76 | Former rules from the 1976 2nd edition. | [E6] [E7] | ✓ |
|
| • ERS76 | Former rules from the 1976 2nd edition. | [E6] [E7] | ✓ |
|
||||||
| • ERS73 | Former rules from the 1973 1st edition. | [E6] [E7] | |
|
| • ERS73 | Former rules from the 1973 1st edition. | [E6] [E7] | |
|
||||||
| Church of England | Rules from the Church of England [*Single Transferable Vote Rules 2020*](https://www.churchofengland.org/sites/default/files/2020-02/STV%20Rules%202020%20-%20final.pdf), similar to ERS73. | |
|
| Church of England | Rules from the Church of England [*Single Transferable Vote Rules 2020*](https://www.churchofengland.org/sites/default/files/2020-02/STV%20Rules%202020%20-%20final.pdf), similar to ERS73. | | ✓ |
|
||||||
|
|
||||||
Exceptions:
|
Exceptions:
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ STV-counting software is frequently validated empirically by comparing the resul
|
|||||||
| ERS97 | [Reverse engineered ballot papers for the ERS97 model election](https://yingtongli.me/blog/2021/01/04/ers97.html) | [Model result](https://www.electoral-reform.org.uk/latest-news-and-research/publications/how-to-conduct-an-election-by-the-single-transferable-vote-3rd-edition/#sub-section-24) (official) | ✓ |
|
| ERS97 | [Reverse engineered ballot papers for the ERS97 model election](https://yingtongli.me/blog/2021/01/04/ers97.html) | [Model result](https://www.electoral-reform.org.uk/latest-news-and-research/publications/how-to-conduct-an-election-by-the-single-transferable-vote-3rd-edition/#sub-section-24) (official) | ✓ |
|
||||||
| ERS97 | [Joe Otten/eSTV ballot papers for the ERS97 model election](https://web.archive.org/web/20020606014623/http://estv.otten.co.uk/) | [Model result](https://www.electoral-reform.org.uk/latest-news-and-research/publications/how-to-conduct-an-election-by-the-single-transferable-vote-3rd-edition/#sub-section-24) (official) | ✓ |
|
| ERS97 | [Joe Otten/eSTV ballot papers for the ERS97 model election](https://web.archive.org/web/20020606014623/http://estv.otten.co.uk/) | [Model result](https://www.electoral-reform.org.uk/latest-news-and-research/publications/how-to-conduct-an-election-by-the-single-transferable-vote-3rd-edition/#sub-section-24) (official) | ✓ |
|
||||||
| ERS76 | Ballot papers adapted from Joe Otten/eSTV ERS97 papers | Model result (official) | ✓ |
|
| ERS76 | Ballot papers adapted from Joe Otten/eSTV ERS97 papers | Model result (official) | ✓ |
|
||||||
|
| Church of England | Joe Otten/eSTV ballot papers for the ERS97 model election | [eSTV 1.47](https://web.archive.org/web/20040607021930/http://www.electoral-reform.org.uk/votingsystems/estv.htm) | ✓ |
|
||||||
|
|
||||||
# References
|
# References
|
||||||
|
|
||||||
|
39
tests/coe.rs
Normal file
39
tests/coe.rs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/* OpenTally: Open-source election vote counting
|
||||||
|
* Copyright © 2021 Lee Yingtong Li (RunasSudo)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
mod utils;
|
||||||
|
|
||||||
|
use opentally::numbers::Rational;
|
||||||
|
use opentally::stv;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ers97_coe_rational() {
|
||||||
|
let stv_opts = stv::STVOptionsBuilder::default()
|
||||||
|
.round_surplus_fractions(Some(2))
|
||||||
|
.round_values(Some(2))
|
||||||
|
.round_votes(Some(2))
|
||||||
|
.round_quota(Some(2))
|
||||||
|
.sum_surplus_transfers(stv::SumSurplusTransfersMode::PerBallot)
|
||||||
|
.quota_criterion(stv::QuotaCriterion::GreaterOrEqual)
|
||||||
|
.surplus(stv::SurplusMethod::EG)
|
||||||
|
.transferable_only(true)
|
||||||
|
.exclusion(stv::ExclusionMethod::ByValue)
|
||||||
|
.defer_surpluses(true)
|
||||||
|
.build().unwrap();
|
||||||
|
|
||||||
|
utils::read_validate_election::<Rational>("tests/data/ers97_coe.csv", "tests/data/ers97.blt", stv_opts, None, &["nt"]);
|
||||||
|
}
|
14
tests/data/ers97_coe.csv
Normal file
14
tests/data/ers97_coe.csv
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
Stage:,1,,2,,4,,6,,8,,9,,10,
|
||||||
|
Comment:,First preferences,,Surplus of Smith,,Exclusion of Monk,,Exclusion of Glazier,,Exclusion of Wright,,Surplus of Carpenter,,Exclusion of Abbot,
|
||||||
|
Smith,134,EL,107.58,EL,107.58,EL,107.58,EL,107.58,EL,107.58,EL,107.58,EL
|
||||||
|
Duke,105,H,106.68,H,108.68,EL,108.68,EL,108.68,EL,108.68,EL,108.68,EL
|
||||||
|
Prince,91,H,91.63,H,95.63,H,98.47,H,102.31,H,104.31,H,104.31,EL
|
||||||
|
Freeman,90,H,92.94,H,93.94,H,96.99,H,99.62,H,100.62,H,101.62,EL
|
||||||
|
Carpenter,81,H,88.14,H,88.35,H,104.35,H,122.35,EL,107.58,EL,107.58,EL
|
||||||
|
Baron,64,H,64.21,H,64.21,H,65.84,H,68.26,H,68.26,H,79.26,H
|
||||||
|
Abbot,59,H,59.84,H,64.84,H,66.47,H,67.1,H,67.1,H,2.1,EX
|
||||||
|
Vicar,55,H,55.21,H,65.21,H,67.47,H,70.31,H,70.31,H,111.31,EL
|
||||||
|
Wright,27,H,32.25,H,32.25,H,32.25,H,0,EX,0,EX,0,
|
||||||
|
Glazier,24,H,30.51,H,30.51,H,0,EX,0,EX,0,EX,0,
|
||||||
|
Monk,23,H,23.42,H,0,EX,0,EX,0,EX,0,EX,0,
|
||||||
|
Non-transferable,0,,0.59,,1.8,,4.9,,6.79,,18.56,,30.56,
|
|
BIN
tests/data/ers97_coe.ods
Normal file
BIN
tests/data/ers97_coe.ods
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user