public override List <int> CalculateResults(VotingSituation situation)
        {
            var baseRule = new ProportionalByDistrictVotingRule()
            {
                Apportionment = Apportionment
            };
            var newSituation = new VotingSituation();

            newSituation.PartyCount = situation.PartyCount;
            newSituation.Electorates.AddRange(situation.Electorates);

            int LargeDistrictSize = TotalSeats - situation.Electorates.Count;

            if (LargeDistrictSize > 0)
            {
                var newElectorate = new ElectorateVotes();
                newElectorate.Magnitude  = LargeDistrictSize;
                newElectorate.VoteCounts = new HashMultiset <Int64>();

                foreach (var smallDistrict in situation.Electorates)
                {
                    foreach (var prefOrder in smallDistrict.VoteCounts)
                    {
                        newElectorate.VoteCounts[prefOrder] += smallDistrict.VoteCounts[prefOrder];
                    }
                }

                newSituation.Electorates.Add(newElectorate);
            }

            return(baseRule.CalculateResults(newSituation));
        }
Ejemplo n.º 2
0
        public static VotingSituation FromInfo(IEnumerable <HashMultiset <Int64> > districts, int partyCount, int districtMagnitude)
        {
            var electorates = new List <ElectorateVotes>();

            foreach (var d in districts)
            {
                var ev = new ElectorateVotes();

                ev.Magnitude  = districtMagnitude;
                ev.VoteCounts = d;

                electorates.Add(ev);
            }

            var result = new VotingSituation();

            result.Electorates = electorates;
            result.PartyCount  = partyCount;

            return(result);
        }