Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/trunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ jobs:

- name: Trunk Check
uses: trunk-io/trunk-action@75699af9e26881e564e9d832ef7dc3af25ec031b # v1.2.4
with:
post-annotations: true
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ different voting systems, electorate models, and strategic behaviors.
See the [VSE FAQ](https://electionscience.github.io/vse-sim/) for an explanation
of the methods and published results.

See the [chart reproduction guide](docs/chart-reproduction.md) to generate the
full simulation CSV used by the chart analysis.

## Setup

The project supports Python 3.10 through 3.12 and uses
Expand Down
24 changes: 24 additions & 0 deletions docs/chart-reproduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: Chart data reproduction
layout: default
permalink: /chart-reproduction
---

The published charts are derived from a full simulation CSV. Generate that CSV
with the same settings used by the charts:

```bash
uv run python scripts/generate_published_results.py --elections 15000 \
--output artifacts/published-results
```

The command prints the generated filename. To explore that data with the
historical R analysis, install `data.table` and `scatterD3`, then pass the CSV
path explicitly:

```bash
Rscript vseCheck.R artifacts/published-results1.csv
```

The generated CSV is intentionally not committed. It records the model,
methods, seed, and iteration count in its first line.
49 changes: 49 additions & 0 deletions scripts/generate_published_results.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""Generate the complete simulation CSV consumed by the chart analysis.

Example:

uv run python scripts/generate_published_results.py --elections 15000 \
--output artifacts/published-results
"""

import argparse
import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parents[1]))

from debugDump import setDebug
from vse import CsvBatch, KSModel, allSystems, fuzzyMediaFor


def main():
parser = argparse.ArgumentParser()
parser.add_argument("--elections", type=int, default=15_000)
parser.add_argument("--seed", default="target15000")
parser.add_argument(
"--output",
type=Path,
default=Path("artifacts/published-results"),
help="Filename prefix; the runner appends a numeric CSV suffix.",
)
args = parser.parse_args()

setDebug(False)
args.output.parent.mkdir(parents=True, exist_ok=True)
batch = CsvBatch(
KSModel(dcdecay=(1, 3), wcdecay=(1.5, 3), dccut=.2, wcalpha=1.5),
allSystems,
nvot=40,
ncand=6,
niter=args.elections,
baseName=str(args.output),
media=fuzzyMediaFor(),
seed=args.seed,
force=True,
retain_rows=False,
)
print(batch.output_file)


if __name__ == "__main__":
main()
8 changes: 6 additions & 2 deletions vseCheck.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ library(scatterD3)
#
# fvse = rbind(fvse,fread("wtf2.csv"))

fvse = fread("target3.csv")
args = commandArgs(trailingOnly = TRUE)
if (length(args) != 1) {
stop("Usage: Rscript vseCheck.R PATH_TO_RESULTS.csv")
}
fvse = fread(args[[1]])
fuzVses = fvse[,mean(util-rand)/mean(best-rand),by=list(method,chooser)]
etype = fvse[method=="Schulze" & chooser=="honBallot",tallyVal0,by=eid]
names(etype) = c("eid","scenario")
Expand Down Expand Up @@ -135,4 +139,4 @@ honestScenarios2[,VSE:=vse*100]
library(ggplot2)
library(ggthemes)
ggplot(data = honestScenarios2[as.character(method) %in% levels(honestScenarios2[,method])[c(1:3,5)],], aes(x = VSE, y = method, group = method)) + geom_line(size=3) + xlim(70,100) + theme_gdocs() + theme(axis.title.y=element_blank()) + xlab("% Voter Satisfaction Efficiency (VSE)")
#(I think that refining the strategies can improve the function:backfire balance, but it's a)
#(I think that refining the strategies can improve the function:backfire balance, but it's a)
Loading