Anti-Harassment Tools/SecurePoll Improvements/Test Results/100 m so2010 elections

Comments edit

I used a script to generate 100 random elections. The popularity of the candidates followed the same distribution as first preference votes in the Math Stack Overflow 2010 moderator elections. My hope was to simulate re-running that election 100 times.

This election was chosen because we have had a problem with it in the past.

Election setup edit

  • Candidates: 5
  • Seats: 3
  • Votes: 164

Comparisons edit

A script compared the candidates SecurePoll and OpenSTV elected. No discrepancies in elected candidates were found in 100 elections.

R code used to generate test data edit

writeBallot <- function(filename, ballots, candidates, numSeats, totalVotes) {
    sink(filename)

    cat(sprintf("%s %s", length(candidates), numSeats))
    cat("\n")
    for (i in 1:totalVotes) {
        cat("1")
        for (cand in ballots[[i]]) {
            if (!is.na(cand)) {
                cat(" ")
                cat(cand)
            }
        }
        cat(" 0")
        cat("\n")
    }
    cat("0")
    cat("\n")
    for (candidate in candidates) {
        cat("\"")
        cat(candidate)
        cat("\"")
        cat("\n")
    }
    cat("\"")
    cat("ElectionTitle")
    cat("\"")
    cat("\n")

    sink()
}

candidates <- c(1, 2, 3, 4, 5)
numSeats <- 3
totalVotes <- 164
## math-stackexchange-com-2010-election-results.blt.csv comes from: https://github.com/dominic998/SecurePoll-Test-Data/blob/main/test_data/math-stackexchange-com-2010-election-results.blt.csv
m_so2010 <- read.csv("math-stackexchange-com-2010-election-results.blt.csv", header=TRUE)
distribution <- table(m_so2010$f)

for (j in 1:100) {

    ballots <- list()
    for (i in 1:totalVotes) {
        ballots[[i]] <- sample(1:length(candidates), sample(1:3, 1), replace=FALSE, distribution)
    }

    randomInt <- sample(1:9999999999, 1)
    filename <- sprintf("%s_%s_%s_%s.blt", length(candidates), numSeats, totalVotes, randomInt)

    writeBallot(filename, ballots, candidates, numSeats, totalVotes)

}

Files edit

All test data and output here: https://github.com/dominic998/SecurePoll-Test-Data/tree/main/test_data/m_so2010_blt

  • Test blt files: files ending in .blt
  • SecurePoll results: files ending _results.txt
  • OpenSTV results: files ending in .php

Environment edit

  • Where you tested: local docker
  • Version of SecurePoll: 3.0.0 (58bf4c8) 11:07, 31 August 2021