Class VotingSystem
java.lang.Object
org.episteme.social.politics.VotingSystem
Defines various voting systems and methods for determining winners in an election.
Refactored to use the extensible
VotingMethod registry.
* @version 2.0- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Method Summary
Modifier and TypeMethodDescriptiondetermineWinners(Map<String, Long> votes, VotingMethod method, int seatsAvailable) Determines winner(s) based on aggregated vote counts and the specified method.determineWinnersFromBallots(List<List<String>> ballots, VotingMethod method, int seatsAvailable) Determines winner(s) based on full ranked ballots and the specified method.determineWinnersFromCardinalData(List<Map<String, Integer>> data, VotingMethod method) Determines winner(s) based on cardinal scores/grades and the specified method.
-
Method Details
-
determineWinners
public static List<String> determineWinners(Map<String, Long> votes, VotingMethod method, int seatsAvailable) Determines winner(s) based on aggregated vote counts and the specified method.- Parameters:
votes- Map of Candidate/Party Name -> Vote Countmethod- The voting method algorithm to applyseatsAvailable- Number of seats to fill (relevant for proportional representation)- Returns:
- List of winners (names or descriptions of allocations)
-
determineWinnersFromBallots
public static List<String> determineWinnersFromBallots(List<List<String>> ballots, VotingMethod method, int seatsAvailable) Determines winner(s) based on full ranked ballots and the specified method.- Parameters:
ballots- List of voter preferences (each list is a ranked list of candidate names)method- The voting method algorithm to applyseatsAvailable- Number of seats to fill- Returns:
- List of winners
-
determineWinnersFromCardinalData
public static List<String> determineWinnersFromCardinalData(List<Map<String, Integer>> data, VotingMethod method) Determines winner(s) based on cardinal scores/grades and the specified method.- Parameters:
data- List of voter scores or grades (each map is Candidate -> Value)method- The voting method algorithm to apply- Returns:
- List of winners
-