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").
- 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
The basic functionality works the same between the different languages (this was originally written in PHP and CodeConvert was used to translate it).
The arguments for the constructor are as follows:
- A multi-dimensional array/list of the votes with the first dimension being the individual ballot and the second dimension being the order of candidates
- The name of the "protected candidate" (e.g. "No Endorsement")
- The name of the office being sought,
- The number of winners
$myelection = new RankedChoiceVote($votes,'No Endorsement',"Assemblymember",1);
$myelection->conductElection();
rcv = RankedChoiceVote(
votes=votes,
protected_candidate="No Endorsement",
election_name="Assemblymember",
num_of_winners=1
)
rcv.conduct_election()
Ranked Choice Voting by Seamus Campbell is licensed under Attribution-ShareAlike 4.0 International