|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.bolson.vote.VotingSystem org.bolson.vote.RankedVotingSystem org.bolson.vote.IRV
public class IRV
Implements the Instant Runoff Voting, also known as Single Transferrable Vote. There's wide debate about the flaws and virtues of this system.
Condorcet
,
IRNR
,
Serialized FormField Summary | |
---|---|
protected java.util.Vector |
votes
|
protected java.util.Vector[] |
winnerBuckets
|
Fields inherited from class org.bolson.vote.VotingSystem |
---|
debug, NO_VOTE, numc |
Constructor Summary | |
---|---|
IRV(int numCandidates)
|
Method Summary | |
---|---|
java.lang.String |
getDebugText(java.lang.String[] names)
Return textual representation of debug data. |
int[] |
getWinners()
Do processing if necessary, return winners. |
int[] |
getWinners(java.io.PrintWriter out,
int numSeats)
Multi-seat IRV, aka STV. |
java.lang.String |
htmlSummary(java.lang.String[] names)
A fancy html representation. |
VotingSystem |
init(java.lang.String[] argv)
Set what happens when a vote has a duplicate rating (among active choices) -split|-dup|-dq |
protected void |
intoBucket(int[] ranking)
|
protected void |
myInit()
|
java.lang.String |
name()
Return name of this voting system. |
void |
resetBuckets()
|
java.lang.String |
toString()
|
java.lang.String |
toString(java.lang.String[] names)
A more interesting representation. |
int |
voteRanking(int[] ranking)
|
Methods inherited from class org.bolson.vote.RankedVotingSystem |
---|
voteRating, voteRating, voteRating |
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, wait, wait, wait |
Field Detail |
---|
protected java.util.Vector votes
protected java.util.Vector[] winnerBuckets
Constructor Detail |
---|
public IRV(int numCandidates)
Method Detail |
---|
protected void myInit()
public java.lang.String name()
VotingSystem
name
in class VotingSystem
protected void intoBucket(int[] ranking)
public int voteRanking(int[] ranking)
voteRanking
in class VotingSystem
ranking
- An array int[N].
ranking[i] is the ranking of choice i.
rankings are 1 (most preferred) through N (least).
INT_MAX, N, or NO_VOTE for unspecified.
public void resetBuckets()
public int[] getWinners()
VotingSystem
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.
getWinners
in class VotingSystem
public java.lang.String getDebugText(java.lang.String[] names)
VotingSystem
getDebugText
in class VotingSystem
names
- Symbolic names for the choices makes human debugging easier. May be null.
VotingSystem.debug
public int[] getWinners(java.io.PrintWriter out, int numSeats)
getWinners
in class VotingSystem
out
- where to print news and diagnosticsnumSeats
- the number of seats available.
VotingSystem.getWinners(int)
,
VotingSystem.debug
,
VotingSystem.getDebugText(String[])
,
VotingSystem.getDebugHTML(String[])
public java.lang.String htmlSummary(java.lang.String[] names)
VotingSystem
htmlSummary
in class VotingSystem
names
- The names of the choices. May be null.
public java.lang.String toString(java.lang.String[] names)
VotingSystem
toString
in class VotingSystem
names
- The names of the choices.
public java.lang.String toString()
toString
in class java.lang.Object
public VotingSystem init(java.lang.String[] argv)
init
in class VotingSystem
vs = (new VS(numc)).init( new String[]{"blah", "grunt"} );
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |