UNPKG

ecclesia

Version:

Framework for political and electoral simulations

35 lines (34 loc) 1.64 kB
import { Counter } from "@gouvernathor/python/collections"; import { type Collection } from "@gouvernathor/python/collections/abc"; import { type Voting } from "./election/voting"; import { type Attribution } from "./election/attribution"; import { type RandomObjParam } from "./utils"; /** * A function to go from a set of opinionated voters * to the elected representatives, the number of seats for each candidate. * * @param voters A pool of voters such as taken by the Voting functions. * @returns A multi-set (a Counter) of elected representatives as returned by an Attribution. */ export interface Election<Voter, Party> { (voters: Collection<Voter>, candidates: Collection<Party>): Counter<Party, number>; } /** * Implements the most basic elections : combining a voting method and an attribution method. */ export declare function standardElection<Voter, Party, Tally>({ votingMethod, attributionMethod }: { votingMethod: Voting<Voter, Party, Tally>; attributionMethod: Attribution<Party, Tally>; }): Election<Voter, Party>; /** * Implements a selection by lottery, directly among the population. * Adds the supplementary constraint that the voter type and the candidate type must be the same. * * The pool of candidates and the pool of citizens must be the same. * (Implementation detail : this is not enforced, and the pool of candidates is ignored.) * Returns elements from the pool picked without replacement, * so the pool must be at least nSeats in size. */ export declare function sortition<Citizen>({ nSeats, ...randomParam }: { nSeats: number; } & RandomObjParam): Election<Citizen, Citizen>;