class svvamp.ProfileUM(profile_s, n_m, ballot_ut=None, ballot_rk=None, ballot_borda_rk=None)[source]

Profile used for Unison Manipulation.

This class is used internally by SVVAMP. It is not intended for the end user.

Parameters:
  • profile_s (Profile) – Profile of all sincere voters (i.e. those who do not prefer c to w).

  • n_m (int) – Number of manipulators.

  • ballot_ut (List, optional) – Ballot, seen as utilities.

  • ballot_rk (List, optional) – Ballot, seen as rankings.

  • List (ballot_borda_rk =) – Ballot, seen as Borda points.

  • optional. – Ballot, seen as Borda points.

Examples

>>> profile_s = Profile(preferences_ut=[[1., .5, 0.], [.5, 1., 0.]])

Define with ballot_ut:

>>> profile_s.preferences_ut
array([[1. , 0.5, 0. ],
       [0.5, 1. , 0. ]])
>>> profile_um = ProfileUM(profile_s=profile_s, n_m=2, ballot_ut=[0., 1., 0.])
>>> profile_um.preferences_ut
array([[1. , 0.5, 0. ],
       [0.5, 1. , 0. ],
       [0. , 1. , 0. ],
       [0. , 1. , 0. ]])

Define with ballot_rk:

>>> profile_s.preferences_rk
array([[0, 1, 2],
       [1, 0, 2]])
>>> profile_um = ProfileUM(profile_s=profile_s, n_m=2, ballot_rk=[1, 2, 0])
>>> profile_um.preferences_rk
array([[0, 1, 2],
       [1, 0, 2],
       [1, 2, 0],
       [1, 2, 0]])

Define with ballot_borda_rk:

>>> profile_s.preferences_borda_rk
array([[2, 1, 0],
       [1, 2, 0]])
>>> profile_um = ProfileUM(profile_s=profile_s, n_m=2, ballot_borda_rk=[0, 2, 1])
>>> profile_um.preferences_borda_rk
array([[2, 1, 0],
       [1, 2, 0],
       [0, 2, 1],
       [0, 2, 1]])
But you need at least one of them:
>>> profile_um = ProfileUM(profile_s=profile_s, n_m=2)
Traceback (most recent call last):
ValueError: Please provide at least ballot_ut, ballot_rk or ballot_borda_rk.
property ballot_borda_ut

ballot of the manipulators, in ‘borda ut’ format.

Examples

>>> profile_s = Profile(preferences_ut=[[1., .5, 0.], [.5, 1., 0.]])
>>> profile_um = ProfileUM(profile_s=profile_s, n_m=2, ballot_ut=[0., 1., 0.])
>>> profile_um.ballot_borda_ut
array([0.5, 2. , 0.5])
Type:

List

property ballot_rk

ballot of the manipulators, in ‘rk’ format.

Examples

>>> profile_s = Profile(preferences_ut=[[1., .5, 0.], [.5, 1., 0.]])
>>> profile_um = ProfileUM(profile_s=profile_s, n_m=2, ballot_rk=[1, 2, 0])
>>> profile_um.ballot_rk
array([1, 2, 0])
>>> profile_um = ProfileUM(profile_s=profile_s, n_m=2, ballot_borda_rk=[0, 2, 1])
>>> profile_um.ballot_rk
array([1, 2, 0])
>>> profile_um = ProfileUM(profile_s=profile_s, n_m=2, ballot_ut=[0., 1., 0.])
>>> profile_um.ballot_rk
Traceback (most recent call last):
ValueError: You should not rely on the implicit conversion from utility to ranking to compute UM.
Type:

List

property labels_candidates

labels of the candidates.

Examples

>>> profile_s = Profile(preferences_ut=[[1., .5, 0.], [.5, 1., 0.]])
>>> profile_um = ProfileUM(profile_s=profile_s, n_m=2, ballot_ut=[0., 1., 0.])
>>> profile_um.labels_candidates
['0', '1', '2']
Type:

List

property matrix_duels_rk

2d array of integers. matrix_duels_rk[c, d] is the number of voters who rank candidate c before d (in the sense of preferences_rk). By convention, diagonal coefficients are set to 0.

>>> from svvamp import Profile
>>> profile = Profile(preferences_rk=[[0, 1, 2], [0, 1, 2]])
>>> profile.matrix_duels_rk
array([[0, 2, 2],
       [0, 0, 2],
       [0, 0, 0]])
property matrix_duels_ut

2d array of integers. matrix_duels_ut[c, d] is the number of voters who have a strictly greater utility for c than for d. By convention, diagonal coefficients are set to 0.

>>> from svvamp import Profile
>>> profile = Profile(preferences_rk=[[0, 1, 2], [0, 1, 2]])
>>> profile.matrix_duels_ut
array([[0, 2, 2],
       [0, 0, 2],
       [0, 0, 0]])
property n_c

Number of candidates.

Type:

int

property n_v

Number of voters.

Type:

int

property plurality_scores_rk

1d array of int. plurality_scores_rk[c] is the number of voters for whom c is the top-ranked candidate (with voter tie-breaking).

>>> from svvamp import Profile
>>> profile = Profile(preferences_rk=[[0, 1, 2], [0, 1, 2]])
>>> profile.plurality_scores_rk
array([2, 0, 0])
property plurality_scores_ut

plurality scores, relying on ‘ut’ preferences.

Examples

>>> profile_s = Profile(preferences_ut=[[1., .5, 0.], [.5, 1., 0.]])
>>> profile_um = ProfileUM(profile_s=profile_s, n_m=2, ballot_ut=[0., 1., 0.])
>>> profile_um.plurality_scores_ut
array([1., 3., 0.])
Type:

List

property preferences_borda_rk

2d array of integers. preferences_borda_rk[v, c] gains 1 point for each candidate d such that voter v ranks c before d. So, these Borda scores are between 0 and C - 1.

property preferences_borda_ut

preferences, in ‘borda ut’ format.

Examples

>>> profile_s = Profile(preferences_ut=[[1., .5, 0.], [.5, 1., 0.]])
>>> profile_um = ProfileUM(profile_s=profile_s, n_m=2, ballot_ut=[0., 1., 0.])
>>> profile_um.preferences_borda_ut
array([[2. , 1. , 0. ],
       [1. , 2. , 0. ],
       [0.5, 2. , 0.5],
       [0.5, 2. , 0.5]])
Type:

List

property preferences_rk

2d array of integers. preferences_rk[v, k] is the candidate at rank k for voter v. For example, preferences_rk[v, 0] is v’s preferred candidate.

property preferences_ut

2d array of floats. preferences_ut[v, c] is the utility of candidate c as seen by voter v.