ecclesia
Version:
Framework for political and electoral simulations
49 lines (48 loc) • 2.08 kB
TypeScript
import { Order } from "../tally";
import { type Attribution, type HasNSeats } from "../attribution";
/**
* Creates an attribution method in which the party with the least votes is eliminated,
* and its votes are redistributed to the other parties according to the voters' preferences.
* Repeats until a party reaches a majority of the remaining votes, winning all the seats.
*
* The ballots are not required to rank all the candidates.
*/
export declare function instantRunoff<Party>({ nSeats }: {
nSeats: number;
}): Attribution<Party, Order<Party>> & HasNSeats;
/**
* Creates an attribution method in which each party receives points according
* to the position it occupies on each ballot, and the party with the most points wins all the seats.
*
* Uses the Modified Borda Count, in which the least-ranked candidate gets 1 point,
* and unranked candidates get 0 points.
* So, the ballots are not required to rank all the candidates.
*/
export declare function bordaCount<Party>({ nSeats }: {
nSeats: number;
}): Attribution<Party, Order<Party>> & HasNSeats;
/**
* Creates an attribution method in which each party is matched against each other party,
* and the party winning each of its matchups wins all the seats.
* If no party wins against all others, the attribution fails.
*
* Doesn't support candidates with equal ranks, due to the Order type format.
* This implementation also doesn't support incomplete ballots.
*
* @param contingency An optional contingency attribution method to use in case of a standoff.
* If not provided (or null), the attribution will fail with a condorcet.Standoff error,
* which is a subclass of AttributionFailure.
*/
export declare function condorcet<Party>({ nSeats, contingency }: {
nSeats: number;
contingency?: Attribution<Party, Order<Party>> | null;
}): Attribution<Party, Order<Party>> & HasNSeats;
export declare namespace condorcet {
var Standoff: {
new (message?: string): {
name: string;
message: string;
stack?: string;
};
};
}