Skip to content

ozcan-durak/elsim

 
 

Repository files navigation

Election Simulator 3000

CircleCI Actions Status

This is a library of functions for running many simulations of different elections (Impartial Culture, spatial model, ...) held using different voting methods (Borda count, Approval voting, ...).

Goals:

  • Fast (~25,000 elections per second)
  • Flexible
  • Well-documented, easily-used and improved upon by other people
  • Well-tested and bug-free
  • Able to reproduce peer-reviewed research

Requirements

Current dependencies are numpy and scipy.

Optionally, elsim can use numba for speed. If not available, the code will still run, just more slowly.

Installation

One possibility is to install with pip:

pip install git+https://github.com/endolith/elsim.git

Documentation

Currently just the docstrings of the submodules and functions themselves, in numpydoc format.

Usage

Specify an election with three candidates (0, 1, 2), where two voters rank candidates 0 > 2 > 1, two voters rank candidates 1 > 2 > 0, and one ranks candidates 2 > 0 > 1:

>>> election = [[0, 2, 1],
                [0, 2, 1],
                [1, 2, 0],
                [1, 2, 0],
                [2, 0, 1]]

Calculate the winner using Black's method:

>>> from elsim.methods import black
>>> black(election)
2

Candidate 2 is the Condorcet winner, and wins under Black's method.

See /examples folder for more on what it can do.

Tests

Tests can be run by installing pytest, hypothesis, and then running pytest in the project folder.

Bugs / Requests

File issues on the Github issue tracker.

Similar projects

Election simulators

Voting system implementations

About

Election Simulator 3000: Simulates a variety of elections and voting methods

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%