Global

Members

(constant) usingIPython

Check if we are in a jupyter notebook. Send any simData to votekitData variable in python.
Source:

Methods

findGridX(voterGeom) → {types.typesGrid.gridX}

get x coordinates for grid
Parameters:
Name Type Description
voterGeom types.typesGeoms.voterGeom1D
Source:
Returns:
Type
types.typesGrid.gridX

module:addSandboxes/addDoubleSandboxes()

Find all the divs of class "double_sandbox". Add the double_sandbox as a neighbor under the same parent.
Source:

module:addSandboxes/addSingleSandboxes()

Find all the divs of class "sandbox". Add the sandbox as a neighbor under the same parent.
Source:

module:addSandboxes/doubleSandbox(config, sandboxPath) → {HTMLElement}

Makes Two sandboxes and links their commands together.
Parameters:
Name Type Description
config Object To pass to commander to set the initial configuration of the sim.
sandboxPath String String to add to the current url directory to get to the sandbox.
Source:
Returns:
- div containing the two sandboxes.
Type
HTMLElement

module:addSandboxes/sandbox(config)

Set up a user interface to run a simulation.
Parameters:
Name Type Description
config Object An object containing commands. A command is a {name,value} pair.
Source:

module:compute/districtElection/districtElection()

An election with many districts. Voters are from many groups. Voter groups are centered around a point. The point is moved by simplex noise to create distinct districts. All the voter groups share the same voter basis.
Source:

module:compute/election/election(geometry, electionOptions, castOptions) → {*}

Here we are in the context of a single election.
Parameters:
Name Type Description
geometry *
electionOptions *
castOptions *
Source:
Returns:
Type
*

module:compute/electionPhase/calculatePolling(lastElectionResults) → {*}

Get polling information from election results.
Parameters:
Name Type Description
lastElectionResults *
Source:
Returns:
Type
*

module:compute/electionPhase/electionCycle(geometry, electionOptions, optionsBag) → {*}

Here we are in the context of an election cycle with polls followed by a single election.
Parameters:
Name Type Description
geometry *
electionOptions *
optionsBag *
Source:
Returns:
electionResults
Type
*

module:compute/electionPhase/electionPhase(geometry, electionOptions, optionsBag) → {*}

Here we are in the context of a single election phase.
Parameters:
Name Type Description
geometry *
electionOptions *
optionsBag *
Source:
Returns:
electionResults
Type
*

module:compute/electionSequence/electionClosedPrimary(geometry, optionsBag) → {*}

Here we are in the context of an election sequence. Run a primary election for each party, then a general election.
Parameters:
Name Type Description
geometry *
optionsBag *
Source:
Returns:
sequenceResults
Type
*

module:compute/electionSequence/electionGeneral(geometry, optionsBag) → {*}

Here we are in the context of the simplest election sequence with one general election phase.
Parameters:
Name Type Description
geometry *
optionsBag *
Source:
Returns:
sequenceResults
Type
*

module:compute/electionSequence/electionNonPartisanPrimary(geometry, optionsBag) → {*}

Here we are in the context of an election sequence with two phases, a non-partisan primary, and a general.
Parameters:
Name Type Description
geometry *
optionsBag *
Source:
Returns:
sequenceResults
Type
*

module:compute/electionSequence/electionSequence(geometry, optionsBag) → {*}

Here we are in the context of an election sequence.
Parameters:
Name Type Description
geometry *
optionsBag *
Source:
Returns:
sequenceResults
Type
*

module:compute/electionSequence/getElectionOptions(sequenceName, phaseName, optionsBag) → {*}

get election phase options from election options for a phase
Parameters:
Name Type Description
sequenceName *
phaseName string
optionsBag *
Source:
Returns:
election phase options
Type
*

module:compute/electionSequence/getGeometryForPhase(phaseName, geometry) → {*}

Use phase description to get geometry. Geometry can differ by phase. e.g. voter strategy, use of polls
Parameters:
Name Type Description
phaseName *
geometry *
Source:
Returns:
geometry
Type
*

