UNPKG

ecclesia

Version:

Framework for political and electoral simulations

60 lines (57 loc) 2.34 kB
import { Order } from '../ballots.js'; import { Attribution, HasNSeats } from './base.js'; import '@gouvernathor/python/collections'; /** * 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. */ 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. */ 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. */ declare function condorcet<Party>({ nSeats, contingency }: { nSeats: number; contingency?: Attribution<Party, Order<Party>> | null; }): Attribution<Party, Order<Party>> & HasNSeats; declare namespace condorcet { var Standoff: { new (message?: string): { name: string; message: string; stack?: string; cause?: unknown; }; new (message?: string, options?: ErrorOptions): { name: string; message: string; stack?: string; cause?: unknown; }; }; } export { bordaCount, condorcet, instantRunoff };