Liking cljdoc? Tell your friends :D

suffragium.cardinal


approvalclj

(approval ballots & {:keys [tbrc] :or {tbrc (-> ballots first keys)}})

Perform an approval election. Returns an array map of candidate keys and number of ballots which approved of them values, in descending order. The ordering of candidates with the same number of approved ballots is not specified.

Each ballot should contain a key for each candidate. A truthy value indicates approval and a falsey value disapproval.

:tbrc is a tie-breaking order of the candidates, used to resolve the final order in the case of ties. Should be a vector of all candidates from most to least preferred. No guarantees are made about the default TBRC, other than completeness.

Perform an approval election. Returns an array map of candidate keys and
number of ballots which approved of them values, in descending order. The
ordering of candidates with the same number of approved ballots is not
specified.

Each ballot should contain a key for each candidate. A truthy value indicates
approval and a falsey value disapproval.

:tbrc is a tie-breaking order of the candidates, used to resolve the final
order in the case of ties. Should be a vector of all candidates from most to
least preferred. No guarantees are made about the default TBRC, other than
completeness.
sourceraw docstring

borda-countclj

(borda-count ballots
             &
             {:keys [score-fn tbrc]
              :or {score-fn identity tbrc (-> ballots first keys)}})

Perform a Borda count election. Returns an array map of candidate keys and total score values, ordered from most to least preferred.

Each ballot should contain a key for each candidate.

:score-fn is a scoring function that translates the value assigned to each candidate on a ballot into a numerical score; defaults to identity.

:tbrc is a tie-breaking order of the candidates, used to resolve the final order in the case of score ties. Should be a vector of all candidates from most to least preferred. No guarantees are made about the default TBRC, other than completeness.

Note: this function can be used for range voting, but will not ensure the scores are within the allowed range.

Perform a Borda count election. Returns an array map of candidate keys
and total score values, ordered from most to least preferred.

Each ballot should contain a key for each candidate.

:score-fn is a scoring function that translates the value assigned to each
candidate on a ballot into a numerical score; defaults to identity.

:tbrc is a tie-breaking order of the candidates, used to resolve the final
order in the case of score ties. Should be a vector of all candidates from
most to least preferred. No guarantees are made about the default TBRC, other
than completeness.

Note: this function can be used for range voting, but will not ensure the
scores are within the allowed range.
sourceraw docstring

pluralityclj

(plurality ballots & {:keys [tbrc] :or {tbrc (-> ballots first keys)}})

Perform a plurality (first-past-the-post) election. Returns an array map of candidate keys and the number of ballots in which they were top ranked values, in descending order.

A lower vaue on a ballot corresponds to a higher rank. If there are multiple candidates with the same lowest value the candidate awarded the vote is not specified (however it will be one of the lowest ranked candidates).

:tbrc is a tie-breaking order of the candidates, used to resolve the final order in the case of ties. Should be a vector of all candidates from most to least preferred. No guarantees are made about the default TBRC, other than completeness.

Perform a plurality (first-past-the-post) election. Returns an array map of
candidate keys and the number of ballots in which they were top ranked
values, in descending order.

A lower vaue on a ballot corresponds to a higher rank. If there are multiple
candidates with the same lowest value the candidate awarded the vote is not
specified (however it will be one of the lowest ranked candidates).

:tbrc is a tie-breaking order of the candidates, used to resolve the final
order in the case of ties. Should be a vector of all candidates from most to
least preferred. No guarantees are made about the default TBRC, other than
completeness.
sourceraw docstring

starclj

(star ballots
      &
      {:keys [score-fn tbrc]
       :or {score-fn identity tbrc (-> ballots first keys)}})

Performs an election using STAR. Takes same arguments as borda-count. Returns the same as borda count except the winner of the runoff will be the first item in the array-map.

Note: unlike the raditional definition of STAR voting, no restriction on the allowed scores is applied.

Performs an election using STAR. Takes same arguments as borda-count.
Returns the same as borda count except the winner of the runoff will be
the first item in the array-map.

Note: unlike the raditional definition of STAR voting, no restriction on
the allowed scores is applied.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close