From 822b6e33eb7200adf793f117f1366925911c15ba Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Sun, 3 Nov 2024 23:30:32 +0100 Subject: [PATCH] Generate smaller numbers for testing --- nix/generate.sh | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/nix/generate.sh b/nix/generate.sh index 7d32ebc..537d0fe 100755 --- a/nix/generate.sh +++ b/nix/generate.sh @@ -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 @@ -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 @@ -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