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

Add tests for final ranking of test ballots #52

Open
carlschroedl opened this issue Oct 22, 2017 · 5 comments
Open

Add tests for final ranking of test ballots #52

carlschroedl opened this issue Oct 22, 2017 · 5 comments
Assignees
Milestone

Comments

@carlschroedl
Copy link
Member

This issue is a follow-on to #42. We added many test ballots. We added tests to check that the correct margins were produced by the MarginCalculator class. Now we need to add tests to assert that the RankedPairsCalculator class can produce the correct final ranking given the margins returned by the MarginCalculator class.

A google drive spreadsheet defines the ballots, the expected margins, and the expected final rankings for several scenarios. The expected final rankings in the spreadsheet currently include ties, but that is incorrect -- our implementation breaks ties. Before we create the RankedPairsCalculator tests, we need to update the expected final rankings in the spreadsheet to reflect our implementation's tie-breaking scheme. The tie-breaking scheme is mentioned in the README. It is implemented in the following classes:

https://github.com/pivot-libre/tideman/blob/0.x/src/MarginTieBreaker.php
https://github.com/pivot-libre/tideman/blob/0.x/src/TieBreakingMarginComparator.php
https://github.com/pivot-libre/tideman/blob/0.x/src/TotallyOrderedBallotMarginTieBreaker.php

@julien-boudry
Copy link

julien-boudry commented Dec 14, 2017

Hi,

If you're interested. I collected many examples from various sources, to build many tests for my Condorcet PHP:
https://github.com/julien-boudry/Condorcet/blob/master/Tests/lib/Algo/Methods/RankedPairsTest.php

It should be noted that not all examples use the margin for ranking the pairs. Documentation on this subject is very divided. However, with the exception of test number 11, all give the same results.

Since we use the same language, it might even be conceivable for us to cross-test our implementations, it would be quite easy to do.
I'll check your tests and see if I can backport them.

@carlschroedl
Copy link
Member Author

Hi @julien-boudry ! We admire your work. Thanks for noting a good area for us to collaborate! I like the way you are encoding the test ballots. I wonder if there is an opportunity to define a small standalone repo that defines file formats and parsers for preferential ballots, margins, and results? This would enable people to share election test scenarios across multiple applications. What do you think?

@julien-boudry
Copy link

julien-boudry commented Dec 15, 2017

Hi,

I think it's a great idea.

For ballot

I use a very simple format describe here :
https://github.com/julien-boudry/Condorcet/wiki/II-%23-B.-Vote-management-%23-1.-Add-Vote

For Result

Same way:

$election->getResult('Schulze Winning')->getResultAsString(); // Return a string like "A > B = C > D > E > G = H"

For Condorcet pairwise

I do not provide a real standard format. However, there is a method that can be easily converted to user output.

$election>getPairwise(false)->getExplicitPairwise(); // Return a simple array with candidate as string (by name) instead object.

Look like :
image

For method stats

The case is more complicated. These stats depend on the method used, and I implement very different ones.

Without much work of reflection and standardization, however, I have implemented for each one a few data that are specific to them.

$election->getResult('Ranked Pairs Margin')->getStats() ; // Return an explicit array with candidate as string name.

Example with Ranked Pairs (test number 8) :

image

@julien-boudry
Copy link

julien-boudry commented Dec 15, 2017

Perhaps I could consider writing a more formal documentation at least for the votes and results. And create the corresponding repository.

However, I won't really have much time this month. But I keep the idea!

@carlschroedl
Copy link
Member Author

Great ideas @julien-boudry ! Our group has a meeting tomorrow. I will talk about your ideas at the meeting.

@tylerharter tylerharter added this to the MVP milestone Jul 4, 2018
This was referenced Jul 6, 2018
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

3 participants