<HTML><BODY>
<div>Thanks. I have created 2 methods.<br>
<br>
The first one is approval zero info. In this case, the voter averages his <span class="correction" id="">utility</span> for all the candidates and places his approval threshold at the average.<br>
<br>
The second one is the same as above. However, it runs 2 elections. The first election uses the same as above and is considered a poll (might be worth reducing the number of voters to <<span class="correction" id="">numv</span> ?). For the second 'real' election, the threshold is set at the average of the winner and second place in the poll. This <span class="correction" id="">approx</span> means that the voter will vote for his <span class="correction" id="">favourite</span> of the top 2 and all he prefers more.<br>
<br>
Unless anyone objects, I will post the code here (or at least if someone objects, I won't do it again). This has the added advantage that any code errors may be spotted :).<br>
<br>
I don't have the ability to compile as I am basing it on the code snippet, so it may not compile, but I did read it through.<br>
<br>
void <span class="correction" id="">ApprovalNoInfo</span>::<span class="correction" id="">runElection</span>( <span class="correction" id="">int</span>* <span class="correction" id="">winnerR</span>, <span class="correction" id="">const</span> <span class="correction" id="">VoterArray</span>& they ) {<br>
<span class="correction" id="">int</span> i,j;<br>
<span class="correction" id="">int</span>* <span class="correction" id="">talley</span>;<br>
<span class="correction" id="">int</span> winner, second_place;<br>
<span class="correction" id="">int</span> <span class="correction" id="">numc</span> = they.<span class="correction" id="">numc</span>;<br>
<span class="correction" id="">int</span> <span class="correction" id="">numv</span> = they.<span class="correction" id="">numv</span>;<br>
<br>
// <span class="correction" id="">init</span> things<br>
<span class="correction" id="">talley</span> = new <span class="correction" id="">int</span>[<span class="correction" id="">numc</span>];<br>
for ( i = 0; i < <span class="correction" id="">numc</span>; i++ ) {<br>
<span class="correction" id="">talley</span>[i] = 0;<br>
}<br>
<br>
double* thresh;<br>
thresh = new double[<span class="correction" id="">numv</span>];<br>
<br>
for ( i = 0; i < <span class="correction" id="">numv</span>; i++ ) {<br>
thresh[i] = 0;<br>
for ( j = 0; j < <span class="correction" id="">numc</span>; j++) {<br>
thresh[i] += they[i].<span class="correction" id="">getPref</span>( j );<br>
}<br>
thresh[i] = thresh[i]/<span class="correction" id="">numc</span>;<br>
}<br>
<br>
// count votes for each candidate<br>
for ( i = 0; i < <span class="correction" id="">numv</span>; i++ ) {<br>
for ( j = 0; j < <span class="correction" id="">numc</span>; j++) {<br>
if ( they[i].<span class="correction" id="">getPref</span>[j] >= thresh[i] ) {<br>
<span class="correction" id="">talley</span>[j]++;<br>
}<br>
}<br>
}<br>
// find winner + second place<br>
{<br>
<span class="correction" id="">int</span> m = -1;<br>
<span class="correction" id="">int</span> <span class="correction" id="">m2</span> = -2; // second place<br>
for ( i = 0; i < <span class="correction" id="">numc</span>; i++ ) {<br>
if ( <span class="correction" id="">talley</span>[i] > m ) {<br>
<span class="correction" id="">m2</span> = m;<br>
m = <span class="correction" id="">talley</span>[i];<br>
second_place=winner;<br>
winner = i;<br>
} else if ( <span class="correction" id="">talley</span>[i] > <span class="correction" id="">m2</span> ) {<br>
<span class="correction" id="">m2</span> = <span class="correction" id="">talley</span>[i];<br>
second_place = i;<br>
}<br>
}<br>
}<br>
<br>
<br>
delete [] <span class="correction" id="">talley</span>;<br>
delete [] thresh;<br>
if ( <span class="correction" id="">winnerR</span> ) {<br>
*<span class="correction" id="">winnerR</span> = winner;<br>
*(<span class="correction" id="">winnerR</span>+1) = second_place; // not really needed<br>
}<br>
<br>
}<br>
<br>
-----------------------------------------------------<br>
</div>
<div> <br>
void <span class="correction" id="">ApprovalWithPoll</span>::<span class="correction" id="">runElection</span>( <span class="correction" id="">int</span>* <span class="correction" id="">winnerR</span>, <span class="correction" id="">const</span> <span class="correction" id="">VoterArray</span>& they ) {<br>
<span class="correction" id="">int</span> i,j;<br>
<span class="correction" id="">int</span>* <span class="correction" id="">talley</span>;<br>
<span class="correction" id="">int</span> winner, second_place;<br>
<span class="correction" id="">int</span> <span class="correction" id="">numc</span> = they.<span class="correction" id="">numc</span>;<br>
<span class="correction" id="">int</span> <span class="correction" id="">numv</span> = they.<span class="correction" id="">numv</span>;<br>
<br>
// <span class="correction" id="">init</span> things<br>
<span class="correction" id="">talley</span> = new <span class="correction" id="">int</span>[<span class="correction" id="">numc</span>];<br>
for ( i = 0; i < <span class="correction" id="">numc</span>; i++ ) {<br>
<span class="correction" id="">talley</span>[i] = 0;<br>
}<br>
<br>
double* thresh;<br>
thresh = new double[<span class="correction" id="">numv</span>];<br>
<br>
for ( i = 0; i < <span class="correction" id="">numv</span>; i++ ) {<br>
thresh[i] = 0;<br>
for ( j = 0; j < <span class="correction" id="">numc</span>; j++) {<br>
thresh[i] += they[i].<span class="correction" id="">getPref</span>( j );<br>
}<br>
thresh[i] = thresh[i]/<span class="correction" id="">numc</span>;<br>
}<br>
<br>
// count votes for each candidate<br>
for ( i = 0; i < <span class="correction" id="">numv</span>; i++ ) {<br>
for ( j = 0; j < <span class="correction" id="">numc</span>; j++) {<br>
if ( they[i].<span class="correction" id="">getPref</span>[j] >= thresh[i] ) {<br>
<span class="correction" id="">talley</span>[j]++;<br>
}<br>
}<br>
}<br>
// find winner + second place<br>
{<br>
<span class="correction" id="">int</span> m = -1;<br>
<span class="correction" id="">int</span> <span class="correction" id="">m2</span> = -2; // second place<br>
for ( i = 0; i < <span class="correction" id="">numc</span>; i++ ) {<br>
if ( <span class="correction" id="">talley</span>[i] > m ) {<br>
<span class="correction" id="">m2</span> = m;<br>
m = <span class="correction" id="">talley</span>[i];<br>
second_place=winner;<br>
winner = i;<br>
} else if ( <span class="correction" id="">talley</span>[i] > <span class="correction" id="">m2</span> ) {<br>
<span class="correction" id="">m2</span> = <span class="correction" id="">talley</span>[i];<br>
second_place = i;<br>
}<br>
}<br>
}<br>
<br>
// Above assumed to be 'poll'<br>
<br>
// <span class="correction" id="">init</span> things<br>
<span class="correction" id="">talley</span> = new <span class="correction" id="">int</span>[<span class="correction" id="">numc</span>];<br>
for ( i = 0; i < <span class="correction" id="">numc</span>; i++ ) {<br>
<span class="correction" id="">talley</span>[i] = 0;<br>
}<br>
<br>
<br>
// Threshold set to average of top 2 from 'poll'<br>
for ( i = 0; i < <span class="correction" id="">numv</span>; i++ ) {<br>
thresh[i] = ( they[i].<span class="correction" id="">getPref</span>[winner] + they[i].<span class="correction" id="">getPref</span>[second_place] ) / 2.0 ;<br>
}<br>
<br>
// count votes for each candidate<br>
for ( i = 0; i < <span class="correction" id="">numv</span>; i++ ) {<br>
for ( j = 0; j < <span class="correction" id="">numc</span>; j++) {<br>
if ( they[i].<span class="correction" id="">getPref</span>[j] >= thresh[i] ) {<br>
<span class="correction" id="">talley</span>[j]++;<br>
}<br>
}<br>
}<br>
// find winner + second place<br>
{<br>
<span class="correction" id="">int</span> m = -1;<br>
<span class="correction" id="">int</span> <span class="correction" id="">m2</span> = -2; // second place<br>
for ( i = 0; i < <span class="correction" id="">numc</span>; i++ ) {<br>
if ( <span class="correction" id="">talley</span>[i] > m ) {<br>
<span class="correction" id="">m2</span> = m;<br>
m = <span class="correction" id="">talley</span>[i];<br>
second_place=winner;<br>
winner = i;<br>
} else if ( <span class="correction" id="">talley</span>[i] > <span class="correction" id="">m2</span> ) {<br>
<span class="correction" id="">m2</span> = talley[i];<br>
second_place = i;<br>
}<br>
}<br>
}<br>
<br>
delete [] talley;<br>
delete [] thresh;<br>
if ( <span class="correction" id="">winnerR</span> ) {<br>
*<span class="correction" id="">winnerR</span> = winner;<br>
*(<span class="correction" id="">winnerR</span>+1) = second_place;<br>
}<br>
<br>
<br>
// return <span class="correction" id="">pickOneHappiness</span>( they, numv, winner );<br>
}<br>
<br>
<br>
</div>
<div style="clear: both;"><span class="correction" id="">Raphfrk</span><br>
--------------------<br>
Interesting site<br>
"what if anyone could modify the laws"<br>
<br>
<span class="correction" id="">www</span>.<span class="correction" id="">wikocracy</span>.<span class="correction" id="">com</span></div>
<br>
<div id="AOLMsgPart_4_d189fc5b-4e16-411a-8cd3-9f181c7c6981" class="AOLPlainTextBody"><pre><tt>
</tt></pre>
</div>
<!-- end of AOLMsgPart_4_d189fc5b-4e16-411a-8cd3-9f181c7c6981 -->
<div class="AOLPromoFooter">
<hr style="margin-top:10px;" />
<a href="http://pr.atwola.com/promoclk/100122638x1081283466x1074645346/aol?redir=http%3A%2F%2Fwww%2Eaim%2Ecom%2Ffun%2Fmail%2F" target="_blank"><b>Check Out the new free AIM(R) Mail</b></a> -- 2 GB of storage and industry-leading spam and email virus protection.<br />
</div>
</BODY></HTML>