chiark
/
gitweb
/
~ian
/
appendix-a6.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
24bf2ba
)
stv: wip debug
author
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Mon, 1 Aug 2016 14:50:15 +0000
(15:50 +0100)
committer
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Mon, 1 Aug 2016 14:50:15 +0000
(15:50 +0100)
stv
patch
|
blob
|
history
diff --git
a/stv
b/stv
index bd952628c01ba1021a2294ef5295f24b4a585222..7059906ccb810b37f8cb06d58ab4253b8d33710d 100755
(executable)
--- a/
stv
+++ b/
stv
@@
-140,17
+140,18
@@
for (;;) {
}
$sorted{$_}{Cand} = $_ foreach keys %sorted;
foreach my $firstpref (sort keys %sorted) {
}
$sorted{$_}{Cand} = $_ foreach keys %sorted;
foreach my $firstpref (sort keys %sorted) {
- $sorted{$firstpref}{Total} = 0; # recount
foreach my $vote (@{ $sorted{$firstpref}{Votes} }) {
votelog $vote, "counted $vote->{Weight} for $firstpref";
foreach my $vote (@{ $sorted{$firstpref}{Votes} }) {
votelog $vote, "counted $vote->{Weight} for $firstpref";
- $sorted{$firstpref}{Total} += $vote->{Weight};
}
}
my @sorted;
}
}
my @sorted;
- my $sort_update = sub {
+ my $things_update = sub {
+ foreach my $s (@surpluses, values %sorted) {
+ $s->{Total} = sum0 map { $_->{Weight} } @{ $s->{Votes } };
+ }
@sorted = nsort_by { -$_->{Total} } values %sorted;
};
@sorted = nsort_by { -$_->{Total} } values %sorted;
};
- $
sort
_update->();
+ $
things
_update->();
print DEBUG "SORTED\n", Dumper(\@sorted);
print DEBUG "SORTED\n", Dumper(\@sorted);
@@
-209,7
+210,9
@@
for (;;) {
delete $sorted{ $s->{Cand} };
delete $continuing{ $s->{Cand} };
delete $sorted{ $s->{Cand} };
delete $continuing{ $s->{Cand} };
- $sort_update->();
+ $things_update->();
+ printf "%7s %10s %s\n", 'surplus', $s->{Cand}, pr $s->{Total};
+
$need_to_transfer_surplus = 0;
# before actually transferring a surplus, we will consider
# eliminating, and then reconsider with a lower quota
$need_to_transfer_surplus = 0;
# before actually transferring a surplus, we will consider
# eliminating, and then reconsider with a lower quota
@@
-261,7
+264,7
@@
for (;;) {
push @unsorted, @$votes;
}
push @unsorted, @$votes;
}
- $
sort
_update->();
+ $
things
_update->();
$need_to_transfer_surplus = 0;
}
$need_to_transfer_surplus = 0;
}