|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.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 Form| Field 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 VotingSystemprotected void intoBucket(int[] ranking)
public int voteRanking(int[] ranking)
voteRanking in class VotingSystemranking - 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()
VotingSystemIt 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 VotingSystempublic java.lang.String getDebugText(java.lang.String[] names)
VotingSystem
getDebugText in class VotingSystemnames - 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 VotingSystemout - 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 VotingSystemnames - The names of the choices. May be null.
public java.lang.String toString(java.lang.String[] names)
VotingSystem
toString in class VotingSystemnames - The names of the choices.
public java.lang.String toString()
toString in class java.lang.Objectpublic VotingSystem init(java.lang.String[] argv)
init in class VotingSystemvs = (new VS(numc)).init( new String[]{"blah", "grunt"} );
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||