unkopt "candidate $cand", $_ foreach split / /, $';
$cands{$cand}{Desc} = $desc;
} elsif (m/^(\w*) :\s*(.*)\s*\|(.*)/) {
my ($voter,$prefs,$opts) = ($1,$2,$3);
unkopt "candidate $cand", $_ foreach split / /, $';
$cands{$cand}{Desc} = $desc;
} elsif (m/^(\w*) :\s*(.*)\s*\|(.*)/) {
my ($voter,$prefs,$opts) = ($1,$2,$3);
push @{ $v->{Prefs} }, [ $_ =~ m/\w+/g ]
foreach split /\s+/, $prefs;
foreach $_ (split / /, $opts) {
push @{ $v->{Prefs} }, [ $_ =~ m/\w+/g ]
foreach split /\s+/, $prefs;
foreach $_ (split / /, $opts) {
sub sortballots (@) {
# Takes each argument, which should be a ballot, sorts
# it into $cand{CAND}{Votes} according to first preference.
sub sortballots (@) {
# Takes each argument, which should be a ballot, sorts
# it into $cand{CAND}{Votes} according to first preference.
my $noncont = $c->{NonCont};
if ($noncont) {
votelog $v, "dropping pref $fp, $noncont";
my $noncont = $c->{NonCont};
if ($noncont) {
votelog $v, "dropping pref $fp, $noncont";
- $c->{Total} += $_->{Weight} foreach @{ $c->{Voters} };
- prf "cand %s: %s votes\n", $stage, $cand, $c->{Total};
+ $c->{Total} += $_->{Weight} foreach @{ $c->{Votes} };
+ prf "candidate %-10s: %10s votes\n", $cand, $c->{Total};
- $totalvalid += $_->{Total} foreach keys %cands;
- $quota = floor($totalvalid / (1 + $seats));
+ $totalvalid += $_->{Total} foreach values %cands;
+ $quota = ($totalvalid / (1 + $seats)) -> bfloor();
+ prf "quota %10s\n", $quota;
- my $win = $tie{"@all"}{$tiekey};
- die "need tie break, want $tiekey from @all" unless defined $win;
+ $selectcand = $tie{"@all"}{$tiekey};
+ die "need tie break, want $tiekey from @all"
+ unless defined $selectcand;
if (continuing() <= $seats_remain) {
foreach my $c (continuing()) {
prf "electing %s to fill remaining place(s)\n", $c->{Cand};
if (continuing() <= $seats_remain) {
foreach my $c (continuing()) {
prf "electing %s to fill remaining place(s)\n", $c->{Cand};
# SLGEO 48(3): we do arithmetic to 5 d3ecimal places,
# but always rounding down
votelog $v, "transferring with value $xfervalue (A=$A B=$B)";
$v->{Weight} = $xfervalue;
# SLGEO 48(3): we do arithmetic to 5 d3ecimal places,
# but always rounding down
votelog $v, "transferring with value $xfervalue (A=$A B=$B)";
$v->{Weight} = $xfervalue;
+
+ if (defined $tspr{"@$previously"}) {
+ die unless $tspr{"@$previously"} == $xfervalue;
+ } else {
+ $tspr{"@$previously"} = $xfervalue;
+ prf "transfer value of ballots %s: %10s\n",
+ "@$previously", $xfervalue;
+ }