Skip to content

Python simulation framework for comparing representative voting methods using spatial preference models

Notifications You must be signed in to change notification settings

Charlie-Steiner/voting-simulation

Repository files navigation

Voting Simulation

A Python framework for comparing representative voting methods using spatial preference models. Voters and candidates are positioned in N-dimensional space, and various voting methods are evaluated on distance and fairness metrics.

Voting Methods

  • Method of Equal Shares (MES) - Proportional approval method where voters "pay" for candidates from an equal budget
  • Single Transferable Vote (STV) - Ranked-choice voting with surplus transfers using weighted inclusive Gregory method and Droop quota
  • Sequential Proportional Approval Voting (seq-PAV) - Greedy approval-based method with configurable approval thresholds
  • Party Voting - Voters choose closest party, seats allocated proportionally

Metrics

  • Distance metrics: Average nearest/median/mean distance from voters to winners
  • Theil index: Inequality measure for distance distributions
  • Representation score: Fraction of voters with an approved winner

Installation

pip install -e .
pip install -e ".[dev]"  # includes pytest, black, mypy

Usage

# Run demo
python demo.py

# Run parameter sweep comparing all methods
python sweep_simulation.py --samples 20 --output sweep_results.csv

# Generate visualizations from sweep results
python visualize_sweep.py

# Run Pareto frontier analysis (STV vs seq-PAV)
python pareto_analysis.py

# Run tests
python -m pytest tests/ -v

Results

Parameter Sweep

Comparison across cluster spread (0.15, 0.4), candidates (30-60), seats (10-20), and cluster count (2, 6):

Method Comparison

Heatmaps

Summary (averaged across configurations):

Method Avg Nearest Avg Median Theil (Median) Rep Score
seq-PAV 0.373 0.769 0.093 1.000
MES 0.366 0.769 0.098 1.000
seq-PAV-10% 0.307 0.825 0.075 1.000
STV 0.293 0.841 0.068 1.000
Random 0.334 0.910 0.055 0.999

Pareto Frontier Analysis

Is STV on the Pareto frontier when compared to seq-PAV with varying approval thresholds?

Pareto Analysis

Finding: STV is ON the Pareto frontier. No seq-PAV configuration dominates STV.

  • STV achieves the best nearest-winner distance (0.170), better than even seq-PAV-5% (0.178)
  • The tradeoff: STV has higher median distance (0.808) vs seq-PAV-40% (0.682)
  • STV's ranked-choice mechanism reaches a region of the frontier that approval-based methods cannot

Key insights:

  • Best median distance: seq-PAV and MES with ~40% approval threshold
  • Best nearest distance: STV - ensures every voter has a close representative
  • Approval threshold tradeoff: Tighter thresholds (5-10%) approach STV behavior; wider thresholds (35-40%) optimize median distance
  • All proportional methods achieve perfect representation (rep_score = 1.0)

About

Python simulation framework for comparing representative voting methods using spatial preference models

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages