First Steps with SVVAMP

Welcome to this series of tutorials! The objective here is to get you up and running with the package SVVAMP, but not to present all its features in detail. For more exhaustive information, see the Reference section of the documentation.

[1]:
import svvamp

Basic Usage

Create a profile of preferences:

[2]:
profile = svvamp.Profile(preferences_rk=[
    [0, 1, 2],
    [0, 1, 2],
    [1, 0, 2],
    [1, 0, 2],
    [2, 1, 0]
])

Each row represents a voter. For example, the first row represents a voter who prefers candidate 0, then candidate 1, then candidate 2.

Define a voting rule:

[3]:
rule = svvamp.RulePlurality()

Load the profile into the rule:

[4]:
rule(profile)
[4]:
<svvamp.rules.rule_plurality.RulePlurality at 0x25026669a30>

Compute the winner of the election:

[5]:
rule.w_
[5]:
0

Here, the winner is candidate 0. Observe that SVVAMP always uses “candidate tie-breaking”: in case of a tie, candidate 0 is favored over candidate 1, etc.

Compute whether the election is coalitionally manipulable:

[6]:
rule.is_cm_
[6]:
True

Demo of SVVAMP’s Features

Properties of the profile:

[7]:
profile.demo(log_depth=0)

************************
*   Basic properties   *
************************
n_v = 5
n_c = 3
labels_candidates = ['0', '1', '2']
preferences_ut =
[[2 1 0]
 [2 1 0]
 [1 2 0]
 [1 2 0]
 [0 1 2]]
preferences_borda_ut =
[[2. 1. 0.]
 [2. 1. 0.]
 [1. 2. 0.]
 [1. 2. 0.]
 [0. 1. 2.]]
preferences_borda_rk =
[[2 1 0]
 [2 1 0]
 [1 2 0]
 [1 2 0]
 [0 1 2]]
preferences_rk =
[[0 1 2]
 [0 1 2]
 [1 0 2]
 [1 0 2]
 [2 1 0]]
v_has_same_ordinal_preferences_as_previous_voter =
[False  True False  True False]

************************
*   Plurality scores   *
************************
preferences_rk (reminder) =
[[0 1 2]
 [0 1 2]
 [1 0 2]
 [1 0 2]
 [2 1 0]]
plurality_scores_rk = [2 2 1]
majority_favorite_rk = nan
majority_favorite_rk_ctb = nan

preferences_borda_ut (reminder) =
[[2. 1. 0.]
 [2. 1. 0.]
 [1. 2. 0.]
 [1. 2. 0.]
 [0. 1. 2.]]
plurality_scores_ut = [2 2 1]
majority_favorite_ut = nan
majority_favorite_ut_ctb = nan

********************
*   Borda scores   *
********************
preferences_borda_rk (reminder) =
[[2 1 0]
 [2 1 0]
 [1 2 0]
 [1 2 0]
 [0 1 2]]
borda_score_c_rk =
[6 7 2]
Remark: Borda scores above are computed with the matrix of duels.
Check: np.sum(self.preferences_borda_rk, 0) =
[6 7 2]
decreasing_borda_scores_rk =
[7 6 2]
candidates_by_decreasing_borda_score_rk =
[1 0 2]

preferences_borda_ut (reminder) =
[[2. 1. 0.]
 [2. 1. 0.]
 [1. 2. 0.]
 [1. 2. 0.]
 [0. 1. 2.]]
borda_score_c_ut =
[6. 7. 2.]
decreasing_borda_scores_ut =
[7. 6. 2.]
candidates_by_decreasing_borda_score_ut =
[1 0 2]

*****************
*   Utilities   *
*****************
preferences_ut (reminder) =
[[2 1 0]
 [2 1 0]
 [1 2 0]
 [1 2 0]
 [0 1 2]]
total_utility_c =
[6 7 2]
total_utility_min = 2
total_utility_max = 7
total_utility_mean = 5.0
total_utility_std = 2.160246899469287

*******************************************
*   Condorcet notions based on rankings   *
*******************************************
preferences_rk (reminder) =
[[0 1 2]
 [0 1 2]
 [1 0 2]
 [1 0 2]
 [2 1 0]]
matrix_duels_rk =
[[0 2 4]
 [3 0 4]
 [1 1 0]]
matrix_victories_rk =
[[0. 0. 1.]
 [1. 0. 1.]
 [0. 0. 0.]]
