Anti-Harassment Tools/SecurePoll Improvements/Test Results/100 normal elections

Comments

edit

I used a script to generate 100 random elections. The popularity of the candidates followed a normal distribution (mean=10, sd=1).

Election setup

edit
  • Candidates: 20
  • Seats: 4
  • Votes: 5000

Comparisons

edit

A script compared the candidates SecurePoll and OpenSTV elected. No discrepancies 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, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
numSeats <- 4
totalVotes <- 5000
distribution <- dnorm(1:20, 10, 1)

for (j in 1:100) {

    ballots <- list()
    for (i in 1:totalVotes) {
        ballots[[i]] <- sample(1:length(candidates), sample(1:length(candidates), 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/100_normal_elections

  • 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 using PHPUnit
  • Version of SecurePoll: 3.0.0 (58bf4c8) 11:07, 31 August 2021