Combined Methods

Daunou

pref_voting.combined_methods.daunou(profile, curr_cands=None)[source]

Implementation of Daunou’s voting method as described in the paper: https://link.springer.com/article/10.1007/s00355-020-01276-w

If there is a Condorcet winner, then that candidate is the winner. Otherwise, iteratively remove all Condorcet losers then select the plurality winner from among the remaining candidates.

Parameters:
  • profile (Profile) – An anonymous profile of linear orders on a set of candidates

  • curr_cands (List[int], optional) – If set, then find the winners for the profile restricted to the candidates in curr_cands

Returns:

A sorted list of candidates

Example:

from pref_voting.profiles import Profile
from pref_voting.combined_methods import daunou
from pref_voting.scoring_methods import plurality

prof = Profile([[1, 3, 2, 0], [0, 2, 3, 1], [1, 3, 0, 2], [3, 1, 0, 2]], [1, 1, 1, 1])

prof.display()

daunou.display(prof)
plurality.display(prof)
+---+---+---+---+
| 1 | 1 | 1 | 1 |
+---+---+---+---+
| 1 | 0 | 1 | 3 |
| 3 | 2 | 3 | 1 |
| 2 | 3 | 0 | 0 |
| 0 | 1 | 2 | 2 |
+---+---+---+---+
Daunou winners are {1, 3}
Plurality winner is {1}

Blacks

pref_voting.combined_methods.blacks(profile, curr_cands=None)[source]

If a Condorcet winner exists return that winner. Otherwise, return the Borda winning set.

Parameters:
  • profile (Profile) – An anonymous profile of linear orders on a set of candidates

  • curr_cands (List[int], optional) – If set, then find the winners for the profile restricted to the candidates in curr_cands

Returns:

A sorted list of candidates

Example:

from pref_voting.profiles import Profile
from pref_voting.combined_methods import blacks
from pref_voting.scoring_methods import borda

prof = Profile([[2, 0, 1], [0, 1, 2], [2, 1, 0], [1, 2, 0]], [1, 1, 1, 1])

prof.display()

blacks.display(prof)
borda.display(prof)
+---+---+---+---+
| 1 | 1 | 1 | 1 |
+---+---+---+---+
| 2 | 0 | 2 | 1 |
| 0 | 1 | 1 | 2 |
| 1 | 2 | 0 | 0 |
+---+---+---+---+
Blacks winner is {2}
Borda winner is {2}

Condorcet IRV

pref_voting.combined_methods.condorcet_irv(profile, curr_cands=None)[source]

If a Condorcet winner exists, elect that candidate, otherwise return the instant runoff winners.

Parameters:
  • profile (Profile) – An anonymous profile of linear orders on a set of candidates

  • curr_cands (List[int], optional) – If set, then find the winners for the profile restricted to the candidates in curr_cands

Returns:

A sorted list of candidates

Example:

from pref_voting.profiles import Profile
from pref_voting.combined_methods import condorcet_irv
from pref_voting.iterative_methods import instant_runoff, instant_runoff_put

prof = Profile([[0, 2, 1, 3], [1, 3, 0, 2], [2, 1, 3, 0], [2, 3, 0, 1]], [1, 1, 1, 1])

prof.display()

instant_runoff.display(prof)
instant_runoff_put.display(prof)
condorcet_irv.display(prof)
+---+---+---+---+
| 1 | 1 | 1 | 1 |
+---+---+---+---+
| 0 | 1 | 2 | 2 |
| 2 | 3 | 1 | 3 |
| 1 | 0 | 3 | 0 |
| 3 | 2 | 0 | 1 |
+---+---+---+---+
Instant Runoff winner is {2}
Instant Runoff PUT winners are {0, 2}
Condorcet IRV winner is {2}

Condorcet IRV PUT

pref_voting.combined_methods.condorcet_irv_put(profile, curr_cands=None)[source]

If a Condorcet winner exists, elect that candidate, otherwise return the instant runoff put winners.

Parameters:
  • profile (Profile) – An anonymous profile of linear orders on a set of candidates

  • curr_cands (List[int], optional) – If set, then find the winners for the profile restricted to the candidates in curr_cands

Returns:

A sorted list of candidates

Example:

from pref_voting.profiles import Profile
from pref_voting.combined_methods import condorcet_irv_put
from pref_voting.iterative_methods import instant_runoff, instant_runoff_put

prof = Profile([[0, 2, 1, 3], [1, 3, 0, 2], [2, 1, 3, 0], [2, 3, 0, 1]], [1, 1, 1, 1])

prof.display()

instant_runoff.display(prof)
instant_runoff_put.display(prof)
condorcet_irv_put.display(prof)
+---+---+---+---+
| 1 | 1 | 1 | 1 |
+---+---+---+---+
| 0 | 1 | 2 | 2 |
| 2 | 3 | 1 | 3 |
| 1 | 0 | 3 | 0 |
| 3 | 2 | 0 | 1 |
+---+---+---+---+
Instant Runoff winner is {2}
Instant Runoff PUT winners are {0, 2}
Condorcet IRV PUT winners are {0, 2}

Smith IRV

pref_voting.combined_methods.smith_irv(profile, curr_cands=None)[source]

