org.bolson.vote
Class IRNR

java.lang.Object
  extended by org.bolson.vote.VotingSystem
      extended by org.bolson.vote.RatedVotingSystem
          extended by org.bolson.vote.IRNR
All Implemented Interfaces:
java.io.Serializable

public class IRNR
extends RatedVotingSystem

Instant Runoff Normalized Ratings

See Also:
Serialized Form

Field Summary
protected  double[] talley
           
 
Fields inherited from class org.bolson.vote.VotingSystem
debug, NO_VOTE, numc
 
Constructor Summary
IRNR(int numCandidates)
           
 
Method Summary
 java.lang.String getDebugHTML(java.lang.String[] names)
          Return HTML representation of debug data.
 int[] getWinners()
          Do processing if necessary, return winners.
 int[] getWinners(java.io.PrintWriter out)
          Print verbose explaination of internal process as it happens.
 int[] getWinners(java.io.PrintWriter out, int numSeats)
          Multi-seat IRNR.
 java.lang.String htmlSummary(java.lang.String[] names)
          A fancy html representation.
 VotingSystem init(java.lang.String[] argv)
          Arguments to modify behavior of VotingSystem
 java.lang.String name()
          Return name of this voting system.
 java.lang.String toString()
           
 java.lang.String toString(java.lang.String[] names)
          A more interesting representation.
 int voteRating(double[] rating)
           
 int voteRating(float[] rating)
           
 int voteRating(int[] rating)
           
 
Methods inherited from class org.bolson.vote.RatedVotingSystem
voteRanking
 
Methods inherited from class org.bolson.vote.VotingSystem
checkRatedVote, getDebugText, getNumberOfCandidates, getWinners, isValidRankedVote, isValidRatedVote, normalize, normalize, normalize, normalize, normalize, normalizeL2, normalizeL2, normalizeL2, normalizeL2, normalizeL2, stretch, voteRating
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

talley

protected double[] talley
Constructor Detail

IRNR

public IRNR(int numCandidates)
Method Detail

name

public java.lang.String name()
Description copied from class: VotingSystem
Return name of this voting system. This is a function so that it can potentially construct a detailed name based on options set in init().

Overrides:
name in class VotingSystem
Returns:
a descriptive name

init

public VotingSystem init(java.lang.String[] argv)
Description copied from class: VotingSystem
Arguments to modify behavior of VotingSystem

Overrides:
init in class VotingSystem
Returns:
this so that you can do
vs = (new VS(numc)).init( new String[]{"blah", "grunt"} );

voteRating

public int voteRating(int[] rating)
Overrides:
voteRating in class RatedVotingSystem
Parameters:
rating - An array int[numc]. rating[i] is the rating of choice i. A rating can be any int value. Higher means more preferred. NO_VOTE for unrated.
Returns:
0 on success

voteRating

public int voteRating(float[] rating)
Specified by:
voteRating in class VotingSystem
Parameters:
rating - An array int[N]. rating[i] is the rating of choice i. A rating can be any int value. Higher means more preferred. NO_VOTE for unrated.
Returns:
0 on success

voteRating

public int voteRating(double[] rating)
Overrides:
voteRating in class RatedVotingSystem
Parameters:
rating - An array int[N]. rating[i] is the rating of choice i. A rating can be any int value. Higher means more preferred. NO_VOTE for unrated.
Returns:
0 on success

getWinners

public int[] getWinners()
Description copied from class: VotingSystem
Do processing if necessary, return winners.

It is recommended to cache the return value in such a way that calling this function again does not do complex recalculation. That cache should be cleared if voteRating or voteRanking is called.

Specified by:
getWinners in class VotingSystem
Returns:
indecies of winners (hopefully 1 of them)

getWinners

public int[] getWinners(java.io.PrintWriter out)
Description copied from class: VotingSystem
Print verbose explaination of internal process as it happens. By default, do no printing and return result of getWinners() .

Overrides:
getWinners in class VotingSystem
Parameters:
out - where to print
Returns:
indecies of winners, hopefully 1 of them but in case of ties there may be more. Check .length to be sure.
See Also:
VotingSystem.getWinners(), VotingSystem.debug, VotingSystem.getDebugText(String[]), VotingSystem.getDebugHTML(String[])

getWinners

public int[] getWinners(java.io.PrintWriter out,
                        int numSeats)
Multi-seat IRNR. Everyone who votes for a winner shares in the distribution of the overvote and retains that fraction of their voting power.

Overrides:
getWinners in class VotingSystem
Parameters:
out - where to print news and diagnostics
numSeats - the number of seats available.
Returns:
indecies of winners, hopefully numSeats of them but in case of ties there may be more and in case of some internal schism there may be fewer. Check .length to be sure.
See Also:
VotingSystem.getWinners(int), VotingSystem.debug, VotingSystem.getDebugText(String[]), VotingSystem.getDebugHTML(String[])

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(java.lang.String[] names)
Description copied from class: VotingSystem
A more interesting representation. Include the names of the choices voted upon in the representation.

Specified by:
toString in class VotingSystem
Parameters:
names - The names of the choices.
Returns:
state, with names!

htmlSummary

public java.lang.String htmlSummary(java.lang.String[] names)
Description copied from class: VotingSystem
A fancy html representation. Include the names of the choices voted upon in the representation.

Specified by:
htmlSummary in class VotingSystem
Parameters:
names - The names of the choices. May be null.
Returns:
state, with names!

getDebugHTML

public java.lang.String getDebugHTML(java.lang.String[] names)
Description copied from class: VotingSystem
Return HTML representation of debug data. Default implementation is: "<PRE>"+getDebugText()+"</PRE>" (except that this method returns null or the empty string if getDebugText() returns null or the empty string).

Overrides:
getDebugHTML in class VotingSystem
Parameters:
names - Symbolic names for the choices makes human debugging easier. May be null.
Returns:
debug HTML
See Also:
VotingSystem.debug