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:

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'
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, in RuleScoreNum, it is the candidates that are tied for the worst score.

Type:NiceSet
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, in RuleScoreNum, it is the candidates that are tied for the best score.

Type:NiceSet
matrix_schulze_

The Schulze matrix (once computed with the given profile).

Type:Matrix
n_candidates_

Number of candidates.

Type:int
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
trailer_

The “trailer” of the election. This is the last candidate in strict_order_ and also the unfavorable choice of the tie-breaking rule in cotrailers_.

Type:object
winner_

The winner of the election. This is the first candidate in strict_order_ and also the choice of the tie-breaking rule in cowinners_.

Type:object