- class svvamp.RuleIRVAverage(**kwargs)[source]#
Instant Runoff Voting based on Average Score (Nanson-like).
Options#
>>> RuleIRVAverage.print_options_parameters() cm_option: ['fast', 'slow', 'very_slow', 'exact']. Default: 'fast'. icm_option: ['lazy']. Default: 'lazy'. iia_subset_maximum_size: is_number. Default: 2. im_option: ['lazy', 'exact']. Default: 'lazy'. tm_option: ['lazy', 'exact']. Default: 'exact'. um_option: ['lazy', 'exact']. Default: 'lazy'.
Notes
At each round, all candidates with a Plurality score strictly lower than average are simultaneously eliminated. When all remaining candidates have the same Plurality score, the candidate with lowest index is declared the winner.
This method meets MajFav criterion.
is_cm_()
:cm_option
='fast'
: Rely onRuleIRV
’s fast algorithm. Polynomial heuristic. Can prove CM but unable to decide non-CM (except in rare obvious cases).cm_option
='slow'
: Rely onRuleExhaustiveBallot
’s exact algorithm. Non-polynomial heuristic (\(2^{n_c}\)). Quite efficient to prove CM or non-CM.cm_option
='very_slow'
: Rely onRuleIRV
’s exact algorithm. Non-polynomial heuristic (\(n_c!\)). Very efficient to prove CM or non-CM.cm_option
='exact'
: Non-polynomial algorithm from superclassRule
.
Each algorithm above exploits the faster ones. For example, if
cm_option
='very_slow'
, SVVAMP tries the fast algorithm first, then the slow one, then the ‘very slow’ one. As soon as it reaches a decision, computation stops.is_icm_()
: Exact in polynomial time.is_im_()
: Non-polynomial or non-exact algorithms from superclassRule
.is_iia()
: Non-polynomial or non-exact algorithms from superclassRule
.is_tm_()
: Exact in polynomial time.is_um_()
: Non-polynomial or non-exact algorithms from superclassRule
.
Examples
>>> profile = Profile(preferences_ut=[ ... [ 0. , -0.5, -1. ], ... [ 1. , -1. , 0.5], ... [ 0.5, 0.5, -0.5], ... [ 0.5, 0. , 1. ], ... [-1. , -1. , 1. ], ... ], preferences_rk=[ ... [0, 1, 2], ... [0, 2, 1], ... [1, 0, 2], ... [2, 0, 1], ... [2, 1, 0], ... ]) >>> rule = RuleIRVAverage()(profile) >>> rule.demo_results_(log_depth=0) ************************ * * * Election Results * * * ************************ *************** * Results * *************** profile_.preferences_ut (reminder) = [[ 0. -0.5 -1. ] [ 1. -1. 0.5] [ 0.5 0.5 -0.5] [ 0.5 0. 1. ] [-1. -1. 1. ]] profile_.preferences_rk (reminder) = [[0 1 2] [0 2 1] [1 0 2] [2 0 1] [2 1 0]] ballots = [[0 1 2] [0 2 1] [1 0 2] [2 0 1] [2 1 0]] scores = [[ 2. 1. 2.] [ 3. inf 2.] [ 5. inf inf]] candidates_by_scores_best_to_worst [0 2 1] scores_best_to_worst [[ 2. 2. 1.] [ 3. 2. inf] [ 5. inf inf]] w = 0 score_w = [2. 3. 5.] total_utility_w = 1.0 ********************************* * Condorcet efficiency (rk) * ********************************* w (reminder) = 0 condorcet_winner_rk_ctb = 0 w_is_condorcet_winner_rk_ctb = True w_is_not_condorcet_winner_rk_ctb = False w_missed_condorcet_winner_rk_ctb = False condorcet_winner_rk = 0 w_is_condorcet_winner_rk = True w_is_not_condorcet_winner_rk = False w_missed_condorcet_winner_rk = False *************************************** * Condorcet efficiency (relative) * *************************************** w (reminder) = 0 condorcet_winner_ut_rel_ctb = 0 w_is_condorcet_winner_ut_rel_ctb = True w_is_not_condorcet_winner_ut_rel_ctb = False w_missed_condorcet_winner_ut_rel_ctb = False condorcet_winner_ut_rel = 0 w_is_condorcet_winner_ut_rel = True w_is_not_condorcet_winner_ut_rel = False w_missed_condorcet_winner_ut_rel = False *************************************** * Condorcet efficiency (absolute) * *************************************** w (reminder) = 0 condorcet_admissible_candidates = [ True False False] w_is_condorcet_admissible = True w_is_not_condorcet_admissible = False w_missed_condorcet_admissible = False weak_condorcet_winners = [ True False False] w_is_weak_condorcet_winner = True w_is_not_weak_condorcet_winner = False w_missed_weak_condorcet_winner = False condorcet_winner_ut_abs_ctb = 0 w_is_condorcet_winner_ut_abs_ctb = True w_is_not_condorcet_winner_ut_abs_ctb = False w_missed_condorcet_winner_ut_abs_ctb = False condorcet_winner_ut_abs = 0 w_is_condorcet_winner_ut_abs = True w_is_not_condorcet_winner_ut_abs = False w_missed_condorcet_winner_ut_abs = False resistant_condorcet_winner = nan w_is_resistant_condorcet_winner = False w_is_not_resistant_condorcet_winner = True w_missed_resistant_condorcet_winner = False
- property candidates_by_scores_best_to_worst_#
1d array of integers. Candidates are sorted according to their order of elimination. When several candidates are eliminated during the same round, they are sorted by Plurality score at that round (less votes are eliminated first) and, in case of a tie, by their index (highest indexes are eliminated first).
- property scores_#
2d array of integers.
scores[r, c]
is the Plurality score of candidatec
at elimination roundr
. By convention, if candidatec
does not participate to roundr
, thenscores[r, c] = numpy.inf
.