[EM] simulator code for VFA with poll
Kevin Venzke
stepjak at yahoo.fr
Sat Dec 16 17:23:40 PST 2006
Hi,
I post this on EM since I am not sure Brian Olson receives emails from
me...
This is a simple attempt at VFA preceded by a poll. Essentially the
election is run once. Then all voters regard the result and move their
"for" vote (if necessary) to one of the top two non-disqualified
candidates. Since this results in a majority favorite, "against" votes
are not reconsidered.
I suppose that straight VFA will be a compromise between the FPP and
Condorcet results; VFA with poll should be closer to Condorcet but with
some monotonicity failures.
I hope there are no errors in this code. I hope it's of interest. I
like VFA because it's easy to count and behaves well with three
candidates.
Kevin Venzke
void VFAWithPoll::runElection( int* winnerR, const VoterArray& they )
{
int i;
int* fptally; int* lptally;
int winner; int winner2;
int numc = they.numc; int numv = they.numv;
fptally = new int[numc]; lptally = new int[numc];
for ( i = 0; i < numc; i++ ) {
fptally[i] = 0;
lptally[i] = 0;
}
for ( i = 0; i < numv; i++ ) {
fptally[they[i].getMax()]++;
lptally[they[i].getMin()]++;
}
{ int m = 0; int n = 0;
winner = 0; winner2 = 0;
for ( i = 0; i < numc; i++ ) {
if ( fptally[i] >= m && lptally[i]*2 <= numv ) {
winner2 = winner; n = m;
winner = i; m = fptally[i];
} else if ( fptally[i] >= n && lptally[i]*2 <= numv ) {
winner2 = i; n = fptally[i];
}
}
}
for ( i = 0; i < numc; i++ ) fptally[i] = 0;
for ( i = 0; i < numv; i++ ) {
if( they[i].getPref( winner ) >= they[i].getPref( winner2 ) )
fptally[winner]++;
else
fptally[winner2]++;
}
if( fptally[winner2] > fptally[winner] ) winner = winner2;
delete [] fptally;
delete [] lptally;
if ( winnerR ) *winnerR = winner;
}
___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
http://fr.mail.yahoo.com
More information about the Election-Methods
mailing list