GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ikluft/prefvote: PrefVote is to promote ranked-choice preference voting algorithms. Updated with Condorcet voting algorithms, it's descended from the Vote::STV software which I wrote in Perl originally in 1998 and used by multiple clubs and non-profit organizations over the years for polls and elections.

BranchesTags
Open more actions menu

Latest commit

 

History

774 Commits
774 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
doc
doc
 
 
lab
lab
 
 
src
src
 
 
test
test
 
 
.gitignore
.gitignore
 
 
AI_POLICY.md
AI_POLICY.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

PrefVote: Preference Voting library

by Ian Kluft

PrefVote is a project to promote ranked preference voting.

Implementations of several ranked-choice voting methods and algorithms are included in the "LAB" (Legacy Algorithm Base) directory. (Yes, it's supposed to also sound like laboratory.) The Single Transferable Vote (STV) implementation is descended from the Vote::STV software I wrote in Perl in 1999 for the Silicon Valley Linux User Group (SVLUG) elections, and then with periodic maintenance over the years. Implementation and experimentation with Condorcet-based algorithms Schulze and Ranked Pairs helped me better understand the flaws of STV in handling close elections, and why it has fallen out of favor among those looking for better voting algorithms.

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.

The legacy algorithms are in the lab directory, where the reference implementation in Perl is instrumented for study and testing. In addition to the older voting algorithms, a new algorithm "KR2" (Kluft Rank-Rate) is under experimentation.

Project-wide documentation is in the doc directory.

About preference voting algorithms

The original Vote::STV software implemented the single transferable vote algorithm, which is a subset of ranked-choice voting, also called preference voting. PrefVote has expanded into a library of multiple voting method implementations all based on ranked choice.

STV: Single Transferable Vote

STV was the first implemented voting method in PrefVote since it was the original implementation as Vote::STV back to 1998. But STV has largely fallen out of favor because studies of voting methods found it lacking on some desirable characteristics, particularly some quirks in close elections in how votes transfer upon elimination of losing candidates. STV was retained while modernizing the code to develop testing infrastructure.

Condorcet methods

No voting method can be perfect, due to a long list of desirable properties, some of which turn out to be in conflict according to Arrow's Impossibility Theorem. Given that there is no perfect voting method, it's important to have agreement among a community on which method it uses. Methods which meet Condorcet requirements make comparisons between each pair of candidates and picks a winner who beats all other candidates in pairwise comparisons, if such a winner exists. Think of a sports round-robin tournament, which is analagous. Condorcet methods, like round-robin tournaments, differ in how to handle cases when there isn't a clear Condorcet or tournament winner. Cycles can happen where a subset of leading candidates fail to beat the others in that subset.

Condorcet-compliant methods implemented in PrefVote are Schulze, Ranked Pairs and KR2 (Kluft Rank-Rate).

Schulze Method

The second voting method implemented in PrefVote was the Schulze algorithm (see full definition paper). The method was designed by Marcus Schulze in 1997 to compute a graph out of voter preferences among candidates and pick the ones preferred over all others. An ordering of all the candidates can be computed over multiple rounds after removing the previous round's winner(s).

Ranked Pairs (Tideman) Method

The next algorithm implemented in PrefVote was Ranked Pairs. It was designed by Nicolaus Tideman in 1987. It tallies ranked choice ballots into pairwise comparisons among all choices/candidates. The pairs are sorted by margin of victory from largest margin down to ties at zero. Pairs are "locked" in for consideration of the final order of candidates if they do not conflict with locked pairs with larger margins. Candidates are then ordered starting who beats all other candidates, then each who beat all remaining candidates.

KR2: Kluft Rank-Rate Method

This voting method came as a result of my development of PrefVote, getting to compare the various ranked-choice and Condorcet voting methods. While the Ranked Pairs/Tideman and Schulze methods are technically sound, graph theory is too complex to explain to the public. In search of a simpler method which is still also technically sound, I developed the Kluft Rank-Rate Method (KR2).

  • Condorcet pairwise comparisons between choices (like a round-robin tournament) are still done like other Condorcet methods.
  • Ranked ballots are each processed by two different methods and sorted by those criteria:
    • The primary sorting criteria is the Copeland Score, wins minus losses from the Condorcet pairwise comparisons.
    • The secondary sorting criteria, when there are ties in the primary, is the average choice rank (ACR) of each choice's positions on each ballot. This tie-breaker is a positional or cardinal voting method.

Each poll may be configured (before voting begins) to allow voters to rate choices by moving them into boxes for support and oppose, or maybe also neutral, strong support and strong oppose. By default there are no rating levels and voting is handled like other ranked-choice algorithms. If ratings are used, the rating boundaries become part of each ballot and show divisions by support and opposition through the boundaries' places in the final ranking.

For example, in a KR2 Level 2 poll, there are 2 levels support and oppose, divided by the "neutral" rating boundary marker. Any choice which ranks higher than the neutral marker is considered supported by the community. Any choice which ranks lower than the neutral marker is considered opposed by the community, and eliminated in the results.

The most significant new developments of the KR2 algorithm are summarized as follows:

  • insertion of rating boundaries among the choices on ranked ballots
  • Condorcet paradox resolution (tie-breaking) using positional voting (average choice rank) as a secondary corting criteria

Future programming language implementations

After the reference implementation in Perl, next up for language implementations will be Rust.

Preference voting online resources

Here is general information about preference voting algorithms.

  • ElectoWiki, electoral systems wiki
  • Wiki articles
    • Comparison: electowiki wikipedia
    • voting system criteria: electowiki wikipedia
    • Ranked voting: electowiki wikipedia
    • Instant-runoff voting: electowiki wikipedia
    • Condorcet method: electowiki wikipedia
      • Condorcet Paradox: electowiki wikipedia
      • Smith set: electowiki wikipedia
      • Round-robin tournament: electowiki wikipedia
      • Tournament (graph theory): electowiki wikipedia
    • Schulze method: electowiki wikipedia
    • Ranked Pairs: electowiki wikipedia
    • KR2 Kluft Rank-Rate: KR2 docs
      • Copeland Score: electowiki wikipedia
      • positional voting method: electowiki wikipedia
      • cardinal voting method: electowiki wikipedia
  • FairVote, nonpartisan group promoting ranked choice voting (RCV) and proportional representation (PR)
  • "What is Democracy?" video series, Prof HL Bray, Duke University
  • "Voting and Elections", American Mathematical Society articles
  • papers defining Schulze voting method, Marcus Schulze, posted 2004-2012
  • Condorcet Voting, part of Democracy Reform Primer Series, University of Chicago Center for Effective Government
  • Voting Methods, Stanford Encyclopedia of Philosophy

Input file format

The original and primary input file format of PrefVote is YAML with a predefined data structure. There is documentation for the data format. Also, when PrefVote is used as a library any data can be submitted by calling functions directly.

In support of a proposed Open Source standard for preference voting systems, PrefVote also supports the Condorcet Election Format (CEF), or CEF. There is documentation for PrefVote's support for CEF input files.

Tie-breaking modifications to algorithms

PrefVote modifies all the algorithms in one way. It adds a tie-breaking factor using the average ballot-position ranking of a choice/candidate. It started as experimentation with intuition that the average ranking of a choice was indicative of the will of the voters. Though it wouldn't be acceptable as a primary factor because averages don't have quantitative data - and quantitative data is paramount to meeting the expectation that the candidate with the most votes must be the winner. Test runs show that it approximates Condorcet results fairly well and converges with Condorcet by around 100 random ballots. It didn't even need to be that close to Condorcet to convey meaning about voter's preferences. That's because this tie-breaking method restores ballot-position ordering information which Condorcet lacks.

The primary voting method in any PrefVote poll must meet the majority criterion. Condorcet methods (Schulze, Ranked Pairs and KR2) and STV (the original algorithm PrefVote was started with in 1998) meet the criterion.

PrefVote's Core module from which all the voting methods inherit common code is not a voting method itself. In performing the counting of average choice ranking (ACR) for other methods to use for tie-breaking, it contains results which can be displayed for testing purposes. Since it only uses average ranking, it really must not be used for actual voting. There is a principle in voting that every vote counts. That means quantitative factors must be the primary ordering for results. ACR turns out to be well-suited to be a second sorting factor for tie-breaking. That's because with all other things being equal in the case of a tie, the voter ranking positions are data that weren't used by Condorcet comparison.

ACR isn't a Condorcet-compliant method on its own, which PrefVote requires, except having grandfathered in STV. It's both a positional and cardinal voting method, equivalent to Score Voting but with the number order reversed (1 = 1st place, etc). Positional and cardinal methods fail the majority criterion. But it is acceptable as a tie-breaker because it pulls positional information from the ballots which complements Condorcet methods.

In case of a Condorcet paradox (tie), then ACR becomes useful as a tie-breaker method. It uses the voters' average ranking order to break a Condorcet tie. Condorcet uses rankings to find the majority preference when one exists. But in close elections it's possible for no Condorcet winner to exist. All Condorcet-based algorithms augment it with a tie-breaking method. The evolution of PrefVote to include ACR influenced the development of the KR2 algorithm as a tie-breaker which preserves voter preferences and can be explained to the public.

About

PrefVote is to promote ranked-choice preference voting algorithms. Updated with Condorcet voting algorithms, it's descended from the Vote::STV software which I wrote in Perl originally in 1998 and used by multiple clubs and non-profit organizations over the years for polls and elections.

Topics

condorcetranked-choiceranked-choice-votingranked-pairsrcvschulzeschulze-methodsingle-transferable-votestvvotevoting

Resources

Readme
Apache-2.0 license
Activity

Stars

4 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.