An election is run on the geometry to generate output data structures. It handles casting votes and applying a social choice function.
Election runs one of two election functions: electionRun or electionDistrictsRun.
The function electionDistrictsRun compiles district and statewide votes and results.
Election may be called by ElectionSampler to run multiple elections.
- If there are districts, then the geometry is run in several tracts, each with slight variations in geometry.
- VoteCasters: Votes are cast.
- If there are districts, then votes from tracts are combined into districts.
- A social choice function runs on the votes to determine winners.
- Election results are assembled.
- All the options, geometry, votes, and social choice outputs are combined into an electionResults data structure.
The election results are all the data you need for making explanations. They are output by the election step in the sim. They are input for the visualizers. They are composed of several parts:
- iWinner or allocation
- An error message string or undefined.
- voter labels
- candidate labels
The districtElectionResults have additional variables by tract and district.