Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

Commit

Permalink
Generate smaller numbers for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
infinisil committed Nov 3, 2024
1 parent c9b64d5 commit 822b6e3
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions nix/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ export BC_ENV_ARGS="-lq"
# Every voter has a normal-distributed preference X

# 25 voters and 10 candidates is the maximum for the free tier
voterCount=450
voterCount=25
# 9 so that we have candidates -2, -1.5, ..., 0, ..., 1.5, 2, instead of messy numbers
candidateCount=23
seatCount=7
candidateCount=9
seatCount=3
# With 40%, a minority group should get a representative
minorityPercentage=15
minorityPercentage=40


# Voters are represented with a single number. They vote for the candidate nearest to their number
Expand All @@ -23,19 +23,18 @@ normal() {
}

for i in $(seq "$voterCount"); do
voterValues+=( "$(normal 2 0)" )
# Check proportional representation works
#if (( 100 * i / voterCount <= minorityPercentage )); then
# # The minority group votes with a wide standard deviation around candidate (-3)
# # such that no single candidate gets more 1st ranks than the majority group.
# # We want to test that this group still get a representative seat regardless
# voterValues+=( "$(normal 2 -3)" )
#else
# # The majority group all votes effectively for the same candidate (3) with only minor differences,
# # which ensures that a number of candidates that could in theory fill all seats get most 1st and 2nd ranks,
# # but we don't want that to happen because of proportional representation
# voterValues+=( "$(normal 0.5 3)" )
#fi
if (( 100 * i / voterCount <= minorityPercentage )); then
# The minority group votes with a wide standard deviation around candidate (-3)
# such that no single candidate gets more 1st ranks than the majority group.
# We want to test that this group still get a representative seat regardless
voterValues+=( "$(normal 2 -3)" )
else
# The majority group all votes effectively for the same candidate (3) with only minor differences,
# which ensures that a number of candidates that could in theory fill all seats get most 1st and 2nd ranks,
# but we don't want that to happen because of proportional representation
voterValues+=( "$(normal 0.1 3)" )
fi
done

# Sort the voters by their value number and therefore also ballots
Expand All @@ -46,7 +45,7 @@ declare -p voterValues >&2
# where people want to have a representative to vote for, and if they don't, they'd nominate themselves.
candidates=()
for (( i=1; i <= candidateCount; i++ )); do
candidates[i]=$(bc <<< "scale=1; ($i - 1) * 8 / ($candidateCount - 1) - 4")
candidates[i]=$(bc <<< "scale=0; ($i - 1) * 8 / ($candidateCount - 1) - 4")
done
declare -p candidates >&2

Expand Down

0 comments on commit 822b6e3

Please sign in to comment.