Tie-Breaking#
- exception TieBreakingException[source]#
Raised when a tie occurs and no tie-breaking rule is provided.
- class TieBreakingRule(func: Callable[[Collection[Project], AbstractProfile, Project], int | float | mpq])[source]#
Implements a tie-breaking rule.
- Parameters:
func (Callable[[Collection[Project], Profile, Project], Numeric]) – A function taking as input an instance, a profile and a project and returning the value on which the project will be sorted.
- func#
A function taking as input an instance, a profile and a project and returning the value on which the project will be sorted.
- order(instance: Collection[Project], profile: AbstractProfile, projects: Collection[Project], key: Callable[[...], Project] | None = None) list[Project] [source]#
Break the ties among all the projects provided in input and returns them ordered. The tie-breaking can be based on the instance or/and on the profile.
- Parameters:
- Returns:
The projects, ordered by the tie-breaking.
- Return type:
list[
Project
]
- untie(instance: Collection[Project], profile: AbstractProfile, projects: Collection[Project], key: Callable[[...], Project] | None = None) Project [source]#
Break the ties among all the projects provided in input and returns a single project. Orders the projects according to the tie-breaking rule and return the first project of the order.
- Parameters:
- Returns:
The first project according to the tie-breaking.
- Return type:
- app_score_tie_breaking = <pabutools.tiebreaking.TieBreakingRule object>#
Implements tie breaking based on the approval score wher the projects with the highest number of supporters in the profile is selected. Can only be applied to approval profiles.
- lexico_tie_breaking = <pabutools.tiebreaking.TieBreakingRule object>#
Implements lexicographic tie breaking, i.e., tie-breaking based on the name of the projects.
- max_cost_tie_breaking = <pabutools.tiebreaking.TieBreakingRule object>#
Implements lexicographic tie breaking based on the cost where ties are broken in favour of the project with the highest cost.
- min_cost_tie_breaking = <pabutools.tiebreaking.TieBreakingRule object>#
Implements lexicographic tie breaking based on the cost where ties are broken in favour of the project with the lowest cost.
- refuse_tie_breaking = <pabutools.tiebreaking.TieBreakingRule object>#
Special tie-breaking function that simply raises an error when a tie needs to be broken.