After restricting to the Smith Set, return the Instant Runoff winner.

Parameters:
  • profile (Profile) – An anonymous profile of linear orders on a set of candidates

  • curr_cands (List[int], optional) – If set, then find the winners for the profile restricted to the candidates in curr_cands

Returns:

A sorted list of candidates

Example:

from pref_voting.profiles import Profile
from pref_voting.combined_methods import smith_irv
from pref_voting.iterative_methods import instant_runoff, instant_runoff_put

prof = Profile([[0, 2, 1, 3], [1, 3, 0, 2], [2, 1, 3, 0], [2, 3, 0, 1]], [1, 1, 1, 1])

prof.display()

instant_runoff.display(prof)
instant_runoff_put.display(prof)
smith_irv.display(prof)
+---+---+---+---+
| 1 | 1 | 1 | 1 |
+---+---+---+---+
| 0 | 1 | 2 | 2 |
| 2 | 3 | 1 | 3 |
| 1 | 0 | 3 | 0 |
| 3 | 2 | 0 | 1 |
+---+---+---+---+
Instant Runoff winner is {2}
Instant Runoff PUT winners are {0, 2}
Smith IRV winner is {2}

Smith IRV PUT

pref_voting.combined_methods.smith_irv_put(profile, curr_cands=None)[source]

After restricting to the Smith Set, return the Instant Runoff winner.

Parameters:
  • profile (Profile) – An anonymous profile of linear orders on a set of candidates

  • curr_cands (List[int], optional) – If set, then find the winners for the profile restricted to the candidates in curr_cands

Returns:

A sorted list of candidates

Example:

from pref_voting.profiles import Profile
from pref_voting.combined_methods import smith_irv_put
from pref_voting.iterative_methods import instant_runoff, instant_runoff_put

prof = Profile([[0, 2, 1, 3], [1, 3, 0, 2], [2, 1, 3, 0], [2, 3, 0, 1]], [1, 1, 1, 1])

prof.display()

instant_runoff.display(prof)
instant_runoff_put.display(prof)
smith_irv_put.display(prof)
+---+---+---+---+
| 1 | 1 | 1 | 1 |
+---+---+---+---+
| 0 | 1 | 2 | 2 |
| 2 | 3 | 1 | 3 |
| 1 | 0 | 3 | 0 |
| 3 | 2 | 0 | 1 |
+---+---+---+---+
Instant Runoff winner is {2}
Instant Runoff PUT winners are {0, 2}
Smith IRV PUT winners are {0, 2}

Composing Voting Methods

pref_voting.combined_methods.compose(vm1, vm2)[source]

After restricting the profile to the set of vm1 winners, run vm2

Parameters:
Returns:

A VotingMethod that composes vm1 and vm2.

Example:

from pref_voting.profiles import Profile
from pref_voting.combined_methods import compose
from pref_voting.scoring_methods import borda
from pref_voting.c1_methods import copeland

prof = Profile([[1, 3, 0, 2], [2, 1, 3, 0], [3, 0, 2, 1]], [1, 2, 1])

prof.display()

copeland_borda = compose(copeland, borda)

copeland.display(prof)
borda.display(prof)
copeland_borda.display(prof)
+---+---+---+
| 1 | 2 | 1 |
+---+---+---+
| 1 | 2 | 3 |
| 3 | 1 | 0 |
| 0 | 3 | 2 |
| 2 | 0 | 1 |
+---+---+---+
Copeland winners are {1, 2}
Borda winners are {1, 2, 3}
Copeland-Borda winner is {2}

Condorcet Plurality

pref_voting.combined_methods.condorcet_plurality(profile, curr_cands=None)[source]

Return the Condorcet winner if one exists, otherwise return the plurality winners.

Parameters:
  • profile (Profile) – An anonymous profile of linear orders on a set of candidates

  • curr_cands (List[int], optional) – If set, then find the winners for the profile restricted to the candidates in curr_cands

Returns:

A sorted list of candidates

Smith-Minimax

pref_voting.combined_methods.smith_minimax(profile, curr_cands=None)[source]

Return the Minimax winner after restricting to the Smith set.

Parameters:
  • profile (Profile) – An anonymous profile of linear orders on a set of candidates

  • curr_cands (List[int], optional) – If set, then find the winners for the profile restricted to the candidates in curr_cands

Returns:

A sorted list of candidates

Copeland-Local-Borda

pref_voting.combined_methods.copeland_local_borda(profile, curr_cands=None)[source]

Return the Borda winner after restricting to the Copeland winners.

Parameters:
  • profile (Profile) – An anonymous profile of linear orders on a set of candidates

  • curr_cands (List[int], optional) – If set, then find the winners for the profile restricted to the candidates in curr_cands

Returns:

A sorted list of candidates

Copeland-Global-Borda

pref_voting.combined_methods.copeland_global_borda(profile, curr_cands=None)[source]

From the Copeland winners, return the candidate with the largest global Borda score.

Parameters:
  • profile (Profile) – An anonymous profile of linear orders on a set of candidates

  • curr_cands (List[int], optional) – If set, then find the winners for the profile restricted to the candidates in curr_cands

Returns:

A sorted list of candidates