Skip to content

Commit

Permalink
Ajout utilitarian completion dans MESadd1.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Berkho committed Jul 15, 2024
1 parent cc6035b commit d9c4992
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions whalrus/participatories_budgeting/mes_add1.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
from whalrus.utils.utils import cached_property, my_division, NiceDict, DeleteCacheMixin, NiceSet
from whalrus.priorities.priority_budgeting import PriorityBudgeting
from whalrus.converters_ballot.converter_ballot import ConverterBallot
from whalrus.participatories_budgeting.equal_shares import EqualShares
from whalrus.participatories_budgeting.equal_shares import EqualShares
from whalrus.participatories_budgeting.mes_utilitarian_completion import MesUtilitarianCompletion
from typing import Union

import numpy as np

class MesAdd1(EqualShares):

def __init__(self,*args, add1u = False, stop_exhaustion = False, integral_endowments = False, **kwargs) -> None:
self.add1u = add1u
self.stop_exhaustion = stop_exhaustion
self.integral_endowments = integral_endowments
super().__init__(*args, **kwargs)
Expand All @@ -40,7 +42,7 @@ def equal_shares(self):
is_exhaustive = False
break
if is_exhaustive and self.stop_exhaustion:
break
break

next_budget = budget + len(self.voters_)
next_mes = list(EqualShares(self.profile_converted_, budget = next_budget, project_cost = self.project_cost, base_rule = self.base_rule_).winners_)
Expand All @@ -51,4 +53,6 @@ def equal_shares(self):
else:
break

if self.add1u:
mes = MesUtilitarianCompletion(self.profile_converted_, budget = self.budget, project_cost = self.project_cost, base_rule = self.base_rule_).utilitarian_completion_(mes)[0]
return mes

0 comments on commit d9c4992

Please sign in to comment.