Class ElectoralSystems
java.lang.Object
org.episteme.social.politics.ElectoralSystems
Provides algorithms for various electoral systems and seat allocation methods.
Includes implementations of D'Hondt and Sainte-Laguë proportional representation methods.
- Since:
- 1.0
- Version:
- 1.1
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Method Summary
Modifier and TypeMethodDescriptionallocateSeatsDHondt(Map<String, Long> votes, int totalSeats) Allocates seats using the D'Hondt method (highest averages).allocateSeatsSainteLague(Map<String, Long> votes, int totalSeats) Allocates seats using the Sainte-Laguë method (Webster method).Implements a simple "Uniform Swing" model for predicting election outcomes.
-
Method Details
-
allocateSeatsDHondt
Allocates seats using the D'Hondt method (highest averages).Favors larger parties slightly more than other PR methods. Divisors: 1, 2, 3, 4...
- Parameters:
votes- Map of party names to their total votestotalSeats- Total seats available for allocation- Returns:
- Map of party names to allocated seats
-
allocateSeatsSainteLague
Allocates seats using the Sainte-Laguë method (Webster method).Generally provides a more proportional outcome than D'Hondt, better for smaller parties. Divisors: 1, 3, 5, 7... (2s + 1)
- Parameters:
votes- Map of party names to their total votestotalSeats- Total seats available for allocation- Returns:
- Map of party names to allocated seats
-
predictSwing
public static Map<String,Real> predictSwing(Map<String, Real> previousResults, Map<String, Real> swing) Implements a simple "Uniform Swing" model for predicting election outcomes. Applies a uniform percentage change to previous results.- Parameters:
previousResults- Map of parties to previous vote percentage (e.g., 0.45 for 45%)swing- Predicted swing in percentage points (e.g., +0.02 for +2%)- Returns:
- Map of predicted vote percentages
-