|
|||||||||
| 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.Approval
public class Approval
Election method based on summation of Yes/No "good enough" votes. This class contains utility code for thresholding data at various points.
| Field Summary | |
|---|---|
double |
dthresh
threshold for voteRating(double[]) |
float |
fthresh
threshold for voteRating(float[]) |
int |
ithresh
threshold for voteRating(int[]) |
protected int[] |
talley
|
| Fields inherited from class org.bolson.vote.VotingSystem |
|---|
debug, NO_VOTE, numc |
| Constructor Summary | |
|---|---|
Approval(int numCandidates)
|
|
| Method Summary | |
|---|---|
int[] |
getWinners()
Do processing if necessary, return winners. |
java.lang.String |
htmlSummary(java.lang.String[] names)
A fancy html representation. |
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 |
voteRanking(int[] ranking)
Choices above (ranked less than or equal to) "(numc+1) / 2" are voted as "approved". |
int |
voteRating(double[] rating)
|
int |
voteRating(float[] rating)
|
int |
voteRating(int[] rating)
|
| Methods inherited from class org.bolson.vote.VotingSystem |
|---|
checkRatedVote, getDebugHTML, getDebugText, getNumberOfCandidates, getWinners, getWinners, getWinners, init, 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 |
|---|
public int ithresh
public float fthresh
public double dthresh
protected int[] talley
| Constructor Detail |
|---|
public Approval(int numCandidates)
| Method Detail |
|---|
public java.lang.String name()
VotingSystem
name in class VotingSystempublic int voteRating(int[] rating)
voteRating in class VotingSystemrating - 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 VotingSystemrating - 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 VotingSystemrating - 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 voteRanking(int[] ranking)
voteRanking in class VotingSystemranking - int[numc]
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 toString()
toString in class java.lang.Objectpublic java.lang.String toString(java.lang.String[] names)
VotingSystem
toString in class VotingSystemnames - The names of the choices.
public java.lang.String htmlSummary(java.lang.String[] names)
VotingSystem
htmlSummary in class VotingSystemnames - The names of the choices. May be null.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||