condorcet_winner_rk = 1
exists_condorcet_order_rk = True
matrix_victories_rk_ctb =
[[0. 0. 1.]
 [1. 0. 1.]
 [0. 0. 0.]]
condorcet_winner_rk_ctb = 1
exists_condorcet_order_rk_ctb = True

***************************************
*   Relative Condorcet notions (ut)   *
***************************************
preferences_borda_ut (reminder) =
[[2. 1. 0.]
 [2. 1. 0.]
 [1. 2. 0.]
 [1. 2. 0.]
 [0. 1. 2.]]
matrix_duels_ut =
[[0 2 4]
 [3 0 4]
 [1 1 0]]
matrix_victories_ut_rel =
[[0. 0. 1.]
 [1. 0. 1.]
 [0. 0. 0.]]
condorcet_winner_ut_rel = 1
exists_condorcet_order_ut_rel = True
matrix_victories_ut_rel_ctb =
[[0. 0. 1.]
 [1. 0. 1.]
 [0. 0. 0.]]
condorcet_winner_ut_rel_ctb = 1
exists_condorcet_order_ut_rel_ctb = True

***************************************
*   Absolute Condorcet notions (ut)   *
***************************************
matrix_duels_ut (reminder) =
[[0 2 4]
 [3 0 4]
 [1 1 0]]
matrix_victories_ut_abs =
[[0. 0. 1.]
 [1. 0. 1.]
 [0. 0. 0.]]
condorcet_admissible_candidates =
[False  True False]
nb_condorcet_admissible = 1
weak_condorcet_winners =
[False  True False]
nb_weak_condorcet_winners = 1
condorcet_winner_ut_abs = 1
exists_condorcet_order_ut_abs = True
resistant_condorcet_winner = nan
threshold_c_prevents_w_Condorcet_ut_abs =
[[0 1 1]
 [2 0 1]
 [0 0 0]]
matrix_victories_ut_abs_ctb =
[[0. 0. 1.]
 [1. 0. 1.]
 [0. 0. 0.]]
condorcet_winner_ut_abs_ctb = 1
exists_condorcet_order_ut_abs_ctb = True

**********************************************
*   Implications between Condorcet notions   *
**********************************************
maj_fav_ut (False)             ==>            maj_fav_ut_ctb (False)
 ||          ||                                     ||           ||
 ||          V                                      V            ||
 ||         maj_fav_rk (False) ==> maj_fav_rk_ctb (False)        ||
 V                         ||       ||                           ||
Resistant Condorcet (False)                                      ||
 ||                        ||       ||                           ||
 V                         ||       ||                           V
Condorcet_ut_abs (True)        ==>      Condorcet_ut_abs_ctb (True)
 ||          ||            ||       ||              ||           ||
 ||          V             V        V               V            ||
 ||       Condorcet_rk (True)  ==> Condorcet_rk_ctb (True)       ||
 V                                                               V
Condorcet_ut_rel (True)        ==>      Condorcet_ut_rel_ctb (True)
 ||
 V
Weak Condorcet (True)
 ||
 V
Condorcet-admissible (True)

Results of the election:

[8]:
rule.demo_results_(log_depth=0)

************************
*                      *
*   Election Results   *
*                      *
************************

***************
*   Results   *
***************
profile_.preferences_ut (reminder) =
[[2 1 0]
 [2 1 0]
 [1 2 0]
 [1 2 0]
 [0 1 2]]
profile_.preferences_rk (reminder) =
[[0 1 2]
 [0 1 2]
 [1 0 2]
 [1 0 2]
 [2 1 0]]
ballots =
[0 0 1 1 2]
scores =
[2 2 1]
candidates_by_scores_best_to_worst
[0 1 2]
scores_best_to_worst
[2 2 1]
w = 0
score_w = 2
total_utility_w = 6

*********************************
*   Condorcet efficiency (rk)   *
*********************************
w (reminder) = 0

condorcet_winner_rk_ctb = 1
w_is_condorcet_winner_rk_ctb = False
w_is_not_condorcet_winner_rk_ctb = True
w_missed_condorcet_winner_rk_ctb = True

condorcet_winner_rk = 1
w_is_condorcet_winner_rk = False
w_is_not_condorcet_winner_rk = True
w_missed_condorcet_winner_rk = True

***************************************
*   Condorcet efficiency (relative)   *
***************************************
w (reminder) = 0

condorcet_winner_ut_rel_ctb = 1
w_is_condorcet_winner_ut_rel_ctb = False
w_is_not_condorcet_winner_ut_rel_ctb = True
w_missed_condorcet_winner_ut_rel_ctb = True

condorcet_winner_ut_rel = 1
w_is_condorcet_winner_ut_rel = False
w_is_not_condorcet_winner_ut_rel = True
w_missed_condorcet_winner_ut_rel = True

***************************************
*   Condorcet efficiency (absolute)   *
***************************************
w (reminder) = 0

condorcet_admissible_candidates =
[False  True False]
w_is_condorcet_admissible = False
w_is_not_condorcet_admissible = True
w_missed_condorcet_admissible = True

weak_condorcet_winners =
[False  True False]
w_is_weak_condorcet_winner = False
w_is_not_weak_condorcet_winner = True
w_missed_weak_condorcet_winner = True

condorcet_winner_ut_abs_ctb = 1
w_is_condorcet_winner_ut_abs_ctb = False
w_is_not_condorcet_winner_ut_abs_ctb = True
w_missed_condorcet_winner_ut_abs_ctb = True

condorcet_winner_ut_abs = 1
w_is_condorcet_winner_ut_abs = False
w_is_not_condorcet_winner_ut_abs = True
w_missed_condorcet_winner_ut_abs = True

resistant_condorcet_winner = nan
w_is_resistant_condorcet_winner = False
w_is_not_resistant_condorcet_winner = True
w_missed_resistant_condorcet_winner = False

Manipulation of the election:

[9]:
rule.demo_manipulation_(log_depth=0)

*****************************
*                           *
*   Election Manipulation   *
*                           *
*****************************

*********************************************
*   Basic properties of the voting system   *
*********************************************
with_two_candidates_reduces_to_plurality =  True
is_based_on_rk =  True
is_based_on_ut_minus1_1 =  False
meets_iia =  False

****************************************************
*   Manipulation properties of the voting system   *
****************************************************
Condorcet_c_ut_rel_ctb (False)     ==>     Condorcet_c_ut_rel (False)
 ||                                                               ||
 ||     Condorcet_c_rk_ctb (False) ==> Condorcet_c_rk (False)     ||
 ||           ||               ||       ||             ||         ||
 V            V                ||       ||             V          V
Condorcet_c_ut_abs_ctb (False)     ==>     Condorcet_ut_abs_c (False)
 ||                            ||       ||                        ||
 ||                            V        V                         ||
 ||       maj_fav_c_rk_ctb (True)  ==> maj_fav_c_rk (True)        ||
 ||           ||                                       ||         ||
 V            V                                        V          V
majority_favorite_c_ut_ctb (True)  ==> majority_favorite_c_ut (True)
 ||                                                               ||
 V                                                                V
IgnMC_c_ctb (True)                 ==>                IgnMC_c (True)
 ||                                                               ||
 V                                                                V
InfMC_c_ctb (True)                 ==>                InfMC_c (True)

*****************************************************
*   Independence of Irrelevant Alternatives (IIA)   *
*****************************************************
w (reminder) = 0
is_iia = False
log_iia: iia_subset_maximum_size = 2.0
example_winner_iia = 1
example_subset_iia = [ True  True False]

**********************
*   c-Manipulators   *
**********************
w (reminder) = 0
preferences_ut (reminder) =
[[2 1 0]
 [2 1 0]
 [1 2 0]
 [1 2 0]
 [0 1 2]]
v_wants_to_help_c =
[[False False False]
 [False False False]
 [False  True False]
 [False  True False]
 [False  True  True]]

************************************
*   Individual Manipulation (IM)   *
************************************
is_im = True
log_im: im_option = exact
candidates_im =
[0. 1. 0.]

*********************************
*   Trivial Manipulation (TM)   *
*********************************
is_tm = True
log_tm: tm_option = exact
candidates_tm =
[0. 1. 0.]

********************************
*   Unison Manipulation (UM)   *
********************************
is_um = True
log_um: um_option = exact
candidates_um =
[0. 1. 0.]

*********************************************
*   Ignorant-Coalition Manipulation (ICM)   *
*********************************************
is_icm = True
log_icm: icm_option = exact
candidates_icm =
[0. 1. 0.]
necessary_coalition_size_icm =
[0. 3. 5.]
sufficient_coalition_size_icm =
[0. 3. 5.]

***********************************
*   Coalition Manipulation (CM)   *
***********************************
is_cm = True
log_cm: cm_option = exact
candidates_cm =
[0. 1. 0.]
necessary_coalition_size_cm =
[0. 3. 3.]
sufficient_coalition_size_cm =
[0. 3. 3.]