module:compute/makeGeography/lloydVoronoi(w, h, n, tolFraction)

Calculate a voronoi diagram with some degree of equal capacity between voronoi cells. Uses Lloyd's method.
Parameters:
Name Type Description
w number number of discrete points wide of space to divide
h number number of points high
n number number of voronoi cells
tolFraction number fractional tolerance for relaxation. Maybe .01 is good.
Source:
Returns:
Centroids (list of points) and voronoi d3 object

module:compute/makeGeography/makeCensus() → {Array.<Array.<Array.<number>>>}

What fraction of each tract lives in each district? Return an array indexed by district. Each element contains an array of pairs. The first of the pair is a tract's pair of coordinates. The second of the pair is the fraction of the tract within that district.
Source:
Returns:
- an array of districts, each with a list of census tract properties [x,y,overlap]
Type
Array.<Array.<Array.<number>>>

module:compute/makeGeography/makeDistrictMap(nd)

Makes and draws district boundaries for districts of equal number of voters. Right now, just for a uniform square geography. Each axis is from 0 to 1. The total area is 1. Define district lines and count voters.
Parameters:
Name Type Description
nd number number of districts.
Source:

module:compute/makeGeography/makeGeography()

Make tracts
Source:

module:compute/makeGeography/makeTractNoise(nx, ny)

Generate a noisy 2D map with two noise sources per pixel.
Parameters:
Name Type Description
nx number Number of x pixels
ny number Number of y pixels
Source:

module:compute/sampleElection/sampleCanDnGeom1D(canDnGeom) → {number}

Use this to sample a random candidate from a distribution.
Parameters:
Name Type Description
canDnGeom object
Source:
Returns:
x coordinate
Type
number

module:compute/sampleElection/sampleCanDnGeom2D(canDnGeom) → {object}

Use this to sample a random candidate from a distribution.
Parameters:
Name Type Description
canDnGeom object
Source:
Returns:
x,y coordinates
Type
object

module:compute/socialChoiceMethods/allocatedScore(votes, socialChoiceOptions) → {types.typesSocialChoice.socialChoiceResults}

This method has rounds. Each round, the votes are weighted based on the previous round. Weights start at 1. Each round, the candidate with the highest weighted tally is selected. Then the scores for the candidate are sorted. The voters' weight is spent, starting from the top scores. Weight is spent until the weight of voters included is equal to 1/seats, which is the quota.
Parameters:
Name Type Description
votes types.typesVotes.votes The object for vote data.
socialChoiceOptions types.typesSocialChoice.socialChoiceOptions options to specify a social choice function.
Source:
Returns:
- the results returned from a social choice function.
Type
types.typesSocialChoice.socialChoiceResults

module:compute/socialChoiceMethods/dHondt(votes, socialChoiceOptions) → {types.typesSocialChoice.socialChoiceResults}

Run the d'Hondt / Jefferson method of apportionment and return an allocation of seats.
Parameters:
Name Type Description
votes types.typesVotes.votes The object for vote data.
socialChoiceOptions types.typesSocialChoice.socialChoiceOptions options to specify a social choice function.
Source:
Returns:
- the results returned from a social choice function.
Type
types.typesSocialChoice.socialChoiceResults

module:compute/socialChoiceMethods/divisorGeneral(votes, socialChoiceOptions) → {types.typesSocialChoice.socialChoiceResults}

Run a general divisor method of apportionment and return an allocation of seats.
Parameters:
Name Type Description
votes types.typesVotes.votes The object for vote data.
socialChoiceOptions types.typesSocialChoice.socialChoiceOptions options to specify a social choice function.
Source:
Returns:
- the results returned from a social choice function.
Type
types.typesSocialChoice.socialChoiceResults

module:compute/socialChoiceMethods/huntingtonHill(votes, socialChoiceOptions) → {types.typesSocialChoice.socialChoiceResults}

