Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SchulzePR bug with ties #15

Open
itamaro opened this issue Jul 20, 2013 · 1 comment
Open

SchulzePR bug with ties #15

itamaro opened this issue Jul 20, 2013 · 1 comment

Comments

@itamaro
Copy link

itamaro commented Jul 20, 2013

It seems SchulzePR is misbehaving, at least with the ballot input I have "engineered":

Python 2.7.4 (default, Apr 19 2013, 18:28:01) 
[GCC 4.7.3] on linux2
>>> from pyvotecore.schulze_pr import SchulzePR
>>> b=[{'count': 1, 'ballot': [[1, 2, 3, 4], [0]]},
       {'count': 1, 'ballot': [[3], [0, 1, 2, 4]]},
       {'count': 1, 'ballot': [[0], [1, 2, 3, 4]]}]
>>> SchulzePR(b, ballot_notation="grouping").as_dict()
{'tie_breaker': [4, 0, 3, 1, 2],
 'candidates': set([0, 1, 2, 3, 4]),
 'order': [3, 0, 4, 1, 2],
 'rounds': [{'winner': 3},
            {'winner': 0},
            {'winner': 4},
            {'winner': 1, 'tied_winners': set([1, 2])},
            {'winner': 2}]}

The anomaly, as I see it, lies in the fact that in the ballot the candidates 1, 2 and 4 are always in the same group, so essentially they must be also grouped together in the results. But in the output you can see that for some reason candidate 4 is above candidates 1 and 2 that are tied.

Am I missing something?

@bradbeattie
Copy link
Owner

My intuition certainly agrees with yours. We might be able to construct a simpler scenario to test this as well.

>>> SchulzePR([{"ballot": [[1,2,3],[4]]}, {"ballot": [[1],[2,3,4]]}], ballot_notation="grouping").rounds
[{'winner': 1}, {'winner': 3, 'tied_winners': set([2, 3])}, {'winner': 2}, {'winner': 4}]

>>> SchulzePR([{"ballot": [[1,2,3],[4]]}, {"ballot": [[1],[2,3,4]]}, {"ballot":[[4],[1,2,3]]}], ballot_notation="grouping").rounds
[{'winner': 1}, {'winner': 4}, {'winner': 3, 'tied_winners': set([2, 3])}, {'winner': 2}]

>>> SchulzePR([{"ballot": [[1,2,3],[4,5]]}, {"ballot": [[1],[2,3,4,5]]}, {"ballot":[[4,5],[1,2,3]]}], ballot_notation="grouping").rounds
[{'winner': 1}, {'winner': 5, 'tied_winners': set([4, 5])}, {'winner': 3, 'tied_winners': set([2, 3])}, {'winner': 4}, {'winner': 2}]

Okay, I'm veering away from simpler here. I'll take a deeper look into it next week when I have a chance. Thanks for reporting this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants