Coder Social home page Coder Social logo

electionscience / vse-sim Goto Github PK

View Code? Open in Web Editor NEW
55.0 9.0 16.0 17.87 MB

Methods for running simulations to calculate Voter Satisfaction Efficiency (VSE) of various voting systems in various conditions.

Home Page: https://electionscience.github.io/vse-sim

Python 93.45% R 6.28% JavaScript 0.27%
comsoc democracy elections electoral-system-visualization electoral-systems python python3 research simulation social-choice

vse-sim's Introduction

Voter Satisfaction Efficiency

These are some methods for running VSE (Voter Satisfaction Efficiency) simulations for various voting systems.

See Voter Satisfaction Efficiency FAQ for an explanation of the methods and results.

Installing the code

Requirements: python3, scipy, pydoc

Testing uses pydoc, which should make most things pretty self-documenting.

E.g.:

python3 -m doctest methods.py
python3 -m doctest voterModels.py
python3 -m doctest dataClasses.py
python3 vse.py

Running simulations

Try

$ python3
>>> from vse import CsvBatch, baseRuns, Mav, medianRuns, Score
>>> from voterModels import PolyaModel
>>> csvs = CsvBatch(PolyaModel(), [[Score(), baseRuns], [Mav(), medianRuns]], nvot=5, ncand=4, niter=3)
>>> csvs.saveFile()

and look for the results in SimResults1.csv

vse-sim's People

Contributors

brianolson avatar brotherjack avatar endolith avatar fsargent avatar jamesonquinn avatar marcosb avatar nealmcb avatar net avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vse-sim's Issues

Request for Confidence intervals

Could we get some confidence intervals plotted on the graphs? Some of these results look a bit funky. (Most notably, some methods seem to outperform score under "100% honest" voting, which should be impossible; perfectly-honest score voting maximizes utility by definition).

Multi-winner elections

Hello, thank you for this wonderful tool. I'd be very interested in seeing if it could be used for a multi-winner election simulation, though I'm not sure what the mathematical/theoretical background on that looks like. Particularly comparing proportional AV/STV/Borda would be helpful. Thoughts?

Fix strategies

  • Make strategies independent of systems, so you can mix-and-match
  • Include a Borda-type strategy
  • Include a Condorcet-type strategy

Try to pull in real-world voter patterns into data seeding

I will try to get this if I can, but wanted to file an issue to track (& just in case anyone gets to it before me)

I wonder if it makes sense to pull some data from real-world elections (e.g. https://abc7ny.com/ranked-choice-voting-nyc-mayoral-race-democratic-primary-eric-adams/10884814/) into voter behaviors?

For example, it'd be interesting to include ~20% of voters only voting for 1 candidate (assuming that's a common ratio), as well as differences in voting patterns when # of candidates > # of voting positions (this specifically only applies when the # of rankings is < # of candidates)

Document random seeds, and allow specification of seeds for reproducibility and testing

The ability to replicate results is critical for simulations and other scientific results used in policy discussions related to fundamental aspects of society like election methods.

For replication of results, testing and exploring the implications of election simulations, the system needs to document the random seeds used in each simulation when reporting the results, and allow the user to specify the seed for a simulation and any other parameters necessary to reproduce the result.

For background on reproducability in another complicated and important field, see A minimum standard for publishing computational results in the weather and climate sciences: Damien Irving

Graphs of probability distributions

Currently you show a bunch of symbols of different sizes and colors, with each representing an average of many simulations, correct? But it's pretty cluttered and hard to see general trends.

Could you just plot the voter happiness directly as a probability distribution for each system? (Does it make sense to refer to the VSE of a single simulation?)

Kind of like http://electology.org/sites/default/files/comparing_voting_methods_simplicity_group_satisfaction.png

but more like this:

probdist

or maybe beanplot style:

figure-4-region-state-interaction-and-party-politics-notes-bean-plot-with-density-trace

voterModels fails doctest

$ python -m doctest voterModels.py
**********************************************************************
File "/home/ted/python/my-vse-sim/voterModels.py", line 269, in voterModels.DimModel
Failed example:
    dm(2,4)
Expected:
    [(4.25, 0.0, 1.25, 4.25), (2.0, 1.25, 0.0, 2.0)]
Got:
    [(-1.8439088914585775, -0.0, -1.0, -1.8439088914585775), (-1.2649110640673518, -1.0, -0.0, -1.2649110640673518)]
**********************************************************************
1 items had failures:
   1 of   3 in voterModels.DimModel
***Test Failed*** 1 failures.

Add target4.csv; Document vseCheck.R

It looks like vseCheck.R is used to produce the visualizations used in the documentation, like .

This appears to be a way to install the R packages (but perhaps not the best way?):

$ R
> install.packages("scatterD3") 
> install.packages("data.table")

$ sudo mv /tmp/Rtmp-X49N6W-or-whatever/downloaded_packages/* /usr/local/lib/R/site-library

Then, trying to reproduce the figures yields this:

$ R -f vseCheck.R
Error in fread("target4.csv") : 
  File 'target4.csv' does not exist. Include one or more spaces to consider the input a system command.

So I'm guessing we need that file also, perhaps among other things.

Any other tips on reproducing (and customizing!) the output would be great.

Thanks!

Add V321Majority

Like v321, but with a separate runoff ballot if the last stage pairwise win is not by a majority (and measure how frequently such a runoff is needed).

Majority Judgment bug?

Specifically, under 100% strategic voting, majority judgment has 0.851 VSE vs 0.947 for approval. But isn't majority judgment identical to approval when all voters are strategic?

Similar library

So I realize this isn't quite the right place for this, but I just wanted to mention that I wrote a library along similar lines here: https://github.com/fresheneesz/elect . It has the ability to easily write and plug in new forms of preference capturing (ballots), voting strategies, and voting methods. It also can handle both multi-winner and single-winner elections.

I also came to the conclusion that "voter satisfaction" is a better way to describe this than "regret". I take it you probably at least know of Warren Smith - he put up some simulation code I wrote here: http://rangevoting.org/multiWinnerBaysianRegret.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.