Run the Huntington-Hill method of apportionment and return an allocation of seats.
Parameters:
Name Type Description
votes types.typesVotes.votes The object for vote data.
socialChoiceOptions types.typesSocialChoice.socialChoiceOptions options to specify a social choice function.
Source:
Returns:
- the results returned from a social choice function.
Type
types.typesSocialChoice.socialChoiceResults

module:compute/socialChoiceMethods/methodOfEqualShares(votes, socialChoiceOptions) → {types.typesSocialChoice.socialChoiceResults}

This method has rounds. groupCost is 1/seats. Add up scores. Divide groupCost by total to get factor to multiply scores by. For each voter, multiply scores by factor to get cost. Subtract cost from budget. If remaining budget is negative, add that amount to the deficit and set budget to 0. Check deficit to see if there is more groupCost to spend. Use this new groupCost like the old groupCost and do the steps above. Do this 10 times. That should be enough, maybe. If there is any deficit remaining, then subtract it from everybody.
Parameters:
Name Type Description
votes types.typesVotes.votes The object for vote data.
socialChoiceOptions types.typesSocialChoice.socialChoiceOptions options to specify a social choice function.
Source:
Returns:
- the results returned from a social choice function.
Type
types.typesSocialChoice.socialChoiceResults

module:compute/socialChoiceMethods/minimax(votes) → {types.typesSocialChoice.socialChoiceResults}

Disregard the weakest pairwise defeat until one candidate is unbeaten.
Parameters:
Name Type Description
votes types.typesVotes.votes The object for vote data.
Source:
Returns:
- the results returned from a social choice function.
Type
types.typesSocialChoice.socialChoiceResults

module:compute/socialChoiceMethods/olprA(votes, socialChoiceOptions) → {types.typesSocialChoice.socialChoiceResults}

Run an Open List Proportional Representation method. Call this variant by the name "A". Return a list of winning candidates and a list of allocated seats to parties. A voter votes for a candidate. Party lists help candidates pool their votes. Party lists are allocated seats. The most popular candidates in a party are elected.
Parameters:
Name Type Description
votes types.typesVotes.votes The object for vote data.
socialChoiceOptions types.typesSocialChoice.socialChoiceOptions options to specify a social choice function.
Source:
Returns:
- the results returned from a social choice function.
Type
types.typesSocialChoice.socialChoiceResults

module:compute/socialChoiceMethods/plurality(votes) → {types.typesSocialChoice.socialChoiceResults}

the candidate with the highest tally wins
Parameters:
Name Type Description
votes types.typesVotes.votes The object for vote data.
Source:
Returns:
- the results returned from a social choice function.
Type
types.typesSocialChoice.socialChoiceResults

module:compute/socialChoiceMethods/randomCandidate(votes) → {types.typesSocialChoice.socialChoiceResults}

pick a random candidate as the winner
Parameters:
Name Type Description
votes types.typesVotes.votes The object for vote data.
Source:
Returns:
- the results returned from a social choice function.
Type
types.typesSocialChoice.socialChoiceResults

module:compute/socialChoiceMethods/randomVoter(votes) → {types.typesSocialChoice.socialChoiceResults}

pick a random voter to select the winner
Parameters:
Name Type Description
votes types.typesVotes.votes The object for vote data.
Source:
Returns:
- the results returned from a social choice function.
Type
types.typesSocialChoice.socialChoiceResults

module:compute/socialChoiceMethods/sainteLague(votes, socialChoiceOptions) → {types.typesSocialChoice.socialChoiceResults}

Run the Sainte-Lague / Webster method of apportionment and return an allocation of seats.
Parameters:
Name Type Description
votes types.typesVotes.votes The object for vote data.
socialChoiceOptions types.typesSocialChoice.socialChoiceOptions options to specify a social choice function.
Source:
Returns:
- the results returned from a social choice function.
Type
types.typesSocialChoice.socialChoiceResults

module:compute/socialChoiceMethods/score(votes) → {types.typesSocialChoice.socialChoiceResults}

the candidate with the highest tally wins
Parameters:
Name Type Description
votes types.typesVotes.votes The object for vote data.
Source:
Returns:
- the results returned from a social choice function.
Type
types.typesSocialChoice.socialChoiceResults

