Skip to content

Feature: Add Fair Lotteries algorithms and GCR baseline#67

Open
dotandanino wants to merge 31 commits into
COMSOC-Community:mainfrom
dotandanino:main
Open

Feature: Add Fair Lotteries algorithms and GCR baseline#67
dotandanino wants to merge 31 commits into
COMSOC-Community:mainfrom
dotandanino:main

Conversation

@dotandanino

Copy link
Copy Markdown

Description

This PR introduces the randomized algorithms from the AAAI-24 paper "Fair Lotteries for Participatory Budgeting," alongside a baseline implementation of the Greedy Cohesive Rule (GCR).

Files Added

  • Fair_Lotteries_for_Participatory_Budgeting.py
  • pabutools/rules/gcr/ (module files)
  • pabutools/rules/lottery/ (module files)
  • tests/test_bw_algorithms.py

Testing

  • All 151 tests and 85 subtests pass successfully locally.

Comment thread pabutools/rules/gcr/gcr_rule.py
Comment thread pabutools/rules/lottery/lottery_rule.py Outdated
Comment thread pabutools/rules/lottery/lottery_rule.py
Comment thread pabutools/rules/lottery/lottery_rule.py
Comment thread Fair_Lotteries_for_Participatory_Budgeting.py Outdated
Comment thread pabutools/analysis/justifiedrepresentation.py Outdated
Comment thread pabutools/analysis/justifiedrepresentation.py Outdated
Comment thread pabutools/analysis/justifiedrepresentation.py Outdated

@Simon-Rey Simon-Rey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your submission. I have quickly looked at the formatting/writing up of the code. There are few comments of the things I would like you to fix before merging ;)

I have not checked the code itself, I assume that you have included sufficient tests to trust that the functions behave as expected.

Comment thread .gitignore

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't add your personal gitignore to the repositoruy

Comment thread .flake8 Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is that file for?

Comment thread pabutools/fractions.py
"""
# Normalize numpy scalars (and similar) to plain Python ints/floats so that
# gmpy2.mpq and arithmetic operators accept them without errors.
normalized = []

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a sensitive function because it is used everywhere so we need to keep efficient. I'm not a huge fan of instantiating a list for that reason. Maybe do the a.item() directly in the ifs, without using a list.

yield ApprovalProfile([ApprovalBallot(b) for b in p], instance=instance)


def approval_profile_from_matrix(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be generalised into a more useful function: By default instantiate a Cardinal ballot from a matrix with any weights. Add a 'to_approval' is true, then it returns an Approval Ballot for each weight that is above a parametrised threshold (default to 0).

That would make the function more useful overall.

return True


def check_strong_UFS(self, N: list, C: list, cost: dict, B: float, ui: dict, p_vec: list) -> bool:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add doc string to these functions.

@Simon-Rey Simon-Rey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the improvements. I've made some new comments, we're almost there ;)

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

Successfully merging this pull request may close these issues.

3 participants