Tie-Breaking#
- exception TieBreakingException[source]#
Raised when a tie occurs and no tie-breaking rule is provided.
- class TieBreakingRule(func: Callable[[AbstractTrichotomousProfile, Alternative], int | float | mpq])[source]#
Implements a tie-breaking rule.
- Parameters:
func (Callable[[TrichotomousProfile, Alternative], 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.
- Type:
Callable[[TrichotomousProfile, Alternative], Numeric]
- order(profile: AbstractTrichotomousProfile, alternatives: Iterable, key: Callable[[...], Alternative] | None = None) list[Alternative] [source]#
Break the ties among all the alternatives provided in input and returns them ordered.
- Parameters:
profile (TrichotomousProfile) – The profile.
alternatives (Iterable) – The set of alternatives between which ties are to be broken.
key (Callable[..., Alternative], optional) – A key function to select the value associated with each alternative, passed as the key argument of the sorted function. Defaults to lambda x: x.
- Returns:
The alternatives, ordered by the tie-breaking rule.
- Return type:
list[Alternative]
- untie(profile: AbstractTrichotomousProfile, alternatives: Iterable, key: Callable[[...], Alternative] | None = None) Alternative [source]#
Break the ties among all the alternatives provided in input and returns a single one of them. Orders the alternatives according to the tie-breaking rule and return the first element of the order.
- Parameters:
profile (TrichotomousProfile) – The profile.
alternatives (Iterable) – The set of alternatives between which ties are to be broken.
key (Callable[..., Alternative], optional) – A key function to select the value associated with each alternative, passed as the key argument of the sorted function. Defaults to lambda x: x.
- Returns:
The first alternative according to the tie-breaking order.
- Return type:
- app_score_tie_breaking = <trivoting.tiebreaking.TieBreakingRule object>#
Implements tie breaking based on the approval score where the projects with the highest approval score in the profile is selected.
- lexico_tie_breaking = <trivoting.tiebreaking.TieBreakingRule object>#
Implements lexicographic tie breaking, i.e., tie-breaking based on the name of the alternatives.
- refuse_tie_breaking = <trivoting.tiebreaking.TieBreakingRule object>[source]#
Special tie-breaking function that simply raises an error when a tie needs to be broken.
- support_tie_breaking = <trivoting.tiebreaking.TieBreakingRule object>#
Implements tie breaking based on the support where the projects with the highest support in the profile is selected.