module:compute/socialChoiceMethods/sntv(votes, socialChoiceOptions) → {types.typesSocialChoice.socialChoiceResults}

Single Non-Transferable Vote
Parameters:
Name Type Description
votes types.typesVotes.votes The object for vote data.
socialChoiceOptions types.typesSocialChoice.socialChoiceOptions options to specify a social choice function.
Source:
Returns:
- the results returned from a social choice function.
Type
types.typesSocialChoice.socialChoiceResults

module:compute/socialChoiceMethods/stv(votes, socialChoiceOptions) → {types.typesSocialChoice.socialChoiceResults}

Single Transferable Vote
Parameters:
Name Type Description
votes types.typesVotes.votes The object for vote data.
socialChoiceOptions types.typesSocialChoice.socialChoiceOptions options to specify a social choice function.
Source:
Returns:
- the results returned from a social choice function.
Type
types.typesSocialChoice.socialChoiceResults

module:compute/voteCasters/pairwise/castPairwise(geometry, castOptions) → {types.typesVotes.votes}

Voters cast votes for candidates.
Parameters:
Name Type Description
geometry types.typesGeometry.geometry geometry for casting votes
castOptions types.typesCast.castOptions options for how to cast votes.
Source:
Returns:
votes
Type
types.typesVotes.votes

module:compute/voteCasters/pairwise/castPairwiseGrid()

Tally votes.
Source:

module:compute/voteCasters/pairwise/castPairwiseIntervals1D()

Sum density of voter distributions along splits.
Source:

module:compute/voteCasters/pairwise/castPairwisePlanes2D()

Sum area of voter distributions to tally the votes.
Source:

module:compute/voteCasters/pairwise/castPairwisePoint() → {types.typesVote.pairwiseVote}

Vote for the closest candidate.
Source:
Returns:
Type
types.typesVote.pairwiseVote

module:compute/voteCasters/plurality/castPlurality(geometry, castOptions) → {types.typesVotes.votes}

Vote for one. Voters cast votes for candidates.
Parameters:
Name Type Description
geometry types.typesGeometry.geometry geometry for casting votes
castOptions types.typesCast.castOptions options for how to cast votes.
Source:
Returns:
votes
Type
types.typesVotes.votes

module:compute/voteCasters/plurality/castPluralityGrid() → {types.typesVotesForGeomGrid.votesForGeomGridPlurality}

Tally votes.
Source:
Returns:
Type
types.typesVotesForGeomGrid.votesForGeomGridPlurality

module:compute/voteCasters/plurality/castPluralityIntervals1D() → {types.typesVotesForGeom.votesForGeomPlurality}

Sum area under voter distributions to tally the votes.
Source:
Returns:
Type
types.typesVotesForGeom.votesForGeomPlurality

module:compute/voteCasters/plurality/castPluralityPoint() → {types.typesVote.pluralityVote}

Vote for the closest candidate.
Source:
Returns:
Type
types.typesVote.pluralityVote

module:compute/voteCasters/plurality/castPluralityQuadrature2D() → {types.typesVotesForGeom.votesForGeomPlurality}

Sum area of voter distributions to tally the votes.
Source:
Returns:
Type
types.typesVotesForGeom.votesForGeomPlurality

module:compute/voteCasters/ranking/castRanking(geometry, castOptions) → {types.typesVotes.votes}

Voters cast votes for candidates.
Parameters:
Name Type Description
geometry types.typesGeometry.geometry geometry for casting votes
castOptions types.typesCast.castOptions options for how to cast votes.
Source:
Returns:
votes
Type
types.typesVotes.votes

module:compute/voteCasters/ranking/castRankingFindPolygons(voterGeom, canPoints)

Make polygons for each group of voters that gives a unique ranking. Divide a starting polygon into smaller polygons. Use a dividing line for each pair of candidates.
Parameters:
Name Type Description
voterGeom object
canPoints Array.<Array.<number>>
Source:

