pyRCV2: Open-source online counting for STV and other preferential voting systems
pyRCV2 is an application for counting various preferential voting elections.
pyRCV2 may be used in a number of different ways:
- as an online web application, no installation or special software required, at https://yingtongli.me/rcv/
- as a standalone Python command line application
- as a library within another Python application
pyRCV2 is a rewrite of pyRCV in order to enable more user-friendly use as a web application, and to refactor code to improve extensibility.
pyRCV2 accepts data in the BLT file format, and can count votes using:
- weighted inclusive Gregory STV (e.g. Scottish STV)
- unweighted inclusive Gregory STV (e.g. Australian Senate STV)
- exclusive Gregory STV (e.g. PRSA 1977 and ERS97)
- Meek STV
- Wright STV
pyRCV2 is highly customisable, including options for:
- different quotas and quota rules (e.g. exact Droop, Hare) or progressively reducing quota
- calculations using fixed-point arithmetic, guarded fixed-point (quasi-exact) or exact rational numbers
- different tie breaking rules (backwards, random, manual) with auditable deterministic random number generation
- multiple constraints (e.g. affirmative action rules)
- extensible API for other counting methods
BLT file format
pyRCV2 requires data to be input in the BLT file format, described in more detail here. Below is an example BLT file:
4 2 3 1 3 4 0 4 1 3 2 0 2 4 1 3 0 1 2 0 2 2 4 3 1 0 1 3 4 2 0 0 "Adam" "Basil" "Charlotte" "Donald" "Title"
The first line,
4 2, specifies that there are 4 candidates, with 2 winners to elect.
The second line,
3 1 3 4 0, is the first lot of ballot data. It indicates that 3 voters voted for the 1st candidate, then the 3rd candidate, then the 4th candidate (i.e. Adam > Charlotte > Donald). The third through seventh lines proceed similarly.
The end of the ballot data is signalled by the line
0. This is followed by the names of the 4 candidates, then the name of the election.
After preparing the BLT file as above, head to https://yingtongli.me/rcv/. Select the BLT file, and click Count. pyRCV2 will count the election and display the results in a count sheet.
By clicking Show advanced options, you can customise the options used for the count. A detailed explanation of the various options can be found here.
Once the count is complete, you can click Print result to generate a printable result report.