Rules Module¶
Module containing classes representing all supported voting rules. For a genereal rule interface see Rule class.
-
pmp.rules.rules_list= ['Bloc', 'Borda', 'ChamberlinCourant', 'PAV', 'Rule', 'SNTV', 'WeaklySeparable']¶ Variable containing names of all provided rules. Initialized during import.
Rule¶
-
class
pmp.rules.Rule(tie_break=<function any_winner>)¶ Scoring rule class.
-
compute_candidate_scores(k, profile)¶ - Parameters
k (str) – Size of committee to find
profile (Profile) – Preferences profile object
If it is possible, fill profile.scores member dictionary with scores of all committees
-
WeaklySeparable¶
-
class
pmp.rules.WeaklySeparable(weights=None, tie_break=<function any_winner>)¶ Weakly Separable scoring rule This is base class for all weakly separable scoring rules
-
compute_candidate_scores(k, profile)¶ - Parameters
k (str) – Size of committee to find
profile (Profile) – Preferences profile object
If it is possible, fill profile.scores member dictionary with scores of all committees
-
compute_committee_score(committee, k, profile)¶ - Parameters
committee (List) – List of candidates
k (str) – Size of committee to find
profile (Profile) – Preferences profile object
Find score assigned to given committee
-
find_committee(k, profile)¶ - Parameters
k (str) – Size of committee to find
profile (Profile) – Preferences profile object
- Returns
Committee winning under given rule
- Return type
List[int]
-
get_committees(k, candidates_with_score)¶ - Parameters
k (Number) – Size of committee
candidates_with_score (Dict[Number, List[Number]]) – Dictionary with lists of candidates who achieved given score
- Returns
List[List]
Find all winning committees
-
SNTV¶
-
class
pmp.rules.SNTV(tie_break=<function any_winner>)¶ Single non-transferable vote scoring rule
-
compute_candidate_scores(k, profile)¶ - Parameters
k (str) – Size of committee to find
profile (Profile) – Preferences profile object
If it is possible, fill profile.scores member dictionary with scores of all committees
-
compute_committee_score(committee, k, profile)¶ - Parameters
committee (List) – List of candidates
k (str) – Size of committee to find
profile (Profile) – Preferences profile object
Find score assigned to given committee
-
find_committee(k, profile)¶ - Parameters
k (str) – Size of committee to find
profile (Profile) – Preferences profile object
- Returns
Committee winning under given rule
- Return type
List[int]
-
get_committees(k, candidates_with_score)¶ - Parameters
k (Number) – Size of committee
candidates_with_score (Dict[Number, List[Number]]) – Dictionary with lists of candidates who achieved given score
- Returns
List[List]
Find all winning committees
-
Bloc¶
-
class
pmp.rules.Bloc(weights=None, tie_break=<function any_winner>)¶ Bloc vote scoring rule
-
compute_candidate_scores(k, profile)¶ - Parameters
k (str) – Size of committee to find
profile (Profile) – Preferences profile object
If it is possible, fill profile.scores member dictionary with scores of all committees
-
compute_committee_score(committee, k, profile)¶ - Parameters
committee (List) – List of candidates
k (str) – Size of committee to find
profile (Profile) – Preferences profile object
Find score assigned to given committee
-
find_committee(k, profile)¶ - Parameters
k (str) – Size of committee to find
profile (Profile) – Preferences profile object
- Returns
Committee winning under given rule
- Return type
List[int]
-
get_committees(k, candidates_with_score)¶ - Parameters
k (Number) – Size of committee
candidates_with_score (Dict[Number, List[Number]]) – Dictionary with lists of candidates who achieved given score
- Returns
List[List]
Find all winning committees
-
Borda¶
-
class
pmp.rules.Borda(weights=None, tie_break=<function any_winner>)¶ Borda vote scoring rule
-
compute_candidate_scores(k, profile)¶ - Parameters
k (str) – Size of committee to find
profile (Profile) – Preferences profile object
If it is possible, fill profile.scores member dictionary with scores of all committees
-
compute_committee_score(committee, k, profile)¶ - Parameters
committee (List) – List of candidates
k (str) – Size of committee to find
profile (Profile) – Preferences profile object
Find score assigned to given committee
-
find_committee(k, profile)¶ - Parameters
k (str) – Size of committee to find
profile (Profile) – Preferences profile object
- Returns
Committee winning under given rule
- Return type
List[int]
-
get_committees(k, candidates_with_score)¶ - Parameters
k (Number) – Size of committee
candidates_with_score (Dict[Number, List[Number]]) – Dictionary with lists of candidates who achieved given score
- Returns
List[List]
Find all winning committees
-
ChamberlinCourant¶
-
class
pmp.rules.ChamberlinCourant(weights=None)¶ Chamberlin-Courant vote scoring rule
-
compute_candidate_scores(k, profile)¶ - Parameters
k (str) – Size of committee to find
profile (Profile) – Preferences profile object
If it is possible, fill profile.scores member dictionary with scores of all committees
-
PAV¶
-
class
pmp.rules.PAV(alpha=None)¶ Proportional Approval Voting scoring rule.
-
compute_candidate_scores(k, profile)¶ - Parameters
k (str) – Size of committee to find
profile (Profile) – Preferences profile object
If it is possible, fill profile.scores member dictionary with scores of all committees
-