RuleSchulze¶
-
class
whalrus.
RuleSchulze
(*args, converter: whalrus.converters_ballot.converter_ballot.ConverterBallot = None, matrix_schulze: whalrus.matrices.matrix.Matrix = None, **kwargs)[source]¶ Schulze’s Rule.
A candidate is a Schulze winner if it has no defeat in the Schulze matrix.
- Parameters
args – Cf. parent class.
converter (ConverterBallot) – Default:
ConverterBallotToOrder
.matrix_schulze (Matrix) – The Schulze matrix. Default:
MatrixSchulze
.kwargs – Cf. parent class.
Examples
>>> rule = RuleSchulze(['a > b > c', 'b > c > a', 'c > a > b'], weights=[4, 3, 2]) >>> rule.matrix_schulze_.as_array_ array([[0, Fraction(2, 3), Fraction(2, 3)], [Fraction(5, 9), 0, Fraction(7, 9)], [Fraction(5, 9), Fraction(5, 9), 0]], dtype=object) >>> rule.winner_ 'a'
-
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