ElectionResult¶
-
class
svvamp.
ElectionResult
(population, **kwargs)[source]¶ Create a simple election (without manipulation).
This is an ‘abstract’ class. As an end-user, you should always use its subclasses
Approval
,Plurality
, etc.Parameters: - population – A
Population
object. - kwargs – additional keyword parameters. See
options_parameters
.
>>> import svvamp >>> pop = svvamp.PopulationSpheroid(V=100, C=5) >>> election = svvamp.Approval(pop, approval_comparator='>=')
-
ballots
¶ Ballots cast by the voters.
- Default type in superclass
ElectionResult
: - 2d array of integers.
- Default behavior in superclass
ElectionResult
: ballots[v, k]
=preferences_rk
[v, k]
.
- Default type in superclass
-
candidates_by_scores_best_to_worst
¶ 1d array of integers. All candidates, sorted from the winner to the last candidate in the result of the election.
- Default behavior in superclass
ElectionResult
: candidates_by_scores_best_to_worst[k]
is the candidate withk
th highest value inscores
.
By definition,
candidates_by_scores_best_to_worst[0]
=w
.- Default behavior in superclass
-
demo
(log_depth=1)¶ Demonstrate the methods of
ElectionResult
class. sparam log_depth: Integer from 0 (basic info) to 3 (verbose).
-
mean_utility_w
¶ Float. The mean utility for the sincere winner
w
. Be careful, this makes sense only if interpersonal comparison of utilities makes sense.
-
options_parameters
¶ Display options.
Display a overview of available options, their default values and a minimal indication about what values are allowed for each option. For more details about a specific option, see its documentation.
-
pop
¶ A
Population
object. The population running the election.
-
score_w
¶ Score of the sincere winner.
- Default type in superclass
ElectionResult
: - Number or 1d array.
- Default behavior in superclass
ElectionResult
: If
scores
is a 1d array, thenscore_w
isw
‘s numerical score:score_w = scores[w]
.If
scores
is a 2d array, thenscore_w
isw
‘s score vector:score_w = scores[:, w]
.
- Default type in superclass
-
scores
¶ Scores of the candidates in the election.
This function is not implemented in the superclass
ElectionResult
. See specific documentation for each voting system.- Typical type in most subclasses:
- 1d or 2d array.
- Typical behavior in most subclasses:
If
scores
is a 1d array, thenscores[c]
is the numerical score for candidatec
.If
scores
is a 2d array, thenscores[:, c]
is the score vector for candidatec
.
-
scores_best_to_worst
¶ Scores of the candidates, from the winner to the last candidate of the election.
- Default type in superclass
ElectionResult
: - 1d or 2d array.
- Default behavior in superclass
ElectionResult
: scores_best_to_worst
is derived fromscores
andcandidates_by_scores_best_to_worst
.If
scores
is a 1d array, then so isscores_best_to_worst
. It is defined byscores_best_to_worst
=scores[candidates_by_scores_best_to_worst]
. Then by definition,scores_best_to_worst[0]
=score_w
.If
scores
is a 2d array, then so isscores_best_to_worst
. It is defined byscores_best_to_worst
=scores[:, candidates_by_scores_best_to_worst]
. Then by definition,scores_best_to_worst[:, 0]
=score_w
.
- Default type in superclass
-
total_utility_w
¶ Float. The total utility for the sincere winner
w
. Be careful, this makes sense only if interpersonal comparison of utilities makes sense.
-
w
¶ Integer (winning candidate).
- Default behavior in superclass
ElectionResult
: - The candidate with highest value in vector
scores
is declared the winner. In case of a tie, the tied candidate with lowest index wins.
- Default behavior in superclass
-
w_is_condorcet_admissible
¶ Boolean.
True
iff the sincere winnerw
is Condorcet-admissible. Cf.condorcet_admissible_candidates
.
-
w_is_condorcet_winner_rk
¶ Boolean. True iff the sincere winner
w
is acondorcet_winner_rk
.
-
w_is_condorcet_winner_rk_ctb
¶ Boolean. True iff the sincere winner
w
is acondorcet_winner_rk_ctb
.
-
w_is_condorcet_winner_ut_abs
¶ Boolean. True iff the sincere winner
w
is acondorcet_winner_ut_abs
.
-
w_is_condorcet_winner_ut_abs_ctb
¶ Boolean. True iff the sincere winner
w
is acondorcet_winner_ut_abs_ctb
.
-
w_is_condorcet_winner_ut_rel
¶ Boolean. True iff the sincere winner
w
is acondorcet_winner_ut_rel
.
-
w_is_condorcet_winner_ut_rel_ctb
¶ Boolean. True iff the sincere winner
w
is acondorcet_winner_ut_abs_ctb
.
-
w_is_not_condorcet_admissible
¶ Boolean.
True
iff the sincere winnerw
is not a Condorcet-admissible candidate (whether some exist or not). Cf.condorcet_admissible_candidates
.
-
w_is_not_condorcet_winner_rk
¶ Boolean. True iff the sincere winner
w
is not acondorcet_winner_rk
(whether one exists or not).
-
w_is_not_condorcet_winner_rk_ctb
¶ Boolean. True iff the sincere winner
w
is not acondorcet_winner_rk_ctb
(whether one exists or not).
-
w_is_not_condorcet_winner_ut_abs
¶ Boolean. True iff the sincere winner
w
is not acondorcet_winner_ut_abs
(whether one exists or not).
-
w_is_not_condorcet_winner_ut_abs_ctb
¶ Boolean. True iff the sincere winner
w
is not acondorcet_winner_ut_abs_ctb
(whether one exists or not).
-
w_is_not_condorcet_winner_ut_rel
¶ Boolean. True iff the sincere winner
w
is not acondorcet_winner_ut_rel
(whether one exists or not).
-
w_is_not_condorcet_winner_ut_rel_ctb
¶ Boolean. True iff the sincere winner
w
is not acondorcet_winner_ut_abs_ctb
(whether one exists or not).
-
w_is_not_resistant_condorcet_winner
¶ Boolean. True iff the sincere winner
w
is not aresistant_condorcet_winner
(whether one exists or not).
-
w_is_not_weak_condorcet_winner
¶ Boolean. True iff the sincere winner
w
is not a Weak Condorcet winner (whether some exist or not). Cf.weak_condorcet_winners
.
-
w_is_resistant_condorcet_winner
¶ Boolean. True iff the sincere winner
w
is aresistant_condorcet_winner
.
-
w_is_weak_condorcet_winner
¶ Boolean. True iff the sincere winner
w
is a Weak Condorcet winner. Cf.weak_condorcet_winners
.
-
w_missed_condorcet_admissible
¶ Boolean. True iff the sincere winner
w
is not a Condorcet-admissible candidate, despite the fact that at least one exists. Cf.condorcet_admissible_candidates
.
-
w_missed_condorcet_winner_rk
¶ Boolean. True iff the sincere winner
w
is not thecondorcet_winner_rk
, despite the fact that she exists.
-
w_missed_condorcet_winner_rk_ctb
¶ Boolean. True iff the sincere winner
w
is not thecondorcet_winner_rk_ctb
, despite the fact that she exists.
-
w_missed_condorcet_winner_ut_abs
¶ Boolean. True iff the sincere winner
w
is not thecondorcet_winner_ut_abs
, despite the fact that she exists.
-
w_missed_condorcet_winner_ut_abs_ctb
¶ Boolean. True iff the sincere winner
w
is not thecondorcet_winner_ut_abs_ctb
, despite the fact that she exists.
-
w_missed_condorcet_winner_ut_rel
¶ Boolean. True iff the sincere winner
w
is not thecondorcet_winner_ut_rel
, despite the fact that she exists.
-
w_missed_condorcet_winner_ut_rel_ctb
¶ Boolean. True iff the sincere winner
w
is not thecondorcet_winner_ut_abs_ctb
, despite the fact that she exists.
-
w_missed_resistant_condorcet_winner
¶ Boolean. True iff the sincere winner
w
is not theresistant_condorcet_winner
, despite the fact that she exists.
-
w_missed_weak_condorcet_winner
¶ Boolean. True iff the sincere winner
w
is not a Weak Condorcet winner, despite the fact that at least one exists. Cf.weak_condorcet_winners
.
- population – A