pairwisecomparisons

This module describes several procedures to check for properties based on pairwise comparisons.

borda_scores(instance)

Computes the total Borda scores of all the alternatives of the instance. Within an indifference class, all alternatives are assigned the smallest score one alternative from the class would have gotten, had the order been strict. For instance, for the order ({a1}, {a2, a3}, {a4}), a1 gets score 3, a2 and a3 score 1 and a4 score 0.

Parameters:

instance (preflibtools.instances.preflibinstance.PreflibInstance) – The instance.

Returns:

A dictionary mapping every instance to their Borda score.

Return type:

dict

copeland_scores(instance)

Returns a dictionary of dictionaries mapping every alternative a to their Copeland score against every other alternative b (the number of voters preferring a over b minus the number of voters preferring b over a).

Parameters:

instance (preflibtools.instances.preflibinstance.PreflibInstance) – The instance.

Returns:

A dictionary of dictionaries storing the scores.

Return type:

dict

has_condorcet(instance, weak_condorcet=False)

Checks whether the instance has a Condorcet winner, using different procedures depending on the data type of the instance. An alternative is a Condorcet winner if it strictly beats every other alternative in a pairwise majority contest. An alternative is a weak Condorcet winner if it strictly beats or ties every other alternative in a pairwise majority contest.

Parameters:
  • instance (preflibtools.instances.preflibinstance.PreflibInstance) – The instance.

  • weak_condorcet (bool) – Boolean indicating whether to consider weak-Condorcet winners or not.

Returns:

A boolean indicating whether the instance has a Condorcet winner or not.

Return type:

bool

pairwise_scores(instance)

Returns a dictionary of dictionaries mapping every alternative a to the number of times it beats every other alternative b (the number of voters preferring a over b).

Parameters:

instance (preflibtools.instances.preflibinstance.PreflibInstance) – The instance.

Returns:

A dictionary of dictionaries storing the scores.

Return type:

dict