Plurality
A plurality voting system selects the candidate who has the greatest first position preferences. Formally, let $C = \{c_i\}_{i\in \mathcal{I}}$ be a set of $m$ candidates, where $\mathcal{I}=\{1,\dots,m\}$ is the index set. Let $r_j(c_i)$ be a function which counts the number of $j^{th}$ position preferences for candidate $i$. The winning candidate is given by
\[c_k = \underset{c_i \in C}{\mathrm{argmax}} r_1(c_i).\]
Example Usage
The following examples illustrate some ways in which the plurality system can be used in RankChoiceVoting.jl. To begin, let's generate some synthetic rank choice votes for candidates $C = \{c,k,m,n\}$ from 100 voters.
using RankChoiceVoting
data = [[:m,:n,:c,:k],[:n,:m,:c,:k],[:c,:k,:n,:m],[:k,:c,:n,:m]]
counts = [42,26,15,17]
rankings = Ranks(counts, data)Ranks
┌────────┬──────────────────┐
│ Counts │ Ranks │
├────────┼──────────────────┤
│ 42 │ [:m, :n, :c, :k] │
│ 26 │ [:n, :m, :c, :k] │
│ 15 │ [:c, :k, :n, :m] │
│ 17 │ [:k, :c, :n, :m] │
└────────┴──────────────────┘
Next, let's create objects for the Consistency criterion and the plurality voting system.
criterion = Consistency()
system = Plurality()Plurality()Compute Ranking
The function compute_ranks is used to generate a complete rank ordering of candidates. In the case of ties, candidates will share the same rank value.
compute_ranks(system, rankings)([1], [:m])Evaluate Winner
We can use the function evaluate_winner to return the winner of the election as a vector. If multiple candidates tie for winner, the vector will contain each winning candidate.
evaluate_winner(system, rankings)1-element Vector{Symbol}:
:mSatisfies
The example below determines whether the a voting system is guaranteed to satisfy a given fairness criterion.
satisfies(system, criterion)trueIt is also possible to check whether a system satisfies a given fairness criterion for a specific set of rank choice votes.
satisfies(system, criterion, rankings)trueIn the case above, the plurality system satisfies the consistency criterion because it holds in general. However, if a system does not satisify a criterion in general, it may satisfy the criterion in specific cases.
Count Violations
The code block below shows how to use count_violations to determine the number of violations of a fairness criterion a given system produces for a specific set of rank choice votes.
count_violations(system, criterion, rankings)0