Geometric Rules

Zonotope

class embedded_voting.RuleZonotope(embeddings_from_ratings=None)[source]

Voting rule in which the aggregated score of a candidate is the volume of the zonotope described by his embedding matrix M such that M[i] = score[i, candidate] * embeddings[i]. (cf times_ratings_candidate()).

For each candidate, the rank r of her associated matrix is computed. The volume of the zonotope is the sum of the volumes of all the parallelepipeds associated to a submatrix keeping only r voters (cf. volume_parallelepiped()). The score of the candidate is then (r, volume).

Parameters:embeddings_from_ratings (EmbeddingsFromRatings) – If no embeddings are specified in the call, this EmbeddingsFromRatings object is use to generate the embeddings from the ratings. Default: EmbeddingsFromRatingsIdentity().

Examples

>>> ratings = Ratings([[1], [1]])
>>> embeddings = Embeddings([[1, 0, 0], [-.5, 1, 0]], norm=False)
>>> election = RuleZonotope()(ratings, embeddings)
>>> election.scores_
[(2, 1.0)]
>>> ratings = Ratings(np.array([[.5, .6, .3], [.7, 0, .2], [.2, 1, .8]]))
>>> embeddings = Embeddings(np.array([[1, 1], [1, 0], [0, 1]]), norm=True)
>>> election = RuleZonotope()(ratings, embeddings)
>>> election.scores_  # doctest: +ELLIPSIS
[(2, 0.458...), (2, 0.424...), (2, 0.372...)]
>>> election.ranking_
[0, 1, 2]
>>> election.winner_
0
>>> election.welfare_  # doctest: +ELLIPSIS
[1.0, 0.605..., 0.0]

Max Parallelepiped

class embedded_voting.RuleMaxParallelepiped(embeddings_from_ratings=None)[source]

Voting rule in which the aggregated score of a candidate is the volume of a parallelepiped described by n_dim rows of the candidate embedding matrix M such that M[i] = score[i, candidate] * embeddings[i]. (cf times_ratings_candidate()).

For each candidate, the rank r of her associated matrix is computed. Then we choose r voters in order to maximize the volume of the parallelepiped associated to the submatrix keeping only these voters (cf. volume_parallelepiped()). The score of the candidate is then (r, volume).

Parameters:embeddings_from_ratings (EmbeddingsFromRatings) – If no embeddings are specified in the call, this EmbeddingsFromRatings object is use to generate the embeddings from the ratings. Default: EmbeddingsFromRatingsIdentity().

Examples

>>> ratings = Ratings(np.array([[.5, .6, .3], [.7, 0, .2], [.2, 1, .8]]))
>>> embeddings = Embeddings(np.array([[1, 1], [1, 0], [0, 1]]), norm=True)
>>> election = RuleMaxParallelepiped()(ratings, embeddings)
>>> election.scores_  # doctest: +ELLIPSIS
[(2, 0.24...), (2, 0.42...), (2, 0.16...)]
>>> election.ranking_
[1, 0, 2]
>>> election.winner_
1
>>> election.welfare_  # doctest: +ELLIPSIS
[0.305..., 1.0, 0.0]
>>> ratings = Ratings([[1, 10], [1, 10], [1, 0]])
>>> embeddings = Embeddings([[1, 0, 0], [0, 1, 0], [0, 0, 1]], norm=False)
>>> election = RuleMaxParallelepiped()(ratings, embeddings)
>>> election.scores_  # doctest: +ELLIPSIS
[(3, 1.0), (2, 100.0...)]
>>> election.scores_focus_on_last_
[1.0, 0]