socialchoicekit.randomized_scoring module
- class socialchoicekit.randomized_scoring.BaseRandomizedScoring(voting_rule: BaseScoring, zero_indexed: bool = False)[source]
Bases:
object
The abstract scoring rule. This class should not be instantiated directly.
Parameters
- zero_indexedbool
If True, the output of the social welfare function and social choice function will be zero-indexed. If False, the output will be one-indexed. One-indexed by default.
- scf(profile: Profile) → int[source]
The social choice function for this voting rule. Returns a single winning alternative.
Notes
Complexity O(MN)
Parameters
- profile: Profile
A (N, M) array, where N is the number of voters and M is the number of alternatives. The element at (i, j) indicates the voter’s preference for alternative j, where 1 is the most preferred alternative.
Returns
- int
A single winning alternative.
- score(profile: Profile) → ndarray[source]
The scoring function for this voting rule. Returns a list of alternatives with their scores.
Notes
Complexity O(MN)
Parameters
- profile: Profile
A (N, M) array, where N is the number of voters and M is the number of alternatives. The element at (i, j) indicates the voter’s preference for alternative j, where 1 is the most preferred alternative.
Returns
- np.ndarray
A (1, M) array of scores where the element at (0, j) indicates the score for alternative j.
- class socialchoicekit.randomized_scoring.RandomizedBorda(zero_indexed: bool = False)[source]
Bases:
BaseRandomizedScoring
The randomized Borda voting rule where each alternative has a probability of being selected proportional to its Borda score.
Access the voting_rule object to access the deterministic Borda voting rule and its methods.
Parameters
- zero_indexedbool
If True, the output of the social welfare function and social choice function will be zero-indexed. If False, the output will be one-indexed. One-indexed by default.
- class socialchoicekit.randomized_scoring.RandomizedHarmonic(zero_indexed: bool = False)[source]
Bases:
BaseRandomizedScoring
The randomized harmonic voting rule where each alternative has a probability of being selected proportional to its harmonic score.
Access the voting_rule object to access the deterministic harmonic voting rule and its methods.
Parameters
- zero_indexedbool
If True, the output of the social welfare function and social choice function will be zero-indexed. If False, the output will be one-indexed. One-indexed by default.
- class socialchoicekit.randomized_scoring.RandomizedKApproval(k: int, zero_indexed: bool = False)[source]
Bases:
BaseRandomizedScoring
The randomized k-approval voting rule where each alternative has a probability of being selected proportional to its k-approval score.
Access the voting_rule object to access the deterministic k-approval voting rule and its methods.
Parameters
- k: int
A number greater than 0. If greater than or equal to M, the k-approval rule becomes trivial.
- zero_indexedbool
If True, the output of the social welfare function and social choice function will be zero-indexed. If False, the output will be one-indexed. One-indexed by default.
- class socialchoicekit.randomized_scoring.RandomizedPlurality(zero_indexed: bool = False)[source]
Bases:
BaseRandomizedScoring
The randomized plurality voting rule where each alternative has a probability of being selected proportional to its plurality score.
Access the voting_rule object to access the deterministic plurality voting rule and its methods.
Parameters
- zero_indexedbool
If True, the output of the social welfare function and social choice function will be zero-indexed. If False, the output will be one-indexed. One-indexed by default.
- class socialchoicekit.randomized_scoring.RandomizedVeto(zero_indexed: bool = False)[source]
Bases:
BaseRandomizedScoring
The randomized veto (anti-plurality) voting rule where each alternative has a probability of being selected proportional to its anti-plurality score.
Access the voting_rule object to access the deterministic veto voting rule and its methods.
Parameters
- zero_indexedbool
If True, the output of the social welfare function and social choice function will be zero-indexed. If False, the output will be one-indexed. One-indexed by default.