Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
+-----------------------------------------+
| The Single Transferrable Vote Algorithm |
+-----------------------------------------+
Problem: M voters must elect K of N candidates.
Input: M x N matrix, Tbl, of votes.
Tbl(i,j) = p, 1<=p<=N,
means that voter i gave preference p to candidate j.
Every voter assigns to each candidate a unique number from
1 (highest preference) to N (lowest preference).
(A voter may assign only the first n < N preferences. In
that case, the other N-n candidates receive a preference of N.)
Weakest candidate:
The candidate with the fewest votes of preference 1.
Ties are broken by fewest votes of preference 2, then 3, etc.
Output: List of K elected candidates in order of election.
Redistribute(n, Tbl):
for v <-- 1 to M
p <-- Tbl(v,n) {* v's preference for candidate n *}
for c <-- 1 to N
p' <-- Tbl(v,c) {* v's preference for candidate c *}
if p' > p then decrement Tbl(v,c) by one
end for
end for
Now remove candidate n from Tbl {* column n *}
Procedure STV
Elected <-- empty
T <-- Tbl {* Start with the original vote matrix *}
for E <-- 1 to K
N' <-- N-E+1 {* Choose a winner among N' candidates *}
T' <-- T {* store the current vote matrix *}
while (no candidate has a majority of 1st preferences)
weak <-- weakest candidate
Redistribute(weak, T) {* remove weakest *}
end while
win <-- the majority candidate
Elected <-- append(Elected, [win])
T <-- T' {* restore back to N' candidates *}
Redistribute(win, T) {* remove winner & redistrb. votes *}
end for
End STV