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

From mediawiki.org

Comments[edit]

I used a script to generate 100 random elections. Voters were simulated casting votes for candidates based on the assumption that each candidate was equally popular.

Each election was run in SecurePoll and OpenSTV, and their respective elected candidates compared.

In 12 of 100 elections, the candidates SecurePoll elected differed from OpenSTV (here is an example of one of these). This is possibly for the same reason as 7_5_1000, but it is hard to tell for sure.

Election setup[edit]

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

Comparisons[edit]

A script compared the candidates SecurePoll and OpenSTV elected. I list below only the test data files where SecurePoll and OpenSTV differed:

  • 20_4_5000_2155278963.blt
  • 20_4_5000_2449345045.blt
  • 20_4_5000_2639270897.blt
  • 20_4_5000_3311518991.blt
  • 20_4_5000_5413623462.blt
  • 20_4_5000_5572588763.blt
  • 20_4_5000_5594736126.blt
  • 20_4_5000_6163321089.blt
  • 20_4_5000_6258154944.blt
  • 20_4_5000_8477213657.blt
  • 20_4_5000_8689352809.blt
  • 20_4_5000_8910242957.blt

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 <- dunif(1:20, 1, 20)

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_uniform_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 (624ef32) 00:10, 28 September 2021.