socialchoicekit.randomized_allocation module
- class socialchoicekit.randomized_allocation.ProbabilisticSerial(zero_indexed: bool = False)[source]
Bases:
object
Probabilistic Serial (Bogomolnaia and Moulin 2001) is a special case of the simultaneous eating algorithm where all agents have the same eating speed.
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.
- bistochastic(profile: StrictProfile) → ndarray[source]
The bistochastic matrix outputted by this voting rule on a preference profile. This bistochastic matrix can be decomposed with the Birkhoff von Neumann algorithm (implemented in bistochastic.birkhoff_von_neumann) to a convex combination of permuation matrices.
Parameters
- profile: StrictProfile
An (N, N) array, where M is the number of items. The element at (i, j) indicates the voter’s preference for item j, where 1 is the most preferred item. If the agent finds an item unacceptable, the element would be np.nan.
Returns
- np.ndarray
A bistochastic matrix.
- scf(profile: StrictProfile) → ndarray[source]
The social choice function for this voting rule. Returns at most one item allocated for each agent.
Parameters
- profile: StrictProfile
An (N, N) array, where M is the number of items. The element at (i, j) indicates the voter’s preference for item j, where 1 is the most preferred item. If the agent finds an item unacceptable, the element would be np.nan.
Returns
- np.ndarray
A numpy array containing the allocated item for each agent or np.nan if the agent is unallocated.
- class socialchoicekit.randomized_allocation.RandomSerialDictatorship(zero_indexed: bool = False)[source]
Bases:
object
Random Serial Dictatorship (Bogomolnaia and Moulin 2001) selects a random agent to select their most preferred item, then selects a random agent from the remaining agents to select their most preferred item, and so on until all agents have selected an item.
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: StrictProfile) → ndarray[source]
The social choice function for this voting rule. Returns at most one item allocated for each agent.
Parameters
- profile: StrictProfile
A (N, M) array, where N is the number of agents and M is the number of items. The element at (i, j) indicates the voter’s preference for item j, where 1 is the most preferred item. If the agent finds an item unacceptable, the element would be np.nan.
Returns
- np.ndarray
A numpy array containing the allocated item for each agent or np.nan if the agent is unallocated.
- class socialchoicekit.randomized_allocation.SimultaneousEating(zero_indexed: bool = False)[source]
Bases:
object
Simultaneous Eating (Bogomolnaia and Moulin 2001) is an algorithm for fair random assignment (resource allocation) where the fraction that each agent receives an item in a simultaneous eating setting is translated to the probability that the agent is assigned an item in the resource allocation setting.
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.
- bistochastic(profile: StrictProfile, speeds: ndarray) → ndarray[source]
The bistochastic matrix outputted by this voting rule on a preference profile. This bistochastic matrix can be decomposed with the Birkhoff von Neumann algorithm (implemented in bistochastic.birkhoff_von_neumann) to a convex combination of permuation matrices.
Parameters
- profile: StrictProfile
An (N, N) array, where M is the number of items. The element at (i, j) indicates the voter’s preference for item j, where 1 is the most preferred item. If the agent finds an item unacceptable, the element would be np.nan.
- speeds: np.ndarray
A N-array, where N is the number of agents. The element at i indicates the speed of agent i. The speed of an agent is the number of items that the agent can eat in one time unit.
Returns
- np.ndarray
A bistochastic matrix.
- scf(profile: StrictProfile, speeds: ndarray) → ndarray[source]
The social choice function for this voting rule. Returns at most one item allocated for each agent.
Parameters
- profile: StrictProfile
An (N, N) array, where M is the number of items. The element at (i, j) indicates the voter’s preference for item j, where 1 is the most preferred item. If the agent finds an item unacceptable, the element would be np.nan.
- speeds: np.ndarray
A N-array, where N is the number of agents. The element at i indicates the speed of agent i. The speed of an agent is the number of items that the agent can eat in one time unit.
Returns
- np.ndarray
A numpy array containing the allocated item for each agent or np.nan if the agent is unallocated.