Here are some updates that allow for points based voting methods, as well as some general features.
Added a by_bloc parameter to generate_profile. If True, this returns a dictionary of PreferenceProfiles by bloc. This is very helpful for analyzing the behavior of a single bloc of voters. Defaults to False for backwards compatibility.
Created a Cumulative ballot generator class. The Cumulative class works like PL, but samples with replacement instead of without. The ranking order does not matter here, simply that candidates are listed on the ballot with multiplicity.
Created a HighestScore election class. This takes in a profile and a score vector, and returns the $m$ candidates with highest scores. There is a lot of flexibility in the score vector, so this class can run things like Borda, cumulative, etc.
Created a Cumulative election class which is just a subclass of HighestScore with the score vector set to all 1s. Thus anyone appearing on the ballot gets one point for each time they appear.
Wrote an __add__ method for PreferenceProfile that combines the ballot lists of two profiles.
Created utility functions to compute the winners of a profile given a score vector, as well as to validate a score vector (non-negative and non-increasing).
I did not make Borda a subclass of HighestScore since it seems like there are some finer details about how short ballots/overvotes are handled in the existing Borda class.
Here are some updates that allow for points based voting methods, as well as some general features.
by_bloc
parameter togenerate_profile
. If True, this returns a dictionary of PreferenceProfiles by bloc. This is very helpful for analyzing the behavior of a single bloc of voters. Defaults to False for backwards compatibility.Cumulative
ballot generator class. TheCumulative
class works like PL, but samples with replacement instead of without. The ranking order does not matter here, simply that candidates are listed on the ballot with multiplicity.HighestScore
election class. This takes in a profile and a score vector, and returns the $m$ candidates with highest scores. There is a lot of flexibility in the score vector, so this class can run things like Borda, cumulative, etc.Cumulative
election class which is just a subclass ofHighestScore
with the score vector set to all 1s. Thus anyone appearing on the ballot gets one point for each time they appear.__add__
method forPreferenceProfile
that combines the ballot lists of two profiles.I did not make
Borda
a subclass ofHighestScore
since it seems like there are some finer details about how short ballots/overvotes are handled in the existingBorda
class.@jamesturk @drdeford @jgibson517 @jennjwang @ziglaser