Skip to content

Commit

Permalink
Merge pull request #29 from tjhv10/main
Browse files Browse the repository at this point in the history
Added cstv algorithm and tests.
  • Loading branch information
Simon-Rey authored Jul 3, 2024
2 parents b1143eb + 37d17b4 commit 419daac
Show file tree
Hide file tree
Showing 5 changed files with 822 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,5 @@ cython_debug/
.idea/

analysis/Pabulib

.vscode/
25 changes: 25 additions & 0 deletions docs-source/source/usage/rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,31 @@ performances, one should use the following:
)
CSTV Algorithm
--------------

:py:func:`~pabutools.rules.cstv.cstv`

The `cstv` function implements the Cost-Sensitive Approval Voting algorithm for participatory budgeting. It takes into account both voter preferences and project costs to allocate budgets efficiently.

.. code-block:: python
from pabutools.election import Instance, Project, ApprovalProfile, ApprovalBallot
from pabutools.rules import cstv
projects = Instance(Project("Project A", 35), Project("Project B", 30))
instance = Instance(projects)
donors = Profile([CumulativeBallot({"Project A": 5, "Project B": 10), CumulativeBallot({"Project A": 5, "Project B": 10), CumulativeBallot({"Project A": 0, "Project B": 15), CumulativeBallot({"Project A": 8, "Project B": 7}), CumulativeBallot({"Project A": 10, "Project B": 5)])
alg_str = "ewt" # Look in the paper that is the insperation for this code in section 5.6
outcome1 = cstv_budgeting_combination(instance, donors, alg_str)
Details for the Budget Allocation Rule
--------------------------------------
The `cstv` function returns a :py:class:`~pabutools.rules.budgetallocation.BudgetAllocation` object, which includes information about the allocated budget and can be used for further analysis or visualization.
Exhaustion Methods
------------------
Expand Down
25 changes: 25 additions & 0 deletions docs/_sources/usage/rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,31 @@ performances, one should use the following:
)
CSTV Algorithm
--------------

:py:func:`~pabutools.rules.cstv.cstv`

The `cstv` function implements the Cost-Sensitive Approval Voting algorithm for participatory budgeting. It takes into account both voter preferences and project costs to allocate budgets efficiently.

.. code-block:: python
from pabutools.election import Instance, Project, ApprovalProfile, ApprovalBallot
from pabutools.rules import cstv
projects = Instance(Project("Project A", 35), Project("Project B", 30))
instance = Instance(projects)
donors = Profile([CumulativeBallot({"Project A": 5, "Project B": 10), CumulativeBallot({"Project A": 5, "Project B": 10), CumulativeBallot({"Project A": 0, "Project B": 15), CumulativeBallot({"Project A": 8, "Project B": 7}), CumulativeBallot({"Project A": 10, "Project B": 5)])
alg_str = "ewt" # Look in the paper that is the insperation for this code in section 5.6
outcome1 = cstv_budgeting_combination(instance, donors, alg_str)
Details for the Budget Allocation Rule
--------------------------------------
The `cstv` function returns a :py:class:`~pabutools.rules.budgetallocation.BudgetAllocation` object, which includes information about the allocated budget and can be used for further analysis or visualization.
Exhaustion Methods
------------------
Expand Down
Loading

0 comments on commit 419daac

Please sign in to comment.