Class ApportionmentMethods
java.lang.Object
org.episteme.social.politics.ApportionmentMethods
Provides mathematical methods for electoral seat apportionment.
Includes implementations of D'Hondt, Sainte-Laguë, Hamilton, and Huntington-Hill methods.
- Since:
- 1.0
- Version:
- 1.1
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordAggregated results of an apportionment calculation.static final recordSimple party representation for apportionment. -
Method Summary
Modifier and TypeMethodDescriptionstatic doublecalculateGallagher(List<ApportionmentMethods.Party> parties, Map<String, Integer> seats, int totalSeats) Calculates the Gallagher index of disproportionality.compareAllMethods(List<ApportionmentMethods.Party> parties, int totalSeats) Compares all implemented methods for a given set of data.dHondt(List<ApportionmentMethods.Party> parties, int totalSeats) D'Hondt method - tends to favor larger parties.static RealeffectiveThreshold(int totalSeats) Calculates the effective electoral threshold.hamilton(List<ApportionmentMethods.Party> parties, int totalSeats) Hamilton (Largest Remainder) method with Hare quota.huntingtonHill(List<ApportionmentMethods.Party> parties, int totalSeats, int minimumPerParty) Huntington-Hill method, used for the US House of Representatives.sainteLague(List<ApportionmentMethods.Party> parties, int totalSeats) Sainte-Laguë method - generally considered more proportional than D'Hondt.
-
Method Details
-
dHondt
public static ApportionmentMethods.ApportionmentResult dHondt(List<ApportionmentMethods.Party> parties, int totalSeats) D'Hondt method - tends to favor larger parties.- Parameters:
parties- list of parties and their vote countstotalSeats- number of seats to allocate- Returns:
- the apportionment result
-
sainteLague
public static ApportionmentMethods.ApportionmentResult sainteLague(List<ApportionmentMethods.Party> parties, int totalSeats) Sainte-Laguë method - generally considered more proportional than D'Hondt.- Parameters:
parties- list of parties and their vote countstotalSeats- number of seats to allocate- Returns:
- the apportionment result
-
hamilton
public static ApportionmentMethods.ApportionmentResult hamilton(List<ApportionmentMethods.Party> parties, int totalSeats) Hamilton (Largest Remainder) method with Hare quota.- Parameters:
parties- list of parties and their vote countstotalSeats- number of seats to allocate- Returns:
- the apportionment result
-
huntingtonHill
public static ApportionmentMethods.ApportionmentResult huntingtonHill(List<ApportionmentMethods.Party> parties, int totalSeats, int minimumPerParty) Huntington-Hill method, used for the US House of Representatives.- Parameters:
parties- list of parties and their vote countstotalSeats- number of seats to allocateminimumPerParty- minimum seats guaranteed per party- Returns:
- the apportionment result
-
compareAllMethods
public static Map<String, ApportionmentMethods.ApportionmentResult> compareAllMethods(List<ApportionmentMethods.Party> parties, int totalSeats) Compares all implemented methods for a given set of data.- Parameters:
parties- list of parties and their vote countstotalSeats- number of seats to allocate- Returns:
- map of method names to results
-
calculateGallagher
public static double calculateGallagher(List<ApportionmentMethods.Party> parties, Map<String, Integer> seats, int totalSeats) Calculates the Gallagher index of disproportionality. Lower values indicate more proportional representation.- Parameters:
parties- parties involvedseats- allocated seatstotalSeats- total pool of seats- Returns:
- the calculated index
-
effectiveThreshold
Calculates the effective electoral threshold.- Parameters:
totalSeats- total seats in the district/election- Returns:
- the threshold percentage as a Real number
-