Preferences Module

Preference

class pmp.preferences.Preference(order=[], weights=None)

Single voter preference.

is_valid(num_cand)
Parameters

num_cand (Number) – Number of candidates

Returns

Boolean

Check if Preference is valid under profile with given candidates number

Profile

class pmp.preferences.Profile(candidates=None, preferences=None)

Profile of voters’ preferences

add_preference(preference)
Parameters

preference (Preference) – Added preference

Add single preference to the profile. Works only if preference is valid.

add_preferences(preferences)
Parameters

preferences (List(Preference)) – Added preferences

Add preferences to the profile. Adds only the valid ones.

clean_scores()

Clear candidates scores cached in profile

Ordinal

class pmp.preferences.Ordinal(order, weights=None)

Ordinal preference profile.

better_candidates_count(candidate)

Candidate’s rank - from how many candidates the candidate is worse.

compare_candidates(candidate_a, candidate_b)

Returns the better one.

is_valid(num_cand)
Parameters

num_cand (Number) – Number of candidates

Returns

Boolean

Check if Preference is valid under profile with given candidates number

worse_candidates_count(candidate)

Candidate’s rank - from how many candidates the candidate is better.

Approval

class pmp.preferences.Approval(approved)

Approval preference profile.

is_valid(num_cand)
Parameters

num_cand (Number) – Number of candidates

Returns

Boolean

Check if Preference is valid under profile with given candidates number