public static CandidateComparerCollection <T> Concat(CandidateComparerCollection <T> first, CandidateComparerCollection <T> second)
        {
            if (first.CandidateCount != second.CandidateCount)
            {
                throw new ArgumentException("Candidate Counts must be equal.");
            }

            return(new CandidateComparerCollection <T>(first.CandidateCount, CountedList <T> .Concat(first.Comparers, second.Comparers)));
        }
Exemplo n.º 2
0
        protected Func <IEnumerable <int>, double> GetSatisfactionWith(CandidateComparerCollection <Voter> voters)
        {
            var satisfactions = Enumerable.Range(0, voters.CandidateCount)
                                .Select(i => voters.Comparers.Sum(v => v.Utilities[i]))
                                .ToList();
            var randomSatisfaction  = satisfactions.Sum() / (double)voters.CandidateCount;
            var maximumSatisfaction = satisfactions.Max();

            if (randomSatisfaction == maximumSatisfaction)
            {
                return(_ => 1d);
            }

            return((winners) => winners.Average(candidate => (satisfactions[candidate] - randomSatisfaction) / (maximumSatisfaction - randomSatisfaction)));
        }
Exemplo n.º 3
0
 public abstract Dictionary <Strategy, double> CalculateSatisfaction(Random random, CandidateComparerCollection <Voter> voters);
Exemplo n.º 4
0
 public virtual PossibleResultCollection GetPossibleResults(CandidateComparerCollection <Voter> voters) => throw new NotSupportedException();