[EM] simulator code for VFA

Kevin Venzke stepjak at yahoo.fr
Fri Dec 15 13:24:17 PST 2006


Hi,

I believe this code is good for VFA. I am assuming there is a "getMin"
similar to "getMax".

I might also like to implement two-slot MMPO (average rating as the
approval cutoff).

It would be interesting to try implementing a "strategic Borda." Perhaps
start with a zero-info approval round, and then have everyone vote Borda
sincerely, except that the better frontrunner is ranked best, and the
worst frontrunner is ranked worst. This would probably look as interesting
as the IRV results.

Kevin Venzke

void VoteForAndAgainst::runElection( int* winnerR, const VoterArray& they )
{
    int i;
    int* fptally;
    int* lptally;
    int winner;
    int numc = they.numc;
    int numv = they.numv;
    
    // init things
    fptally = new int[numc];
    lptally = new int[numc];
    for ( i = 0; i  < numc; i++ ) {
        fptally[i] = 0;
        lptally[i] = 0;
    }
    
    // count first and last prefs for each candidate
    for ( i = 0; i < numv; i++ ) {
        fptally[they[i].getMax()]++;
        lptally[they[i].getMin()]++;
    }

    // find winner
    {
        int m = 0;
        winner = 0;
        for ( i = 0; i < numc; i++ ) {
            if ( fptally[i] >= m && lptally[i]*2 <= numv ) {
                m = fptally[i];
                winner = i;
            }
        }
    }
    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