|
|||||||||
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.RatedVotingSystem org.bolson.vote.Condorcet
public class Condorcet
Implements the Condorcet method of ranked voting tabulation and beatpath tie resolution. See electionmethods.org. Several variations are contained in this based on options submitted to init().
CondorcetRTB
,
Serialized FormField Summary | |
---|---|
protected int[] |
talley
|
Fields inherited from class org.bolson.vote.VotingSystem |
---|
debug, NO_VOTE, numc |
Constructor Summary | |
---|---|
Condorcet(int numCandidates)
|
Method Summary | |
---|---|
static void |
countDefeats(int numc,
int[] tally,
int[] defeatCount)
|
java.lang.String |
getDebugText(java.lang.String[] names)
Return textual representation of debug data. |
int[] |
getSchwartzSet()
return the set of choices that are only beaten by each other. |
int[] |
getSchwartzSet(int[] defeatCount)
return the set of choices that are only beaten by each other. |
static int[] |
getSchwartzSet(int numc,
int[] tally,
int[] defeatCount)
|
static int[] |
getSchwartzSet(int numc,
int[] tally,
int[] defeatCount,
java.lang.StringBuffer debugsb)
|
int[] |
getWinners()
Do processing if necessary, return winners. |
int[] |
getWinnersCSSD()
|
int[] |
getWinnersOldBPM()
|
int[] |
getWinnersSchwartzEqOne()
|
int[] |
getWinnersSimpleIfOne()
|
java.lang.String |
htmlSummary(java.lang.String[] names)
A fancy html representation. |
static java.lang.StringBuffer |
htmlTable(java.lang.StringBuffer sb,
int numc,
int[] arr,
java.lang.String title,
java.lang.String[] names)
|
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. |
boolean |
verifySchwartzSet(int[] ss)
Verify set to have Schwartz Set properties. |
static boolean |
verifySchwartzSet(int numc,
int[] tally,
int[] ss)
|
static boolean |
verifySchwartzSet(int numc,
int[] tally,
int[] ss,
java.lang.StringBuffer debugsb)
|
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, 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 int[] talley
Constructor Detail |
---|
public Condorcet(int numCandidates)
Method Detail |
---|
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 VotingSystem init(java.lang.String[] argv)
VotingSystem
init
in class VotingSystem
argv
- -minpref|-avgpref|-margins|-wv|-both
-minpref "no vote" indicates minimal preference
-avgpref "no vote" assigned average preference not otherwise assigned
-margins tie breakers consider marginal votes (A_Over_B - B_Over_A)
-wv tie breakers consider winning votes (A_Over_B)
-both add to both on tie (otherwise add to neither on tie). can change outcome with -wv "winning votes".
public java.lang.String name()
VotingSystem
name
in class VotingSystem
public int voteRating(int[] rating)
voteRating
in class RatedVotingSystem
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.
public int voteRating(float[] rating)
voteRating
in class VotingSystem
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.
public int voteRating(double[] rating)
voteRating
in class RatedVotingSystem
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.
public int[] getSchwartzSet()
public int[] getSchwartzSet(int[] defeatCount)
defeatCount
- must be int[numc]
by the reference property of java arrays, the defeatCount will be returned in this property.
public static void countDefeats(int numc, int[] tally, int[] defeatCount)
public static int[] getSchwartzSet(int numc, int[] tally, int[] defeatCount)
public static int[] getSchwartzSet(int numc, int[] tally, int[] defeatCount, java.lang.StringBuffer debugsb)
public boolean verifySchwartzSet(int[] ss)
ss
- a candidate Schwartz Set
public static boolean verifySchwartzSet(int numc, int[] tally, int[] ss)
public static boolean verifySchwartzSet(int numc, int[] tally, int[] ss, java.lang.StringBuffer debugsb)
public int[] getWinnersSchwartzEqOne()
public int[] getWinnersSimpleIfOne()
public int[] getWinnersOldBPM()
public int[] getWinnersCSSD()
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 toString()
toString
in class java.lang.Object
public java.lang.String toString(java.lang.String[] names)
VotingSystem
toString
in class VotingSystem
names
- The names of the choices.
public static java.lang.StringBuffer htmlTable(java.lang.StringBuffer sb, int numc, int[] arr, java.lang.String title, java.lang.String[] names)
public java.lang.String htmlSummary(java.lang.String[] names)
VotingSystem
htmlSummary
in class VotingSystem
names
- The names of the choices. May be null.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |