ecclesia
Version:
Framework for political and electoral simulations
67 lines (64 loc) • 2.74 kB
TypeScript
import { Simple } from '../ballots.js';
import { HasNSeats, Attribution } from './base.js';
import { DivisorMethod, Proportional, RankIndexMethod } from './proportionalBase.js';
import '@gouvernathor/python/collections';
import './metrics.js';
declare function jefferson<Party>({ nSeats }: {
nSeats: number;
}): DivisorMethod<Party> & HasNSeats;
declare const dHondt: typeof jefferson;
declare function webster<Party>({ nSeats }: {
nSeats: number;
}): DivisorMethod<Party> & HasNSeats;
declare const sainteLague: typeof webster;
declare function hamilton<Party>({ nSeats }: {
nSeats: number;
}): Proportional<Party> & HasNSeats;
declare const hareLargestRemainders: typeof hamilton;
/**
* This attribution method required some creativity and tweaks,
* since the standard divisor won't work without an initial seats value,
* causing a division by 0.
* As a result, a threshold is required in this case.
*
* In a situation where the candidates are already limited by other means,
* (for instance when distributing representatives between a fixed number of states)
* to be less or equal to the number of seats, then a threhold of 0 can be passed.
* In that case, the method will allocate one seat to each candidate
* until all candidates have a seat,
* or (but that would be a bug) all seats are allocated.
*
* The order in which the first seats are allocated is an implementation detail.
*/
declare function huntingtonHill<Party>({ nSeats, threshold }: {
nSeats: number;
threshold: 0;
}): DivisorMethod<Party> & HasNSeats;
declare function huntingtonHill<Party>({ nSeats, threshold, contingency }: {
nSeats: number;
threshold: number;
contingency?: DivisorMethod<Party> | null;
}): DivisorMethod<Party> & HasNSeats;
declare function huntingtonHill<Party>({ nSeats, threshold, contingency }: {
nSeats: number;
threshold: number;
contingency?: RankIndexMethod<Party> | null;
}): RankIndexMethod<Party> & HasNSeats;
declare function huntingtonHill<Party>({ nSeats, threshold, contingency }: {
nSeats: number;
threshold: number;
contingency?: Attribution<Party, Simple<Party>> | null;
}): Attribution<Party, Simple<Party>> & HasNSeats;
/**
* Creates a highest-averages proportional attribution method.
*
* The exact method used is an implementation detail and may change between versions.
*/
declare const highestAverages: typeof webster;
/**
* Creates a largest-remainders proportional attribution method.
*
* Implementation detail: the quota used is the Hare/Hamilton quota.
*/
declare const largestRemainders: typeof hamilton;
export { dHondt, hamilton, hareLargestRemainders, highestAverages, huntingtonHill, jefferson, largestRemainders, sainteLague, webster };