For ordinal extensions

class embedded_voting.ManipulationOrdinal(ratings, embeddings, rule_positional, rule=None)[source]

This class extends the Manipulation class to ordinal rule_positional (irv, borda, plurality, etc.).

Parameters:
  • ratings (Profile) – The ratings of voters on which we do the analysis.
  • embeddings (Embeddings) – The embeddings of the voters.
  • rule_positional (RulePositional) – The ordinal rule_positional used.
  • rule (Rule) – The aggregation rule we want to analysis.
rule

The aggregation rule we want to analysis.

Type:Rule
winner_

The index of the winner of the election without manipulation.

Type:int
welfare_

The welfares of the candidates without manipulation.

Type:float list
extended_rule

The rule we are analysing

Type:Rule
rule_positional

The rule_positional used.

Type:RulePositional

Examples

>>> np.random.seed(42)
>>> ratings_dim_candidate = [[1, .2, 0], [.5, .6, .9], [.1, .8, .3]]
>>> embeddings = EmbeddingsGeneratorPolarized(10, 3)(.8)
>>> ratings = RatingsFromEmbeddingsCorrelated(coherence=.8, ratings_dim_candidate=ratings_dim_candidate)(embeddings)
>>> rule_positional = RulePositionalBorda(3)
>>> manipulation = ManipulationOrdinal(ratings, embeddings, rule_positional, RuleSVDNash())
>>> manipulation.prop_manipulator_
0.0
>>> manipulation.manipulation_global_
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
>>> manipulation.avg_welfare_
1.0
manipulation_voter(i)[source]

This function return, for the i^th voter, its favorite candidate that he can turn to a winner by manipulating the election.

Parameters:i (int) – The index of the voter.
Returns:The index of the best candidate that can be elected by manipulation.
Return type:int

Particular cases

Borda

class embedded_voting.ManipulationOrdinalBorda(ratings, embeddings, rule=None)[source]

This class do the single voter manipulation analysis for the RulePositionalBorda rule_positional. It is faster than the general class class:ManipulationOrdinal.

Parameters:
  • ratings (Ratings or np.ndarray) – The ratings of voters to candidates
  • embeddings (Embeddings) – The embeddings of the voters
  • rule (Rule) – The aggregation rule we want to analysis.

Examples

>>> np.random.seed(42)
>>> ratings_dim_candidate = [[1, .2, 0], [.5, .6, .9], [.1, .8, .3]]
>>> embeddings = EmbeddingsGeneratorPolarized(10, 3)(.8)
>>> ratings = RatingsFromEmbeddingsCorrelated(coherence=.8, ratings_dim_candidate=ratings_dim_candidate)(embeddings)
>>> manipulation = ManipulationOrdinalBorda(ratings, embeddings, RuleSVDNash())
>>> manipulation.prop_manipulator_
0.0
>>> manipulation.avg_welfare_
1.0
>>> manipulation.worst_welfare_
1.0
>>> manipulation.manipulation_global_
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
manipulation_voter(i)[source]

This function return, for the i^th voter, its favorite candidate that he can turn to a winner by manipulating the election.

Parameters:i (int) – The index of the voter.
Returns:The index of the best candidate that can be elected by manipulation.
Return type:int

k-Approval

class embedded_voting.ManipulationOrdinalKApproval(ratings, embeddings, k=2, rule=None)[source]

This class do the single voter manipulation analysis for the RulePositionalKApproval rule_positional. It is faster than the general class class:ManipulationOrdinal.

Parameters:
  • ratings (Profile) – The ratings of voters on which we do the analysis.
  • embeddings (Embeddings) – The embeddings of the voters.
  • k (int) – The k parameter for the k-approval rule.
  • rule (Rule) – The aggregation rule we want to analysis.

Examples

>>> np.random.seed(42)
>>> ratings_dim_candidate = [[1, .2, 0], [.5, .6, .9], [.1, .8, .3]]
>>> embeddings = EmbeddingsGeneratorPolarized(10, 3)(.8)
>>> ratings = RatingsFromEmbeddingsCorrelated(coherence=.8, ratings_dim_candidate=ratings_dim_candidate)(embeddings)
>>> manipulation = ManipulationOrdinalKApproval(ratings, embeddings, 2, RuleSVDNash())
>>> manipulation.prop_manipulator_
0.0
>>> manipulation.avg_welfare_
1.0
>>> manipulation.worst_welfare_
1.0
>>> manipulation.manipulation_global_
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
manipulation_voter(i)[source]

This function return, for the i^th voter, its favorite candidate that he can turn to a winner by manipulating the election.

Parameters:i (int) – The index of the voter.
Returns:The index of the best candidate that can be elected by manipulation.
Return type:int

Instant Runoff

class embedded_voting.ManipulationOrdinalIRV(ratings, embeddings, rule=None)[source]

This class do the single voter manipulation analysis for the RuleInstantRunoff rule_positional. It is faster than the general class class:ManipulationOrdinal.

Parameters:
  • ratings (Ratings or np.ndarray) – The ratings of voters to candidates
  • embeddings (Embeddings) – The embeddings of the voters
  • rule (Rule) – The aggregation rule we want to analysis.

Examples

>>> np.random.seed(42)
>>> ratings_dim_candidate = [[1, .2, 0], [.5, .6, .9], [.1, .8, .3]]
>>> embeddings = EmbeddingsGeneratorPolarized(10, 3)(.8)
>>> ratings = RatingsFromEmbeddingsCorrelated(coherence=.8, ratings_dim_candidate=ratings_dim_candidate)(embeddings)
>>> manipulation = ManipulationOrdinalIRV(ratings, embeddings, RuleSVDNash())
>>> manipulation.prop_manipulator_
0.4
>>> manipulation.avg_welfare_
0.4
>>> manipulation.worst_welfare_
0.0
>>> manipulation.manipulation_global_
[2, 2, 1, 2, 1, 2, 1, 2, 1, 2]
manipulation_voter(i)[source]

This function return, for the i^th voter, its favorite candidate that he can turn to a winner by manipulating the election.

Parameters:i (int) – The index of the voter.
Returns:The index of the best candidate that can be elected by manipulation.
Return type:int