org.bolson.vote
Class PairwiseRatingDifferentialSummation
java.lang.Object
org.bolson.vote.VotingSystem
org.bolson.vote.RatedVotingSystem
org.bolson.vote.PairwiseRatingDifferentialSummation
- All Implemented Interfaces:
- java.io.Serializable
public class PairwiseRatingDifferentialSummation
- extends RatedVotingSystem
It's like Condorcet, but based on ratings differentials.
Pairwise Rating Differential Summation
For N choices keep a talley matrix which is N by N.
For each pair of choices in a rated vote:
If choice A is rated higher than choice B, add (A's rating minus B's rating) to the talley entry (A,B)
If choice B is rated higher than choice A, add (B's rating minus A's rating) to the talley entry (B,A)
After all votes have been tallied, if (A,B) is greater than (B,A) then A has 'defeated' B.
Examine all such relations and count up the defeats. The choice or choices with the fewest defeats win.
- See Also:
- Serialized Form
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 |
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 |
talley
protected double[] talley
defeatCount
protected int[] defeatCount
winners
public int[] winners
PairwiseRatingDifferentialSummation
public PairwiseRatingDifferentialSummation(int numCandidates)
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
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()
- Description copied from class:
VotingSystem
- Do processing if necessary, return winners.
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.
- Specified by:
getWinners
in class VotingSystem
- Returns:
- indecies of winners (hopefully 1 of them)
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
toString
public java.lang.String toString(java.lang.String[] names)
- Description copied from class:
VotingSystem
- 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!
htmlSummary
public java.lang.String htmlSummary(java.lang.String[] names)
- Description copied from class:
VotingSystem
- 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!