RuleCondorcet¶
-
class
whalrus.
RuleCondorcet
(*args, converter: whalrus.converters_ballot.converter_ballot.ConverterBallot = None, matrix_majority: whalrus.matrices.matrix.Matrix = None, **kwargs)[source]¶ Condorcet Rule.
- Parameters
args – Cf. parent class.
converter (ConverterBallot) – Default:
ConverterBallotToOrder
.matrix_majority (Matrix) – The majority matrix. Default:
MatrixMajority
.kwargs – Cf. parent class.
Examples
If there is a Condorcet winner, then it it the winner and all other candidates are tied. If there is no Condorcet winner, then all candidates are tied.
>>> RuleCondorcet(ballots=['a > b > c', 'b > a > c', 'c > a > b']).order_ [{'a'}, {'b', 'c'}] >>> RuleCondorcet(ballots=['a > b > c', 'b > c > a', 'c > a > b']).order_ [{'a', 'b', 'c'}]
More precisely, and in all generality, a candidate is considered a Condorcet winner if all the non-diagonal coefficients on its raw of
matrix_majority_
are equal to 1. With the default setting ofmatrix_majority = MatrixMajority()
, the Condorcet winner is necessarily unique when it exists, but that might not be the case with some more exotic settings:>>> rule = RuleCondorcet(ballots=['a ~ b > c'], matrix_majority=MatrixMajority(equal=1)) >>> rule.matrix_majority_.as_array_ array([[Fraction(1, 2), 1, 1], [1, Fraction(1, 2), 1], [0, 0, Fraction(1, 2)]], dtype=object) >>> rule.order_ [{'a', 'b'}, {'c'}]
-
property
cotrailers_
¶ “Cotrailers” of the election, i.e. the candidates that fare worst in the election. This is the last equivalence class in
order_
. For example, inRuleScoreNum
, it is the candidates that are tied for the worst score.- Type
-
property
cowinners_
¶ Cowinners of the election, i.e. the candidates that fare best in the election.. This is the first equivalence class in
order_
. For example, inRuleScoreNum
, it is the candidates that are tied for the best score.- Type
-
property
n_candidates_
¶ Number of candidates.
- Type
int
-
property
strict_order_
¶ Result of the election as a strict order over the candidates. The first element is the winner, etc. This may use the tie-breaking rule.
- Type
list
-
property
trailer_
¶ The “trailer” of the election. This is the last candidate in
strict_order_
and also the unfavorable choice of the tie-breaking rule incotrailers_
.- Type
object
-
property
winner_
¶ The winner of the election. This is the first candidate in
strict_order_
and also the choice of the tie-breaking rule incowinners_
.- Type
object