Giter Site home page Giter Site logo

seamuscampbell / ranked-choice-voting Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 43 KB

IRV algorithm with a "no endorsement" option

Home Page: https://seamuscampbell.nyc

PHP 100.00%
instant-runoff instant-runoff-voting php ranked-choice ranked-choice-voting rcv-election no-endorsement

ranked-choice-voting's Introduction

Ranked Choice Voting

The issue with proprietary ranked choice voting systems is that there is no way for them to keep a "no endorsement" as a candidate from round to round as many organizations require. This program allows you to designate a candidate that cannot be eliminated (e.g. "no endorsement").

Algorithm

  • Put all candidates into a 2-dimensional array with the first dimension being the individual ballot and the second dimension being the order
  • After each round, see who has the most votes at the front of their rankings
  • If a candidate passes the win number (simple majority), remove them from contention
  • If the number of spots for winning candidates is full, stop
  • Otherwise, order the rankings and find the candidate with the fewest number of votes BUT if there is a "protected candidate" (e.g. "No Endorsement"), find the candidate with the second-fewest votes
  • Remove the candidate with the fewest votes from all of the ballots (i.e. every candidate goes up one rank)
  • Continue the process until the number of winners or number of remaining candidates equals the number of maximum winners
  • If the round has only two candidates left, declare the candidate with the most votes in that round the winner

Implementation

$myelection = new RankedChoiceVote($votes,'No Endorsement',"Assemblymember",1); $myelection ->conductElection(); The arguments for the constructor are as follows:

  1. A multi-dimensional array of the votes with the first dimension being the individual ballot and the second dimension being the order of candidates
  2. The name of the "protected candidate" (e.g. "No Endorsement")
  3. The name of the office being sought,
  4. The number of winners

License

Ranked Choice Voting by Seamus Campbell is licensed under Attribution-ShareAlike 4.0 International

ranked-choice-voting's People

Contributors

seamuscampbell avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.