Last active
August 29, 2015 14:21
-
-
Save kac-/4b5e55b003420c36203d to your computer and use it in GitHub Desktop.
JOW z przekazywaniem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Map<String, Integer> result = new HashMap<String, Integer>(); | |
while (constituencies.size() > 0) { | |
Iterator<List<Candidate>> ci = constituencies.iterator(); | |
while (ci.hasNext()) { | |
List<Candidate> l = ci.next(); | |
Collections.sort(l); | |
Candidate candidate = l.get(0); | |
if (candidate.acceptor != null && !candidate.acceptor.out) { | |
candidate.acceptor.votes += candidate.votes; | |
} else if (candidate.reserve != null && !candidate.reserve.out) { | |
candidate.reserve.votes += candidate.votes; | |
} | |
candidate.out = true; | |
l.remove(candidate); | |
if (l.size() == 1) { | |
Candidate win = l.get(0); | |
Integer v = result.get(win.party); | |
v = v == null ? 1 : v + 1; | |
result.put(win.party, v); | |
ci.remove(); | |
} | |
} | |
} |
Można dodać współczynnik tłumienia tj. np. tylko 3/4 głosów odpadającego przechodzi do Akceptora. Przy takich parametrach ok. 70 reprezentantów dostałoby się z lokalnego drugiego miejsca a 30 z trzeciego, pojedynczy( <10) kandydaci dostaliby się z lokalnych miejsc czwartych i piątych.
Przykładowy wynik:
partia | miejsca | udział |
---|---|---|
Con | 296 | 45,54% |
Lab | 231 | 35,54% |
SNP | 50 | 7,69% |
UKIP | 34 | 5,23% |
LD | 17 | 2,62% |
DUP | 5 | 0,77% |
SF | 5 | 0,77% |
PC | 4 | 0,62% |
SDLP | 3 | 0,46% |
UUP | 3 | 0,46% |
Green | 2 | 0,31% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Efekt 3 uruchomień( losowi Akceptorzy i Rezerwowi pośród partii oraz kolejność „odpytywania” okręgów).