-
Notifications
You must be signed in to change notification settings - Fork 21
Title: Implemented GPseq algorithm #44
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
Conversation
|
The test should be implemented with unittest2. Take inspiration from the other tests in the package. |
pabutools/rules/gpseq.py
Outdated
| """ | ||
|
|
||
| from __future__ import annotations | ||
| from typing import List |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the builtin type list and not this. The package typing should not be used now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it
pabutools/rules/gpseq.py
Outdated
| from pabutools.election.ballot.approvalballot import ApprovalBallot | ||
| from pabutools.tiebreaking import TieBreakingRule, lexico_tie_breaking | ||
| import numpy as np | ||
| import logging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No logging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it
pabutools/rules/gpseq.py
Outdated
| logging.info(f"project: {project.name} with cost {project.cost} and {float(max(new_loads))} max load") | ||
| return float(max(new_loads)) | ||
|
|
||
| if __name__ == '__main__': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the main
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it.
tests/test_gpseq.py
Outdated
| @@ -0,0 +1,83 @@ | |||
| """ | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be migrated to unittest2. The package does not use pytest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it.
|
See the comments I have left in the code and also for the other PR: (#43). |
|
Looks good, two more things: first please remove all the DS_Store files, second remove the setup.py. We use the pyproject.toml to handle all the details of the package itself, there is no need for a setup.py. |
Ok, I deleted it. |
|
Nice! Few extra things, sorry I had not paid attention to that before:
|
|
I added everything, please lets do it quickly. |
|
Your code has indentation problems. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #44 +/- ##
==========================================
- Coverage 89.67% 85.24% -4.43%
==========================================
Files 49 50 +1
Lines 3641 3708 +67
==========================================
- Hits 3265 3161 -104
- Misses 376 547 +171 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Fixed it, check now. |
|
Sorry, I'm now confused what rule is it that you implemented? The article you refer to does not exist. I'm confused as to what the difference is compared to the Phragmén's rule already implemented. Maybe @erelsgl knows? |
|
@Simon-Rey it is Algorithm 1 in this paper: https://arxiv.org/abs/1711.08226 |
|
So for now the implementation is not that of Algo 1 from Aziz et al. (which, by the way, is the maximin support rule despite the name they gave it, see the survey). The current implementation does:
This is not the maximin support rule because in the latter the load is constantly recompute, i.e., the LP in Algo 1 is run at each iteration so the spread of the load of a project (uniform in the current implementation) can change at each iteration. This is also not Sequential Phragmén as for the latter when selecting a project, the total load of its approvers is redistributed among them so that they all end up with the same load. Note that I have already implemented Sequential Phragmén in the package. The implementation is a simplified version of sequential phragmen in which the load of a voter is monotonic. I am not aware of this rule having been studied and I'm now not super sure of the usefulness of having it in the package. There may be something I missed in the implementation, please correct me if I'm wrong. |
|
You're right, I've now updated the implementation so that the load is distributed optimally rather than uniformly, and it now matches the algorithm described in the paper. |
|
Since the PR has been merged already you need to open a new one for me to see your code. Note that I have cleaned things around after the merge and that your code is now in the phragmen.py file. |
|
Okay, I’ve opened another one. |
Full implementation of the Greedy Phragmén algorithm (GPseq) with doctests and logging.