|
|
@ -18,9 +18,25 @@ import java.util.Comparator;
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* https://en.wikipedia.org/wiki/Majority_judgment
|
|
|
|
* https://en.wikipedia.org/wiki/Majority_judgment
|
|
|
|
* https://fr.wikipedia.org/wiki/Jugement_majoritaire
|
|
|
|
* https://fr.wikipedia.org/wiki/Jugement_majoritaire
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* Should this class be `final`?
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
final public class MajorityJudgmentDeliberator implements DeliberatorInterface {
|
|
|
|
final public class MajorityJudgmentDeliberator implements DeliberatorInterface {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected boolean favorContestation = true;
|
|
|
|
|
|
|
|
protected boolean numerizeScore = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MajorityJudgmentDeliberator() {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MajorityJudgmentDeliberator(boolean favorContestation) {
|
|
|
|
|
|
|
|
this.favorContestation = favorContestation;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MajorityJudgmentDeliberator(boolean favorContestation, boolean numerizeScore) {
|
|
|
|
|
|
|
|
this.favorContestation = favorContestation;
|
|
|
|
|
|
|
|
this.numerizeScore = numerizeScore;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ResultInterface deliberate(TallyInterface tally) {
|
|
|
|
public ResultInterface deliberate(TallyInterface tally) {
|
|
|
|
ProposalTallyInterface[] tallies = tally.getProposalsTallies();
|
|
|
|
ProposalTallyInterface[] tallies = tally.getProposalsTallies();
|
|
|
@ -34,8 +50,7 @@ final public class MajorityJudgmentDeliberator implements DeliberatorInterface {
|
|
|
|
for (int proposalIndex = 0; proposalIndex < amountOfProposals; proposalIndex++) {
|
|
|
|
for (int proposalIndex = 0; proposalIndex < amountOfProposals; proposalIndex++) {
|
|
|
|
ProposalTallyInterface proposalTally = tallies[proposalIndex];
|
|
|
|
ProposalTallyInterface proposalTally = tallies[proposalIndex];
|
|
|
|
String score = computeScore(proposalTally, amountOfJudges);
|
|
|
|
String score = computeScore(proposalTally, amountOfJudges);
|
|
|
|
ProposalTallyAnalysis analysis = new ProposalTallyAnalysis();
|
|
|
|
ProposalTallyAnalysis analysis = new ProposalTallyAnalysis(proposalTally, this.favorContestation);
|
|
|
|
analysis.reanalyze(proposalTally);
|
|
|
|
|
|
|
|
ProposalResult proposalResult = new ProposalResult();
|
|
|
|
ProposalResult proposalResult = new ProposalResult();
|
|
|
|
proposalResult.setScore(score);
|
|
|
|
proposalResult.setScore(score);
|
|
|
|
proposalResult.setAnalysis(analysis);
|
|
|
|
proposalResult.setAnalysis(analysis);
|
|
|
@ -73,7 +88,7 @@ final public class MajorityJudgmentDeliberator implements DeliberatorInterface {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected String computeScore(ProposalTallyInterface tally, BigInteger amountOfJudges) {
|
|
|
|
protected String computeScore(ProposalTallyInterface tally, BigInteger amountOfJudges) {
|
|
|
|
return computeScore(tally, amountOfJudges, true, false);
|
|
|
|
return computeScore(tally, amountOfJudges, this.favorContestation, this.numerizeScore);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|