Returns the condorcet winner if one exists from either a seq of ballots or the result of a pairwise election. In the former case a pairwise election is performed. Returns nil if there is no condorcet winner.
Returns the condorcet winner if one exists from either a seq of ballots or the result of a pairwise election. In the former case a pairwise election is performed. Returns nil if there is no condorcet winner.
Perform a Copeland method election. Returns a priority map of candidate keys and score values. The score of a candidate is its number of pairwise victories minus its number of pairwise defeats.
Perform a Copeland method election. Returns a priority map of candidate keys and score values. The score of a candidate is its number of pairwise victories minus its number of pairwise defeats.
(invert pg)
Takes the result of a pairwise election and reverses the direction of every edge. Useful if you want to find e.g. the condorcet loser.
Takes the result of a pairwise election and reverses the direction of every edge. Useful if you want to find e.g. the condorcet loser.
Perform a Copeland method election as originally proposed by Llull. Returns a priority map of candidate keys and score values. The score of a candidate is its number of pairwise victories.
Perform a Copeland method election as originally proposed by Llull. Returns a priority map of candidate keys and score values. The score of a candidate is its number of pairwise victories.
(pairwise ballots)
Perform a pairwise election. Returns a loom weighted digraph. A pairwise election between two candidates is represented as a directed edge from the winner to the loser with a weight of the margin of victory. In the case of an edge to and from both candidates is created with a weight of 0.
Each ballot should contain a key for each candidate with an integer, lower value = more preferred. Candidates may be ranked as equally preferable.
Perform a pairwise election. Returns a loom weighted digraph. A pairwise election between two candidates is represented as a directed edge from the winner to the loser with a weight of the margin of victory. In the case of an edge to and from both candidates is created with a weight of 0. Each ballot should contain a key for each candidate with an integer, lower value = more preferred. Candidates may be ranked as equally preferable.
(ranked-pairs pg & {:keys [tbrc tbrp] :or {tbrp :schulze-ii}})
Perform an election using Tideman's ranked pairs method. Returns a priority map of candidate keys and score values. The score of a candidate is its Copeland score on the graph of locked-in candidate pairs.
Accepts two optional arguments:
:tbrc is a tie-breaking order of the candidates, used to construct a tie-breaking ranking of the pairs. Used when pairs have the same margin. Must be a vector containing all candidates from most-preferred to least preferred. If not specified the TBRC is the order of candidates returned by sort.
:tbrp specifies the method used to construct a TBRP from the TBRC. Should be one of :zavist, :cretney, :legrand, :schulze-i, or :schulze-ii. Alternatively can be a vector containing all pairs of candidates as sub-vectors (in which case :tbrc is ignored). Defaults to :schulze-ii.
Perform an election using Tideman's ranked pairs method. Returns a priority map of candidate keys and score values. The score of a candidate is its Copeland score on the graph of locked-in candidate pairs. Accepts two optional arguments: :tbrc is a tie-breaking order of the candidates, used to construct a tie-breaking ranking of the pairs. Used when pairs have the same margin. Must be a vector containing all candidates from most-preferred to least preferred. If not specified the TBRC is the order of candidates returned by sort. :tbrp specifies the method used to construct a TBRP from the TBRC. Should be one of :zavist, :cretney, :legrand, :schulze-i, or :schulze-ii. Alternatively can be a vector containing all pairs of candidates as sub-vectors (in which case :tbrc is ignored). Defaults to :schulze-ii.
(schulze pg & {:keys [tbrc tbrp] :or {tbrp :schulze-ii}})
Perform an election using the Schulze method method. Returns a sequence of candidates from highest to lowest ranking. Uses margins to measure the strength of links.
Accepts two optional arguments:
:tbrc is a tie-breaking order of the candidates, used to construct a tie-breaking ranking of the pairs. Used when pairs have the same strength beatpath. Must be a vector containing all candidates from most-preferred to least preferred. If not specified the TBRC is the order of candidates returned by sort.
:tbrp specifies the method used to construct a TBRP from the TBRC. Should be one of :zavist, :cretney, :legrand, :schulze-i, or :schulze-ii. Alternatively can be a vector containing all pairs of candidates as sub-vectors (in which case :tbrc is ignored). Defaults to :schulze-ii.
Perform an election using the Schulze method method. Returns a sequence of candidates from highest to lowest ranking. Uses margins to measure the strength of links. Accepts two optional arguments: :tbrc is a tie-breaking order of the candidates, used to construct a tie-breaking ranking of the pairs. Used when pairs have the same strength beatpath. Must be a vector containing all candidates from most-preferred to least preferred. If not specified the TBRC is the order of candidates returned by sort. :tbrp specifies the method used to construct a TBRP from the TBRC. Should be one of :zavist, :cretney, :legrand, :schulze-i, or :schulze-ii. Alternatively can be a vector containing all pairs of candidates as sub-vectors (in which case :tbrc is ignored). Defaults to :schulze-ii.
(schwartz-components pg)
Takes the results of a pairwise election and returns the Schwartz set components in no particular order.
Takes the results of a pairwise election and returns the Schwartz set components in no particular order.
(schwartz-set pg)
Takes the results of a pairwise election and returns the Schwartz set.
Takes the results of a pairwise election and returns the Schwartz set.
(smith-set pg)
Takes the results of a pairwise election and returns the Smith set.
Takes the results of a pairwise election and returns the Smith set.
Returns the weak condorcet winners if any exist from either a seq of ballots or the result of a pairwise election. In the former case a pairwise election is performed. Returns #{} if there are no weak condorcet winners.
Returns the weak condorcet winners if any exist from either a seq of ballots or the result of a pairwise election. In the former case a pairwise election is performed. Returns #{} if there are no weak condorcet winners.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close