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.

Type:

Callable[[Collection[Project], Profile, Project], Numeric]

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:
  • instance (Instance) – The instance.

  • profile (Profile) – The profile.

  • projects (Iterable[Project]) – The set of projects between which ties are to be broken.

  • key (Callable[…, Project], optional) – A key function to select the project from the input. Defaults to lambda x: x.

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:
  • instance (Instance) – The instance.

  • profile (Profile) – The profile.

  • projects (Iterable[Project]) – The set of projects between which ties are to be broken.

  • key (Callable[…, Project], optional) – A key function to select the project from the input. Defaults to lambda x: x.

Returns:

The first project according to the tie-breaking.

Return type:

Project

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.