module:compute/voteCasters/ranking/castRankingGrid(voterGeom, geometry, castOptions) → {types.typesVotesForGeomGrid.votesForGeomGridRanking}

Cast and tally votes on a grid of points.
Parameters:
Name Type Description
voterGeom types.typesGeoms.voterGeom
geometry types.typesGeometry.geometry
castOptions types.typesCast.castOptions
Source:
Returns:
votesForGeom
Type
types.typesVotesForGeomGrid.votesForGeomGridRanking

module:compute/voteCasters/ranking/castRankingIntervals1D()

Sum density of voter distributions within intervals to tally the votes.
Source:

module:compute/voteCasters/ranking/castRankingPoint() → {types.typesVote.rankingVote}

Vote for the closest candidate.
Source:
Returns:
Type
types.typesVote.rankingVote

module:compute/voteCasters/ranking/castRankingPolygons2D()

Sum area of voter distributions to tally the votes.
Source:

module:compute/voteCasters/ranking/makeRankingIntervals1D(canPoints)

Find the intervals over which voters share a ranking.
Parameters:
Name Type Description
canPoints Array.<number>
Source:

module:compute/voteCasters/ranking/splitConvex(points, plane) → {Object}

Beware, points are references to old points, so make sure to make a copy afterward.
Parameters:
Name Type Description
points Array.<Array.<number>>
plane Array.<number>
Source:
Returns:
- Object containing properties positive and negative, each being a set of points
Type
Object

module:compute/voteCasters/score/castScore(geometry, castOptions) → {object}

Voters cast votes for candidates.
Parameters:
Name Type Description
geometry object geometry for casting votes
Properties
Name Type Description
canPoints Array.<object> For 2D, an array of arrays: [x,y]. For 1D, an array of numbers: x.
voterGeoms Array.<object> For 2D, an array of objects: {x,y,w}. For 1D, an array of objects: {x,w,densityProfile}.
parties object
strategySeed object
voterStrategyList object
castOptions object options for how to cast votes.
Source:
Returns:
votes
Type
object

module:compute/voteCasters/score/castScoreGrid()

Tally votes.
Source:

module:compute/voteCasters/score/castScorePoint()

Vote for the closest candidate.
Source:

module:compute/voteCasters/scoreFull/castScoreFull(geometry, castOptions) → {object}

Voters cast votes for candidates.
Parameters:
Name Type Description
geometry object geometry for casting votes
Properties
Name Type Description
canPoints Array.<object> For 2D, an array of arrays: [x,y]. For 1D, an array of numbers: x.
voterGeoms Array.<object> For 2D, an array of objects: {x,y,w}. For 1D, an array of objects: {x,w,densityProfile}.
parties object
castOptions object options for how to cast votes.
Source:
Returns:
votes
Type
object

module:compute/voteCasters/scoreFull/castScoreFullGrid()

Tally votes.
Source:

module:sim/entities/Entities(menu, changes, commander, layout)

Parameters:
Name Type Description
menu Menu
changes Changes
commander Commander
layout Layout
Source:

module:sim/modes/SimMode(screen, menu, changes, commander)

Simulation is the main task we're trying to accomplish in this program. There are multiple states that the sim can be in. Each state simulates something different.
Parameters:
Name Type Description
screen Screen
menu Menu
changes Changes
commander Commander
Source:

module:view/save/addLoadConfigText(layout, commander)

Add buttons to layout for undo and redo, and connect them to commander for functionality.
Parameters:
Name Type Description
layout Layout
commander Commander
Source:
Add buttons for saving the configuration to a link.
Parameters:
Name Type Description
layout Layout
commander Commander
Source:
Add buttons for saving the configuration to a link.
Parameters:
Name Type Description
layout Layout
commander Commander
Source:

module:view/save/addSaveConfigToText(layout, commander)

Add buttons for saving the configuration to a textbox.
Parameters:
Name Type Description
layout Layout
commander Commander
Source:

module:view/save/addSaveData(layout)

Add buttons for saving the configuration to a textbox.
Parameters:
Name Type Description
layout Layout
Source:

