Skip to content

Commit

Permalink
Merge pull request #96 from wesholliday/main
Browse files Browse the repository at this point in the history
Added positive_involvement to voting method properties, added Schwartz sequential dropping algorithm for Beat Path
  • Loading branch information
epacuit authored May 5, 2024
2 parents 244c52e + 134f1d0 commit 648a7c5
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 48 deletions.
10 changes: 9 additions & 1 deletion docs/source/scoring_methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,15 @@ One problem with the above code is that the name of the scoring rule is "Scoring

```{eval-rst}
.. autofunction:: pref_voting.scoring_methods.anti_plurality(profile, curr_cands = None)
.. autofunction:: pref_voting.scoring_methods.anti_plurality
```

## Dowdall

```{eval-rst}
.. autofunction:: pref_voting.scoring_methods.dowdall
```

Expand Down
21 changes: 16 additions & 5 deletions pref_voting/c1_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
condorcet_properties = VotingMethodProperties(
condorcet_winner=True,
condorcet_loser=False,
pareto_dominance=False,)
pareto_dominance=False,
positive_involvement=False,
)
@vm(name = "Condorcet",
properties = condorcet_properties,
input_types = [ElectionTypes.PROFILE, ElectionTypes.PROFILE_WITH_TIES, ElectionTypes.MAJORITY_GRAPH, ElectionTypes.MARGIN_GRAPH])
Expand Down Expand Up @@ -75,7 +77,9 @@ def condorcet(edata, curr_cands = None):
copeland_properties = VotingMethodProperties(
condorcet_winner=True,
condorcet_loser=True,
pareto_dominance=True,)
pareto_dominance=True,
positive_involvement=False,
)
@vm(name = "Copeland",
properties = copeland_properties,
input_types = [ElectionTypes.PROFILE, ElectionTypes.PROFILE_WITH_TIES, ElectionTypes.MAJORITY_GRAPH, ElectionTypes.MARGIN_GRAPH])
Expand Down Expand Up @@ -162,7 +166,9 @@ def copeland_ranking(edata, curr_cands=None, local=True, tie_breaking=None):
llull_properties = VotingMethodProperties(
condorcet_winner=True,
condorcet_loser=True,
pareto_dominance=True,)
pareto_dominance=True,
positive_involvement=False,
)
@vm(name = "Llull",
properties = llull_properties,
input_types = [ElectionTypes.PROFILE, ElectionTypes.PROFILE_WITH_TIES, ElectionTypes.MAJORITY_GRAPH, ElectionTypes.MARGIN_GRAPH])
Expand Down Expand Up @@ -228,6 +234,7 @@ def right_covers(dom, c1, c2):
condorcet_winner=True,
condorcet_loser=True,
pareto_dominance=True,)

@vm(name = "Uncovered Set",
properties = uc_gill_properties,
input_types = [ElectionTypes.PROFILE, ElectionTypes.PROFILE_WITH_TIES, ElectionTypes.MAJORITY_GRAPH, ElectionTypes.MARGIN_GRAPH])
Expand Down Expand Up @@ -544,7 +551,9 @@ def uc_mckelvey(edata, curr_cands = None):
top_cycle_properties = VotingMethodProperties(
condorcet_winner=True,
condorcet_loser=True,
pareto_dominance=True,)
pareto_dominance=True,
positive_involvement=False,
)
@vm(name = "Top Cycle",
properties = top_cycle_properties,
input_types = [ElectionTypes.PROFILE, ElectionTypes.PROFILE_WITH_TIES, ElectionTypes.MAJORITY_GRAPH, ElectionTypes.MARGIN_GRAPH])
Expand Down Expand Up @@ -645,7 +654,9 @@ def top_cycle_defeat(edata, curr_cands = None):
gocha_properties = VotingMethodProperties(
condorcet_winner=True,
condorcet_loser=True,
pareto_dominance=True,)
pareto_dominance=True,
positive_involvement=False,
)
@vm(name = "GOCHA",
properties = gocha_properties,
input_types = [ElectionTypes.PROFILE, ElectionTypes.PROFILE_WITH_TIES, ElectionTypes.MAJORITY_GRAPH, ElectionTypes.MARGIN_GRAPH])
Expand Down
51 changes: 37 additions & 14 deletions pref_voting/combined_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
daunou_properties = VotingMethodProperties(
condorcet_winner=True,
condorcet_loser=True,
pareto_dominance=True,)
pareto_dominance=True,
positive_involvement=False,
)
@vm(name = "Daunou",
properties = daunou_properties,
input_types = [ElectionTypes.PROFILE])
Expand Down Expand Up @@ -68,7 +70,9 @@ def daunou(profile, curr_cands=None):
blacks_properties = VotingMethodProperties(
condorcet_winner=True,
condorcet_loser=True,
pareto_dominance=True,)
pareto_dominance=True,
positive_involvement=False,
)
@vm(name = "Blacks",
properties = blacks_properties,
input_types = [ElectionTypes.PROFILE])
Expand Down Expand Up @@ -112,7 +116,9 @@ def blacks(profile, curr_cands=None):
smith_irv_properties = VotingMethodProperties(
condorcet_winner=True,
condorcet_loser=True,
pareto_dominance=True,)
pareto_dominance=True,
positive_involvement=False,
)
@vm(name = "Smith IRV",
properties = smith_irv_properties,
input_types = [ElectionTypes.PROFILE])
Expand Down Expand Up @@ -151,7 +157,9 @@ def smith_irv(profile, curr_cands=None):
smith_irv_put_properties = VotingMethodProperties(
condorcet_winner=True,
condorcet_loser=True,
pareto_dominance=True,)
pareto_dominance=True,
positive_involvement=False,
)
@vm(name = "Smith IRV PUT",
properties = smith_irv_put_properties,
input_types = [ElectionTypes.PROFILE])
Expand Down Expand Up @@ -190,7 +198,10 @@ def smith_irv_put(profile, curr_cands=None):
condorcet_irv_properties = VotingMethodProperties(
condorcet_winner=True,
condorcet_loser=True,
pareto_dominance=True,)
pareto_dominance=True,
positive_involvement=False,
)

@vm(name = "Condorcet IRV",
properties = condorcet_irv_properties,
input_types = [ElectionTypes.PROFILE])
Expand Down Expand Up @@ -231,7 +242,9 @@ def condorcet_irv(profile, curr_cands=None):
condorcet_irv_put_properties = VotingMethodProperties(
condorcet_winner=True,
condorcet_loser=True,
pareto_dominance=True,)
pareto_dominance=True,
positive_involvement=False,
)
@vm(name = "Condorcet IRV PUT",
properties = condorcet_irv_put_properties,
input_types = [ElectionTypes.PROFILE])
Expand Down Expand Up @@ -324,7 +337,9 @@ def _vm(edata, curr_cands=None):
condorcet_plurality_properties = VotingMethodProperties(
condorcet_winner=True,
condorcet_loser=False,
pareto_dominance=True,)
pareto_dominance=True,
positive_involvement=False,
)
@vm(name = "Condorcet Plurality",
properties = condorcet_plurality_properties,
input_types = [ElectionTypes.PROFILE])
Expand All @@ -343,12 +358,14 @@ def condorcet_plurality(profile, curr_cands = None):
return _compose(condorcet, plurality)(profile, curr_cands=curr_cands)


smith_minimax_plurality_properties = VotingMethodProperties(
smith_minimax_properties = VotingMethodProperties(
condorcet_winner=True,
condorcet_loser=True,
pareto_dominance=True,)
pareto_dominance=True,
positive_involvement=True,
)
@vm(name="Smith-Minimax",
properties=smith_minimax_plurality_properties,
properties=smith_minimax_properties,
input_types=[ElectionTypes.PROFILE, ElectionTypes.PROFILE_WITH_TIES, ElectionTypes.MARGIN_GRAPH])
def smith_minimax(edata, curr_cands = None):
"""Return the Minimax winner after restricting to the Smith set.
Expand All @@ -367,7 +384,9 @@ def smith_minimax(edata, curr_cands = None):
copeland_local_borda_properties = VotingMethodProperties(
condorcet_winner=True,
condorcet_loser=True,
pareto_dominance=True,)
pareto_dominance=True,
positive_involvement=False,
)
@vm(name="Copeland-Local-Borda",
properties=copeland_local_borda_properties,
input_types=[ElectionTypes.PROFILE, ElectionTypes.MARGIN_GRAPH])
Expand Down Expand Up @@ -414,7 +433,9 @@ def _vm(profile, curr_cands=None):
copeland_global_borda_properties = VotingMethodProperties(
condorcet_winner=True,
condorcet_loser=True,
pareto_dominance=True,)
pareto_dominance=True,
positive_involvement=False,
)
@vm(name="Copeland-Global-Borda",
properties=copeland_global_borda_properties,
input_types=[ElectionTypes.PROFILE])
Expand Down Expand Up @@ -505,7 +526,9 @@ def _vm(edata, curr_cands=None):
borda_minimax_faceoff_properties = VotingMethodProperties(
condorcet_winner=True,
condorcet_loser=True,
pareto_dominance=True,)
pareto_dominance=True,
positive_involvement=False,
)
@vm(name="Borda-Minimax Faceoff",
properties=borda_minimax_faceoff_properties,
input_types=[ElectionTypes.PROFILE])
Expand All @@ -524,4 +547,4 @@ def borda_minimax_faceoff(edata, curr_cands=None):
"""

return _faceoff(borda, minimax)(edata, curr_cands=curr_cands)
return _faceoff(borda, minimax)(edata, curr_cands=curr_cands)
2 changes: 1 addition & 1 deletion pref_voting/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def weak_orders(A):
yield {}
return
for k in range(1, len(A) + 1):
for B in itertools.combinations(A, k):
for B in combinations(A, k):
for order in weak_orders(set(A) - set(B)):
new_order = {cand: rank + 1 for cand, rank in order.items()}
yield {**new_order, **{cand: 0 for cand in B}}
Expand Down
Loading

0 comments on commit 648a7c5

Please sign in to comment.