Tutorial 2: Election¶
Create a population of 9 voters with preferences over 5 candidates, using the Spheroid model (extending Impartial Culture to utilities):
import svvamp
pop = svvamp.PopulationSpheroid(V=9, C=5)
Print the preference rankings of the population:
pop.ensure_voters_sorted_by_rk()
print(pop.preferences_rk)
Create an election, using Plurality:
election = svvamp.Plurality(pop)
Print the ballots:
print(election.ballots)
Print the scores of the candidates:
print(election.scores)
Print the ordering of candidates according to their scores:
print(election.candidates_by_scores_best_to_worst)
print(election.scores_best_to_worst)
Print the winner, her score and her total utility:
print(election.w)
print(election.score_w)
print(election.total_utility_w)
Print whether the winner of the election is a Condorcet winner:
print(election.w_is_condorcet_winner_ut_abs)