module:view/save/checkURL()

Check if the URL is giving a configuration. Three cases: 1. No config in url 2. Long config in url 3. Short code in url that requires a database lookup. Then use a callback since we might have to wait for the database.
Source:

module:view/screen/ScreenCanvas()

Make the canvas part of the screen.
Source:

module:view/screen/ScreenDownload()

Make the download link part of the screen.
Source:

module:view/screen/ScreenSvg()

Make the svg part of the screen.
Source:

module:view/view/ViewMode()

Need to pass along the pub-sub pattern through view to specific viewModes. The views attach to these view states.
Source:

module:view/viewButtons/addUndo(layout, commander)

Add buttons to layout for undo and redo, and connect them to commander for functionality.
Parameters:
Name Type Description
layout Layout
commander Commander
Source:

module:view/viewButtons/candidateAddMakeButton(layout, canList)

Add button to layout for adding a candidate
Parameters:
Name Type Description
layout Layout
canList Sim
Source:

module:view/viewButtons/candidateDnAddMakeButton(layout, commander)

Add button to layout for adding a candidate
Parameters:
Name Type Description
layout Layout
commander Commander
Source:

module:view/viewButtons/voterShapeAddMakeButton(layout, voterShapeList)

Add buttons to layout for undo and redo, and connect them to commander for functionality.
Parameters:
Name Type Description
layout Layout
voterShapeList VoterShapeList
Source:

module:view/viewScreens/ViewSettings(changes)

Parameters:
Name Type Description
changes Changes
Source:

module:view/viz/VoterRender1D(voterShape, screen)

Graphics Component for voterShapes in 1D
Parameters:
Name Type Description
voterShape VoterShape
screen Screen
Source:

module:view/viz/VoterRender2D(voterShape, screen)

Graphics Component for voterShapes in 2D
Parameters:
Name Type Description
voterShape VoterShape
screen Screen
Source:

module:view/viz/colorBlend(f, colors) → {String}

Blend colors in given proportions.
Parameters:
Name Type Description
f Array.<Number> proportions of colors, as fraction of 1.
colors Array.<String> -
Source:
Returns:
- Color
Type
String

module:view/viz/colorBlender(f, colors) → {String}

Blend colors in given proportions.
Parameters:
Name Type Description
f Array.<Number> proportions of colors, as fraction of 1.
colors Array.<Array.<Number>> list of lists. rgb colors.
Source:
Returns:
- Color
Type
String

module:view/viz/getAllocation(electionResults) → {Object}

When there is just one winner, sometimes the allocation isn't included in the election results.
Parameters:
Name Type Description
electionResults Object
Source:
Returns:
allocation
Type
Object

module:view/viz/vizMESChartsCalcBudget(phaseResults)

Calculate data for charts of budget for MES
Parameters:
Name Type Description
phaseResults Object MES methodResults plus a little extra
Source:
Returns:
budgetDataMES

module:view/viz/vizMESChartsCalcShape(sequenceResults, screen, budgetDataMES)

Calculate shape data for charts of budget for MES
Parameters:
Name Type Description
sequenceResults Object MES methodResults plus a little extra candidate data
screen Object
budgetDataMES Object
Source:
Returns:
chartDataMES

module:view/viz/vizMESChartsRender(screen, chartDataMES)

Render data for charts of budget for MES
Parameters:
Name Type Description
screen *
chartDataMES * MES methodResults plus a little extra
Source:

module:view/vizCandidateDns/CandidateDnRendererList()

A simple list of candidateDnRenderer instances. It really just passes along function calls to each member of the list. It also checks if that member exists. Alternatively, it was deleted.
Source:

sortObjByKey()

https://stackoverflow.com/a/35810961
Source:

Type Definitions

grid

data for points on a grid
Type:
  • grid1D | grid2D
Source:

point

Type:
  • point1D | point2D
Source:

points

For 2D, an array of objects: {x,y,w}. For 1D, an array of objects: {x,w,densityProfile}.
Type:
Source:

votesForGeom

Type:
Source: