fairvotereform / RankIt

https://rankit.vote
1 stars 2 forks source link

Eliminated choices are rearranged between rounds #130

Closed ggordn3r closed 4 years ago

ggordn3r commented 4 years ago

See attached movie from Emily at FairVote. Github made me zip it. Choices should sort descending based on Round 1 votes, but this one didn't. The poll is live and no longer shows this issue, so it may only occur before a certain threshold? Reported 10:26am on May 28th.

Here's the poll and round in question: https://rankit.vote/results/4Hsz7S52qroohfbTKsLB/1

Results .zip ploads.

proggeramlug commented 4 years ago

Hm, hard to debug. Let's observe it but unless we can reliably reproduce it's not helpful to spend time here.

Could you see if you can reproduce it?

ggordn3r commented 4 years ago

Update 7/29: This poll no longer exhibits the behavior described below, presumably because more people have voted in it. However, I found a new poll and have a better explanation for the behavior in the next comment.

I found another example in a more recent poll and was able to reproduce: https://rankit.vote/results/2dRIuBr22njWRKVXGp7U/summary

For me, the summary view first showed the winner in the second slot with 50%, with the runner up in slot 7 or 8 (also at 50%) and all other choices eliminated. Both of those should be close to the top, probably within the first 4 slots. Moving to Round 1, I see that the choice in 1st place in Round 1 was not the ultimate winner--that could be a clue to this bug. All views should preserve the choices in descending order for # of votes in Round 1, even if the ultimate winner is not the leader in that round. If I navigate through the rounds, then go back to the summary, the order in the summary is corrected to the last round in the round-by-round walkthrough.

I had one idea--could it be related to the "randomize order" setting on the Create Poll page? (see below) That should randomize the order of choices during voting, but not in results.

Screenshot (350)_LI

ggordn3r commented 4 years ago

Hmm... the last example no longer applies, but I think I may have figured this out:

The order of eliminated choices switches when votes are reallocated from winners in multi-winner polls. I think this is because the next choice for some ballots has already been eliminated. That triggers a reordering of eliminated choices. See, for example: https://rankit.vote/results/7EsrKw7yUlgHD33T6CgP/summary

Viewed on staging, you can follow the vote totals through the choices to see what I'm talking about--notice how the 3 votes reallocated in round 2 all end up inactive: https://rankit.skelpo.com/results/7EsrKw7yUlgHD33T6CgP/1

Expected behavior is that the order should not update with each round, but be fixed as descending order in the first round.

proggeramlug commented 4 years ago

So it looks like Stephen implemented some sorting logic here. Like votes with 0 votes are moved to the bottom and then votes are sorted so that the highest number is at the top.

If I take that logic out the order remains the same. So do we want to have that sorting or should we keep the order only after the first round of sorting according to that logic?

I've taken it out and put it online so we can see it btw.

ggordn3r commented 4 years ago

Hey Ralph--Stephen was actually attempting a fix to a related issue that I didn't include here. Sorry about that. Could you implement his sorting logic and kick it back to me and him?

proggeramlug commented 4 years ago

Back in!

ggordn3r commented 4 years ago

Ok, I'd like us to attempt the "once and for all" fix on sorting: ordering by final results. In this scheme, winners are at the top of the chart in order of election (i.e. ascending by round: 1st elected = 1st bar) and eliminated choices are at the bottom of the chart in order of elimination (i.e. descending by round: 1st eliminated = last bar)

Chris, the Fairvote developer, says he extended the "elected" and "eliminated" output in a way that enables this sort. I'm adding his full reply below:

I saw your note about the display order in your last email. I added the info necessary for the display order to the stv function output. The "elected" output is no longer just a list and now contains a dictionary with "name", "round", and "votes". The "eleminated output variable contains the same info now too. (The votes can be used as tie-breakers for candidates elected or eliminated in the same round). Let me know if this works.

proggeramlug commented 4 years ago

Okay, I attempted to get this right. Check it out. The only element of "randomness" we have is when there are choices with the same number of votes. Then it might be random every time we calculate the results.

Also, I implemented that if we have not had the new algorithm run through a poll, it will do that on the spot on the results and reload the page.

ggordn3r commented 4 years ago

Excellent! Unfortunately I can't test this fully until #156 is resolved. I did notice one thing though: it looks like choices that received no votes don't appear at all. See, for example: https://rankit.skelpo.com/results/7EsrKw7yUlgHD33T6CgP/summary

That's incorrect--if this is following the algorithm with the new pull request, those should show up as eliminated in the second round.

proggeramlug commented 4 years ago

See #156

proggeramlug commented 4 years ago

The other is I just fixed! :)

ggordn3r commented 4 years ago

I'm still seeing choices out of order when more than one choice is tied for last. Try toggling through a few of these rounds: https://rankit.skelpo.com/results/eaub53HYQM70lX5J8az7/1

Expected order is winners ascending by round (this seems to be working), then eliminated descending by round (not working).

proggeramlug commented 4 years ago

Okay, problem was: Both were nominated in the same round.

I fixed it by saying that if they are in the same round we also sort them by votes and if they have the same amount of votes (like in this case) we sort alphabetically. Check it out!

ggordn3r commented 4 years ago

Hmm... that's better but still not spec. The order should follow the elimination order, as below. Where the bar is already in the right place, I add "correct" beside it:

proggeramlug commented 4 years ago

Okay, I think I finally fixed the order for good. One thing though: in the last round the 2 winners are crossed off here (because they are technically not in that round), is that correct?

proggeramlug commented 4 years ago

okay, this is #158, you already mentioned it there, nevermind :)

ggordn3r commented 4 years ago

Sooo close, but Hawaii (first choice with votes to be eliminated) shows up below all the choices with 0 votes when it should show up above them. Scroll to the bottom in this round to see it in action: https://rankit.skelpo.com/results/eaub53HYQM70lX5J8az7/2

proggeramlug commented 4 years ago

Now!