org.bolson.vote
Class IRNRP

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

public class IRNRP
extends RatedVotingSystem

Instant Runoff Normalized Ratings Proportional

See Also:
IRNR, Serialized Form

Field Summary
protected  double[] talley
           
 
Fields inherited from class org.bolson.vote.VotingSystem
debug, NO_VOTE, numc
 
Constructor Summary
IRNRP(int numCandidates)
          In addition to interfaced methods, there shall be a constructor taking the integer number N of choices to be voted on.
 
Method Summary
 java.lang.String getDebugText(java.lang.String[] names)
          Return textual representation of debug data.
protected  void getScaledDoubleVote(double[] dt, java.lang.Object o, double weight, boolean[] active)
           
 int[] getWinners()
          Do processing if necessary, return winners.
 int[] getWinners(int numSeats)
          Do processing if necessary, return winners.
 java.lang.String htmlSummary(java.lang.String[] names)
          A fancy html representation.
 VotingSystem init(java.lang.String[] argv)
          Arguments to modify behavior of IRNRP
 java.lang.String name()
          Return name of this voting system.
 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, getDebugHTML, getNumberOfCandidates, getWinners, 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, toString, wait, wait, wait
 

Field Detail

talley

protected double[] talley
Constructor Detail

IRNRP

public IRNRP(int numCandidates)
In addition to interfaced methods, there shall be a constructor taking the integer number N of choices to be voted on.

Method Detail

init

public VotingSystem init(java.lang.String[] argv)
Arguments to modify behavior of IRNRP

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()
Do processing if necessary, return winners. It might be a good idea to implement getWinners(java.io.PrintWriter) and implement this to call it with null.

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

getScaledDoubleVote

protected void getScaledDoubleVote(double[] dt,
                                   java.lang.Object o,
                                   double weight,
                                   boolean[] active)

getWinners

public int[] getWinners(int numSeats)
Do processing if necessary, return winners. Default implementation returns null so that not all systems have to be multi-seat systems.

Overrides:
getWinners in class VotingSystem
Parameters:
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.

toString

public java.lang.String toString(java.lang.String[] names)
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!

getDebugText

public java.lang.String getDebugText(java.lang.String[] names)
Description copied from class: VotingSystem
Return textual representation of debug data. Default implementation returns null.

Overrides:
getDebugText in class VotingSystem
Parameters:
names - Symbolic names for the choices makes human debugging easier. May be null.
Returns:
debug text (default=null)
See Also:
VotingSystem.debug

htmlSummary

public java.lang.String htmlSummary(java.lang.String[] names)
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!

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