Profile
- class poisson_approval.Profile(voting_rule='Approval', symbolic=False)[source]
A profile of preference (abstract class).
- Parameters
voting_rule (str) – The voting rule. Possible values are
APPROVAL
,PLURALITY
andANTI_PLURALITY
.symbolic (bool) – Whether the computations are symbolic or numeric.
- property abc
Share of voters with this ranking.
- Type
Number
- property acb
Share of voters with this ranking.
- Type
Number
- analyzed_strategies(strategies)[source]
Analyze a list of strategies for the profile.
- Parameters
strategies (iterable) – An iterator of strategies, such as a list of strategies.
- Returns
The analyzed strategies of the profile.
- Return type
Examples
- property analyzed_strategies_group
Analyzed group strategies.
Cf.
analyzed_strategies()
andstrategies_group
. This is implemented only for profiles where we consider that there is a natural notion of group, such asProfileNoisyDiscrete
.- Type
- property analyzed_strategies_ordinal
Analyzed ordinal strategies.
Cf.
analyzed_strategies()
andstrategies_ordinal
.- Type
- property analyzed_strategies_pure
Analyzed pure strategies.
Cf.
analyzed_strategies()
andstrategies_pure
. This is implemented only for discrete profiles such asProfileTwelve
orProfileDiscrete
.- Type
- property bac
Share of voters with this ranking.
- Type
Number
- property bca
Share of voters with this ranking.
- Type
Number
- best_responses_to_strategy(tau, ratio_optimistic=Fraction(1, 2))[source]
Convert best responses to a
StrategyThreshold
.- Parameters
tau (TauVector) – Tau-vector.
ratio_optimistic – The value of ratio_optimistic to use. Default: 1/2.
- Returns
The conversion of the best responses into a strategy. Only the rankings present in this profile are mentioned in the strategy.
- Return type
- property cab
Share of voters with this ranking.
- Type
Number
- property cba
Share of voters with this ranking.
- Type
Number
- property contains_rankings
Whether the profile contains some rankings.
- Type
bool
- property contains_weak_orders
Whether the profile contains some weak orders.
- Type
bool
Ballot shares due to the weak orders if they vote fanatically.
Voters of type
'a>b~c'
(lovers):In Approval or Plurality, they vote for a.
In Anti-plurality, half of them vote for ab (i.e. against c) and half of them vote for ac (i.e. against b).
Voters of type
'a~b>c'
(haters):In Approval or Plurality, half of them vote for a and half of them vote for b.
In Anti-plurality, they vote for ab (i.e. against c).
- Type
dict
Ballot shares due to the weak orders if they vote sincerely.
Voters of type
'a>b~c'
(lovers):In Approval or Plurality, they vote for a.
In Anti-plurality, half of them vote for ab (i.e. against c) and half of them vote for ac (i.e. against b).
Voters of type
'a~b>c'
(haters):In Approval or Anti-plurality, they vote for ab (i.e. against c).
In Plurality, half of them vote for a and half of them vote for b.
- Type
dict
dict : Ballot shares due to the weak orders if they vote strategically.
For voters with a weak order, strategic voting is the same as sincere voting, except in two cases:
For voters of type
'a~b>c'
(haters)`in Plurality, who have two dominant strategies: vote for a or b.For voters of type
'a>b~c'
(lovers) in Anti-Plurality, who have two dominant strategies: vote against b or c (i.e. respectively for ac or ab).
- property d_candidate_anti_plurality_welfare
Anti-plurality welfare of each candidate, i.e. share of voters with utility > 0.
- Type
- property d_candidate_plurality_welfare
Plurality welfare of each candidate, i.e. share of voters with utility 1.
- Type
- property d_candidate_relative_anti_plurality_welfare
Relative anti-plurality welfare of each candidate. This is similar to
d_candidate_anti_plurality_welfare
, but renormalized so that the candidate with best welfare has 1 and the one with worst welfare has 0. In math: relative_welfare = (welfare - min_welfare) / (max_welfare - min_welfare). In the case where all candidates have the same welfare, by convention, the relative welfare is 1 for all of them.- Type
- property d_candidate_relative_plurality_welfare
Relative plurality welfare of each candidate. This is similar to
d_candidate_plurality_welfare
, but renormalized so that the candidate with best welfare has 1 and the one with worst welfare has 0. In math: relative_welfare = (welfare - min_welfare) / (max_welfare - min_welfare). In the case where all candidates have the same welfare, by convention, the relative welfare is 1 for all of them.- Type
Shares of rankings. E.g.
'abc': 0.3
means that a ratio 0.3 of the voters have ranking'abc'
.- Type
dict
Shares of weak orders. E.g.
'a~b>c': 0.3
means that a ratio 0.3 of the voters have weak order'a~b>c'
.- Type
dict
- property has_majority_favorite
Whether there is a majority favorite (a candidate ranked first by strictly more than half of the voters).
- Type
bool
- property has_majority_ranking
Whether there is a majority ranking (a ranking shared by strictly more than half of the voters).
- Type
bool
- is_equilibrium(strategy)[source]
Whether a strategy is an equilibrium in this profile.
- Parameters
strategy (Strategy) – A strategy that specifies at least all the rankings that are present in the profile.
- Returns
Whether strategy is an equilibrium in this profile.
- Return type
- property is_generic_in_rankings
Whether the profile is generic in rankings (contains all rankings).
- Type
bool
- property is_profile_condorcet
Whether the profile is Condorcet. By convention,
1.
means there is a strict Condorcet winner,0.5
means there are one or more weak Condorcet winner(s),0.
means there is no Condorcet winner.- Type
float
- property is_single_peaked
Whether the profile is single-peaked.
- Type
bool
- property is_standardized
Whether the profile is standardized. Cf.
standardized_version()
.- Type
bool
- classmethod order_and_label(t)[source]
Order and label of a discrete type.
Helper method for the ternary plots.
- Parameters
t (object) – A type. Any type that is accepted as a key in the initialization dictionary.
- Returns
order (str) – The ranking or weak order.
label (str) – The label to be used for the corner of the triangle.
Examples
- classmethod order_and_label_weak(t)[source]
Auxiliary function for
order_and_label()
, specialized for weak orders.- Parameters
t (object) – A weak order of the form
'a>b~c'
or'a~b>c'
.- Returns
order (str) – The weak order itself.
label (str) – The label to be used for the corner of the triangle.
Examples
>>> Profile.order_and_label_weak('a~b>c') ('a~b>c', '$r(a\\sim b>c)$')
- random_tau_undominated()[source]
Random tau based on undominated ballots.
This is used, for example, in
iterated_voting()
.- Returns
A random tau-vector. Independently for each ranking, a proportion uniformly drawn in [0, 1] of voters use one undominated ballot, and the rest use the other undominated ballot. For example, in Approval voting, voters with ranking abc are randomly split between ballots a and ab.
- Return type
- property standardized_version
Standardized version of the profile (makes it unique, up to permutations of the candidates).
- Type
- property strategies_group
Group strategies of the profile.
- Yields
Strategy
– All possible group strategies of the profile. This is implemented only for profiles where we consider that there is a natural notion of group, such asProfileNoisyDiscrete
.
Examples
Cf.
ProfileNoisyDiscrete
.- Type
Iterator
- property strategies_ordinal
Ordinal strategies of the profile.
- Yields
StrategyOrdinal
– All possible ordinal strategies for this profile.
Examples
Cf.
ProfileOrdinal
.- Type
Iterator
- property strategies_pure
Pure strategies of the profile.
- Yields
Strategy
– All possible pure strategies of the profile. This is implemented only for discrete profiles such asProfileTwelve
orProfileDiscrete
.
Examples
Cf.
ProfileDiscrete
.- Type
Iterator
- property support_in_rankings
Support of the profile (in terms of rankings).
- Type
SetPrintingInOrder
of str
- property support_in_weak_orders
Support of the profile (in terms of weak orders).
- Type
SetPrintingInOrder
of str
- property weighted_maj_graph
Weighted majority graph.
- Type
numpy.ndarray