prefvote

PrefVote LAB (Legacy Algorithm Base) libraries

PrefVote is a project to promote preference voting. It includes implementations of several ranked-choice voting methods and algorithms. It was originally derived from the Vote::STV software written by Ian Kluft in Perl in 1999, with periodic maintenance over the years.

Since the project’s original language Perl has strengths in prototyping, that’s the reference implementation in this project for multiple language implementations. With translations to multiple programming languages, the library is designed with a common test suite among the different implementations to verify proper functioning.

Example voting result from test suite

This is an example result from Single Transferable Vote (STV), Schulze and Ranked Pairs using the same file in the test suite with each algorithm. 250 ballots were randomly generated. So there’s no actual meaning to the result except testing the software.

Notes about all the following examples:

Single Transferable Vote (STV) results from the example data

Results: Test Vote 004

1 seat available ∣ 250 ballots

Abbreviation Name/description Result
FACTIOUS factious/divisive 1/selected
EVIL evil villain 2/placed
CHAOTIC chaotic unpredictable 3/eliminated
ABNORMAL abnormal and antisocial 4/eliminated
BORING boring as anything 5/eliminated
DYSFUNCTIONAL dysfunctional incompetent 6/eliminated
Round # Quota FACTIOUS EVIL CHAOTIC ABNORMAL BORING DYSFUNCTIONAL
1 125 68 54 36 31 33 28 ❌
2 124.5 75 58 45 36 35 ❌
3 122 78 69 51 46 ❌
4 118.5 90 81 66 ❌
5 114 118 ✅ 110
6 56.50847 113.01695 ✅

Notes about the STV example:

Schulze method results from the example data

Results: Test Vote 004

1 seat available ∣ 250 ballots

Abbreviation Name/description Result
FACTIOUS factious/divisive 1/selected
EVIL evil villain 2/placed
CHAOTIC chaotic unpredictable 3/placed
DYSFUNCTIONAL dysfunctional incompetent 4/placed
ABNORMAL abnormal and antisocial 5/placed
BORING boring as anything 6/placed

Margin-of-victory matrix

FACTIOUS EVIL CHAOTIC DYSFUNCTIONAL ABNORMAL BORING
FACTIOUS 🛇 7 ✅ 57 ✅ 67 ✅ 74 ✅ 79 ✅
EVIL -7 ❌ 🛇 48 ✅ 68 ✅ 68 ✅ 64 ✅
CHAOTIC -57 ❌ -48 ❌ 🛇 16 ✅ 5 ✅ 15 ✅
DYSFUNCTIONAL -67 ❌ -68 ❌ -16 ❌ 🛇 13 ✅ 5 ✅
ABNORMAL -74 ❌ -68 ❌ -5 ❌ -13 ❌ 🛇 11 ✅
BORING -79 ❌ -64 ❌ -15 ❌ -5 ❌ -11 ❌ 🛇

Notes about the Schulze example:

Ranked Pairs voting results from the example data

Results: Test Vote 004

1 seat available ∣ 250 ballots

Abbreviation Name/description Result
FACTIOUS factious/divisive 1/selected
EVIL evil villain 2/placed
CHAOTIC chaotic unpredictable 3/placed
DYSFUNCTIONAL dysfunctional incompetent 4/placed
ABNORMAL abnormal and antisocial 5/placed
BORING boring as anything 6/placed

Margin-of-victory matrix

FACTIOUS EVIL CHAOTIC DYSFUNCTIONAL ABNORMAL BORING
FACTIOUS 🛇 7 ✅🔒 57 ✅🔒 67 ✅🔒 74 ✅🔒 79 ✅🔒
EVIL -7 ❌ 🛇 48 ✅🔒 68 ✅🔒 68 ✅🔒 64 ✅🔒
CHAOTIC -57 ❌ -48 ❌ 🛇 16 ✅🔒 5 ✅🔒 15 ✅🔒
DYSFUNCTIONAL -67 ❌ -68 ❌ -16 ❌ 🛇 13 ✅🔒 5 ✅🔒
ABNORMAL -74 ❌ -68 ❌ -5 ❌ -13 ❌ 🛇 11 ✅🔒
BORING -79 ❌ -64 ❌ -15 ❌ -5 ❌ -11 ❌ 🛇

Notes about the Ranked Pairs example: