Preferential voting utilities to help come to reasonable decisions
when there are more than 2 options. Currently we provide 3 common
voting implementations, with batch and incremental tallying.
In this library, a
candidate is a non-numeric object
eq? such as a symbol and a
an object aggregating
votes. A single
vote is a
list of lists of candidates in order of preference. The inner
lists may have multiple elements to represent an equal preference
among the options, so that the vote
((A B) (C))
represents a preference of either
C. A vote should not have any duplicate candidates,
but need not include all eligible candidates.
xshould be either a
tallyor alist of votes. Unlike
instant-runoff-ranksatisfies the Condorcet winner and loser criteria, the Smith criterion, and various other criteria desirable in motivating people to vote honestly and without strategy for their actual preferences. Recommended for most use cases.
x, which can be either a
tallyor alist of votes. The keys of the alist should be some identifier of the voter, but are for debugging purposes and not actually used. Second or later preferences are allowed but ignored by the algorithm. However, unlike traditional plurality voting, each vote may have multiple first place choice candidates which are counted equally. If equal weighted votes are not desired they should be filtered separately prior to tallying.
xshould be either a
tallyor alist of votes. Unlike traditional IRV this implementation allows equal weighted votes which should be filtered prior to tallying if undesired.
Tallyis an object holding an aggregated count of preferential votes. On creation you specify what level of aggregation is done. The most general case is
distinct, which keeps a count of each unique preferential vote. The next most general is
pairwise, which counts just pairwise preferences, followed by the default which just counts the number of times a candidate appeared as the first choice.
candidatesshould be a vector of all valid candidates.
tallyfor the votes alist
tallywith pairwise aggregation for the votes alist
tallywith distinct aggregation for the votes alist
(candidate . candidate)pair keys and count values for the given
tallywith pairwise aggregation for the given alist of pairs having
(candidate . candidate)keys and count values.