Practical and Worst-Case Efficient Apportionment
Raphael Reitzig @ Theorietage 2015
worked with Sebastian Wild
FACHBEREICH
INFORMATIK
FACHBEREICH
INFORMATIK
&Algorithmen
Komplexität
Apportionment
Votes
19777721
12843458
3585178
3180299 →
?
311
193
63
64
Seats
Apportionment
Wishes:
Pairwise Vote
Monotonicity
House
Monotonicity
Quota
Rule
Apportionment
Wishful thinking:
Pairwise Vote
Monotonicity
House
Monotonicity
Quota
Rule
Apportionment
Wishful thinking:
Pairwise Vote
Monotonicity
House
Monotonicity
Quota
Rule
⇐=
Apportionment
Wishful thinking:
Pairwise Vote
Monotonicity
House
Monotonicity
Quota
Rule
⇐=
Divisor Methods
⇐⇒
Divisor Methods
Input
Votes v of n parties for k seats, k n.
Divisor Methods
Input
Votes v of n parties for k seats, k n.
Method
DivisorMethod(v, k) :
1. s ← 0n.
2. For k, . . . , 1:
2.1 I ← arg maxn
i=1 vi /(si + 1).
2.2 sI ← sI + 1.
3. Return s.
Divisor Methods
Input
Votes v of n parties for k seats, k n.
Increasing divisor sequence d = (dj )j∈N0 .
Method
DivisorMethodd (v, k) :
1. s ← 0n.
2. For k, . . . , 1:
2.1 I ← arg maxn
i=1 vi /dsi
.
2.2 sI ← sI + 1.
3. Return s.
Divisor Methods
Input
Votes v of n parties for k seats, k n.
Increasing divisor sequence d = (dj )j∈N0 .
Method
DivisorMethodd (v, k) :
1. s ← 0n.
2. For k, . . . , 1:
2.1 I ← arg maxn
i=1 vi /dsi
.
2.2 sI ← sI + 1.
3. Return s. Θ
(k
logn)
using
priority
queues
Divisor Methods
dj = j + 1, k = 7
j A B C D
0 58 132 40 72
Divisor Methods
dj = j + 1, k = 7
j A B C D
0 58 132 40 72
1 66
Divisor Methods
dj = j + 1, k = 7
j A B C D
0 58 132 40 72
1 66 36
Divisor Methods
dj = j + 1, k = 7
j A B C D
0 58 132 40 72
1 66 36
2 44
Divisor Methods
dj = j + 1, k = 7
j A B C D
0 58 132 40 72
1 66 36
2 44
29
Divisor Methods
dj = j + 1, k = 7
j A B C D
0 58 132 40 72
1 66 36
2 44
29
3 33
Divisor Methods
dj = j + 1, k = 7
j A B C D
0 58 132 40 72
1 66 36
2 44
29
3 33
20
Divisor Methods
dj = j + 1, k = 7
j A B C D
0 58 132 40 72
1 66 36
2 44
29
3 33
20
24
=: a
Divisor Methods
dj = j + 1, k = 7
j A B C D
0 58 132 40 72
1 66 36
2 44
29
3 33
20
24
=: a
A := {132, 72, 66, 58, 44, 40, 36, 33, . . . }
≤ a > a
Reduction to Rank Selection
Observations
Knowing the value a selected last is sufficient.
We select the kth largest value last.
Reduction to Rank Selection
Observations
Knowing the value a selected last is sufficient.
We select the kth smallest value last.
Idea
Use a selection algorithm on multiset
A = ai,j =
dj
vi
i ∈ [1..n], j ∈ N0
and obtain a = A(k) “directly”.
Reduction to Rank Selection
Observations
Knowing the value a selected last is sufficient.
We select the kth smallest value last.
Idea
Use a selection algorithm on a finite subset of multiset
A = ai,j =
dj
vi
i ∈ [1..n], j ∈ N0
and obtain a = A(k) “directly”.
Finding Good Cutoffs
i
j
1 2 3 4 5 6 7 8
0
1
2
3
4
5
...
...
...
...
...
...
...
...
...
A :
Finding Good Cutoffs
i
j
1 2 3 4 5 6 7 8
0
1
2
3
4
5
...
...
...
...
...
...
...
...
...
A :
Finding Good Cutoffs
i
j
1 2 3 4 5 6 7 8
0
1
2
3
4
5
...
...
...
...
...
...
...
...
...
k
A :
Finding Good Cutoffs
i
j
1 2 3 4 5 6 7 8
0
1
2
3
4
5
...
...
...
...
...
...
...
...
...
k
A :
Θ(kn) algorithm.
Finding Good Cutoffs
Given (dj )j≥−1 with [technical details], we assume δ : R≥0 → R≥d0
with [technical details] so that
ai,j =
δ(j)
vi
and
δ−1
(y) = max{j ∈ Z≥−1 | dj ≤ y}
is the (zero-based) rank function of d.
Finding Good Cutoffs
i
j
1 2 3 4 5 6 7 8
0
1
2
3
4
5
...
...
...
...
...
...
...
...
...
A :
Finding Good Cutoffs
i
j
1 2 3 4 5 6 7 8
0
1
2
3
4
5
...
...
...
...
...
...
...
...
...
A :
δ−1(vi a ) = si − 1
Finding Good Cutoffs
i
j
1 2 3 4 5 6 7 8
0
1
2
3
4
5
...
...
...
...
...
...
...
...
...
[
[
[
[
[
]
]
]
]
]
]
]
]
A :
δ−1(vi a ) = si − 1
δ−1(vi a)
δ−1(vi a)
a ≤ a ≤ a
Finding Good Cutoffs
i
j
1 2 3 4 5 6 7 8
0
1
2
3
4
5
...
...
...
...
...
...
...
...
...
ˆA :
δ−1(vi a ) = si − 1
δ−1(vi a)
δ−1(vi a)
a ≤ a ≤ a
Finding Good Cutoffs
i
j
1 2 3 4 5 6 7 8
0
1
2
3
4
5
...
...
...
...
...
...
...
...
...
ˆA :
δ−1(vi a ) = si − 1
δ−1(vi a) =: ji
δ−1(vi a) =: ji
a ≤ a ≤ a
Finding Good Cutoffs
i
j
1 2 3 4 5 6 7 8
0
1
2
3
4
5
...
...
...
...
...
...
...
...
...
ˆA :
δ−1(vi a ) = si − 1
δ−1(vi a) =: ji
δ−1(vi a) =: ji
a = A(k) = ˆA(ˆk) with ˆk = k − i ji
.
Finding Good Cutoffs
i
j
1 2 3 4 5 6 7 8
0
1
2
3
4
5
...
...
...
...
...
...
...
...
...
ˆA :
δ−1(vi a ) = si − 1
δ−1(vi a) =: ji
δ−1(vi a) =: ji
i ji
< k ≤ i ji
Finding Good Cutoffs
i
j
1 2 3 4 5 6 7 8
0
1
2
3
4
5
...
...
...
...
...
...
...
...
...
ˆA :
δ−1(vi a ) = si − 1
δ−1(vi a) =: ji
δ−1(vi a) =: ji
i ji
< k ≤ i ji
Make tight!
Finding Good Cutoffs
In the Article
Observation:
k ≤ rank(a , A) ≤ k + n.
Ansatz:
rank(a, A) < k and k + n ≤ rank(a, A).
Express rank in terms of bounds on δ−1.
Make tight!
Good Bounds On a
If
αx + β ≤ δ(x) ≤ αx + β
with β ≤ α and [technical details], then
a := max 0,
αk − (α − β) · n)
n
i=1 vi
and
a :=
αk + βn
n
i=1 vi
work.
Good Bounds On a
If
αx + β ≤ δ(x) ≤ αx + β
with β ≤ α and [technical details], then
a := max 0,
αk − (α − β) · n)
n
i=1 vi
and
a :=
αk + βn
n
i=1 vi
work.
Furthermore,
| ˆA| ≤ 2(1 + (β − β)/α) · n ∈ Θ(n) .
An Aside: Applicability
Does anybody use d with suitable δ?
An Aside: Applicability
Does anybody use d with suitable δ?
Method Divisor Sequence δ(x) Sandwich
Smallest divisors 0, 1, 2, 3, . . . x —
Greatest divisors 1, 2, 3, 4, . . . x + 1 —
Sainte-Lagu¨e 1, 3, 5, 7, . . . 2x + 1 —
Modified S-L 1.4, 3, 5, 7, . . . 2x+1
1.6x+1.4
x≥1
x<1 2x + 6
5 ± 1
5
Equal Proportions 0,
√
2,
√
6,
√
12, . . . x(x + 1) x + 1
4 ± 1
4
Harmonic Mean 0, 4
3, 12
5 , 24
7 , . . . 2x(x+1)
2x+1 x + 1
4 ± 1
4
Imperiali 2, 3, 4, 5, . . . x + 2 —
Danish 1, 4, 7, 10, . . . 3x + 1 —
Yes, they all do.
The Algorithm
RW15d (v, k) :
1. Compute a and a.
2. Initialize ˆA := ∅ and ˆk := k.
3. For each i ∈ [1..n] do:
3.1 Compute ji
and ji .
3.2 Add all dj/vi to ˆA for which ji
≤ j ≤ ji .
3.3 Update ˆk ← ˆk − ji
.
4. Select and return ˆA(ˆk).
The Algorithm
RW15d (v, k) :
1. Compute a and a.
2. Initialize ˆA := ∅ and ˆk := k.
3. For each i ∈ [1..n] do:
3.1 Compute ji
and ji .
3.2 Add all dj/vi to ˆA for which ji
≤ j ≤ ji .
3.3 Update ˆk ← ˆk − ji
.
4. Select and return ˆA(ˆk).
Θ
(n)
runtim
e!
In Context
Puk CE14 RW15
WC O(n)
In Context
Puk CE14 RW15
WC O(n)   
Implementable
Advantage: Code Complexity
CE14: ≈ 250 loc PukPQ: ≈ 80 loc RW15: ≈ 50 loc DMPQ: ≈ 25 loc
plus library and shared code
In Context
Puk CE14 RW15
WC O(n)   
Implementable   
Simple
Advantage: Runtime Cost
2 4 6 8 10
0
1
2
3
4
n
Averagerunningtimeinµs/n
(α, β) = (2, 1) and k = 100n
0 50 100 150 200
0
0.2
0.4
0.6
n
(α, β) = (1, 3/4) and k = 10n
PukPQ CE14 RW15 DMPQ
In Context
Puk CE14 RW15
WC O(n)   
Implementable   
Simple   
Fast
Details
Literature
Michel L. Balinski und H. Peyton Young. Fair Representation. Meeting the
Ideal of One Man, One Vote. 2nd. Brookings Institution Press, 2001. isbn:
978-0-8157-0111-8
Friedrich Pukelsheim. Proportional Representation. Apportionment Methods
and Their Applications. 1. Aufl. Springer, 2014. isbn: 978-3-319-03855-1. doi:
10.1007/978-3-319-03856-8
Zhanpeng Cheng und David Eppstein. “Linear-time Algorithms for Proportional
Apportionment”. In: International Symposium on Algorithms and Computation
(ISAAC) 2014. Springer, 2014. doi: 10.1007/978-3-319-13075-0_46
Raphael Reitzig und Sebastian Wild. A Practical and Worst-Case Efficient
Algorithm for Divisor Methods of Apportionment. 2015. arXiv: 1504.06475
Code
github.com/reitzig/2015 apportionment

Practical and Worst-Case Efficient Apportionment

  • 1.
    Practical and Worst-CaseEfficient Apportionment Raphael Reitzig @ Theorietage 2015 worked with Sebastian Wild FACHBEREICH INFORMATIK FACHBEREICH INFORMATIK &Algorithmen Komplexität
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
    Divisor Methods Input Votes vof n parties for k seats, k n.
  • 8.
    Divisor Methods Input Votes vof n parties for k seats, k n. Method DivisorMethod(v, k) : 1. s ← 0n. 2. For k, . . . , 1: 2.1 I ← arg maxn i=1 vi /(si + 1). 2.2 sI ← sI + 1. 3. Return s.
  • 9.
    Divisor Methods Input Votes vof n parties for k seats, k n. Increasing divisor sequence d = (dj )j∈N0 . Method DivisorMethodd (v, k) : 1. s ← 0n. 2. For k, . . . , 1: 2.1 I ← arg maxn i=1 vi /dsi . 2.2 sI ← sI + 1. 3. Return s.
  • 10.
    Divisor Methods Input Votes vof n parties for k seats, k n. Increasing divisor sequence d = (dj )j∈N0 . Method DivisorMethodd (v, k) : 1. s ← 0n. 2. For k, . . . , 1: 2.1 I ← arg maxn i=1 vi /dsi . 2.2 sI ← sI + 1. 3. Return s. Θ (k logn) using priority queues
  • 11.
    Divisor Methods dj =j + 1, k = 7 j A B C D 0 58 132 40 72
  • 12.
    Divisor Methods dj =j + 1, k = 7 j A B C D 0 58 132 40 72 1 66
  • 13.
    Divisor Methods dj =j + 1, k = 7 j A B C D 0 58 132 40 72 1 66 36
  • 14.
    Divisor Methods dj =j + 1, k = 7 j A B C D 0 58 132 40 72 1 66 36 2 44
  • 15.
    Divisor Methods dj =j + 1, k = 7 j A B C D 0 58 132 40 72 1 66 36 2 44 29
  • 16.
    Divisor Methods dj =j + 1, k = 7 j A B C D 0 58 132 40 72 1 66 36 2 44 29 3 33
  • 17.
    Divisor Methods dj =j + 1, k = 7 j A B C D 0 58 132 40 72 1 66 36 2 44 29 3 33 20
  • 18.
    Divisor Methods dj =j + 1, k = 7 j A B C D 0 58 132 40 72 1 66 36 2 44 29 3 33 20 24 =: a
  • 19.
    Divisor Methods dj =j + 1, k = 7 j A B C D 0 58 132 40 72 1 66 36 2 44 29 3 33 20 24 =: a A := {132, 72, 66, 58, 44, 40, 36, 33, . . . } ≤ a > a
  • 20.
    Reduction to RankSelection Observations Knowing the value a selected last is sufficient. We select the kth largest value last.
  • 21.
    Reduction to RankSelection Observations Knowing the value a selected last is sufficient. We select the kth smallest value last. Idea Use a selection algorithm on multiset A = ai,j = dj vi i ∈ [1..n], j ∈ N0 and obtain a = A(k) “directly”.
  • 22.
    Reduction to RankSelection Observations Knowing the value a selected last is sufficient. We select the kth smallest value last. Idea Use a selection algorithm on a finite subset of multiset A = ai,j = dj vi i ∈ [1..n], j ∈ N0 and obtain a = A(k) “directly”.
  • 23.
    Finding Good Cutoffs i j 12 3 4 5 6 7 8 0 1 2 3 4 5 ... ... ... ... ... ... ... ... ... A :
  • 24.
    Finding Good Cutoffs i j 12 3 4 5 6 7 8 0 1 2 3 4 5 ... ... ... ... ... ... ... ... ... A :
  • 25.
    Finding Good Cutoffs i j 12 3 4 5 6 7 8 0 1 2 3 4 5 ... ... ... ... ... ... ... ... ... k A :
  • 26.
    Finding Good Cutoffs i j 12 3 4 5 6 7 8 0 1 2 3 4 5 ... ... ... ... ... ... ... ... ... k A : Θ(kn) algorithm.
  • 27.
    Finding Good Cutoffs Given(dj )j≥−1 with [technical details], we assume δ : R≥0 → R≥d0 with [technical details] so that ai,j = δ(j) vi and δ−1 (y) = max{j ∈ Z≥−1 | dj ≤ y} is the (zero-based) rank function of d.
  • 28.
    Finding Good Cutoffs i j 12 3 4 5 6 7 8 0 1 2 3 4 5 ... ... ... ... ... ... ... ... ... A :
  • 29.
    Finding Good Cutoffs i j 12 3 4 5 6 7 8 0 1 2 3 4 5 ... ... ... ... ... ... ... ... ... A : δ−1(vi a ) = si − 1
  • 30.
    Finding Good Cutoffs i j 12 3 4 5 6 7 8 0 1 2 3 4 5 ... ... ... ... ... ... ... ... ... [ [ [ [ [ ] ] ] ] ] ] ] ] A : δ−1(vi a ) = si − 1 δ−1(vi a) δ−1(vi a) a ≤ a ≤ a
  • 31.
    Finding Good Cutoffs i j 12 3 4 5 6 7 8 0 1 2 3 4 5 ... ... ... ... ... ... ... ... ... ˆA : δ−1(vi a ) = si − 1 δ−1(vi a) δ−1(vi a) a ≤ a ≤ a
  • 32.
    Finding Good Cutoffs i j 12 3 4 5 6 7 8 0 1 2 3 4 5 ... ... ... ... ... ... ... ... ... ˆA : δ−1(vi a ) = si − 1 δ−1(vi a) =: ji δ−1(vi a) =: ji a ≤ a ≤ a
  • 33.
    Finding Good Cutoffs i j 12 3 4 5 6 7 8 0 1 2 3 4 5 ... ... ... ... ... ... ... ... ... ˆA : δ−1(vi a ) = si − 1 δ−1(vi a) =: ji δ−1(vi a) =: ji a = A(k) = ˆA(ˆk) with ˆk = k − i ji .
  • 34.
    Finding Good Cutoffs i j 12 3 4 5 6 7 8 0 1 2 3 4 5 ... ... ... ... ... ... ... ... ... ˆA : δ−1(vi a ) = si − 1 δ−1(vi a) =: ji δ−1(vi a) =: ji i ji < k ≤ i ji
  • 35.
    Finding Good Cutoffs i j 12 3 4 5 6 7 8 0 1 2 3 4 5 ... ... ... ... ... ... ... ... ... ˆA : δ−1(vi a ) = si − 1 δ−1(vi a) =: ji δ−1(vi a) =: ji i ji < k ≤ i ji Make tight!
  • 36.
    Finding Good Cutoffs Inthe Article Observation: k ≤ rank(a , A) ≤ k + n. Ansatz: rank(a, A) < k and k + n ≤ rank(a, A). Express rank in terms of bounds on δ−1. Make tight!
  • 37.
    Good Bounds Ona If αx + β ≤ δ(x) ≤ αx + β with β ≤ α and [technical details], then a := max 0, αk − (α − β) · n) n i=1 vi and a := αk + βn n i=1 vi work.
  • 38.
    Good Bounds Ona If αx + β ≤ δ(x) ≤ αx + β with β ≤ α and [technical details], then a := max 0, αk − (α − β) · n) n i=1 vi and a := αk + βn n i=1 vi work. Furthermore, | ˆA| ≤ 2(1 + (β − β)/α) · n ∈ Θ(n) .
  • 39.
    An Aside: Applicability Doesanybody use d with suitable δ?
  • 40.
    An Aside: Applicability Doesanybody use d with suitable δ? Method Divisor Sequence δ(x) Sandwich Smallest divisors 0, 1, 2, 3, . . . x — Greatest divisors 1, 2, 3, 4, . . . x + 1 — Sainte-Lagu¨e 1, 3, 5, 7, . . . 2x + 1 — Modified S-L 1.4, 3, 5, 7, . . . 2x+1 1.6x+1.4 x≥1 x<1 2x + 6 5 ± 1 5 Equal Proportions 0, √ 2, √ 6, √ 12, . . . x(x + 1) x + 1 4 ± 1 4 Harmonic Mean 0, 4 3, 12 5 , 24 7 , . . . 2x(x+1) 2x+1 x + 1 4 ± 1 4 Imperiali 2, 3, 4, 5, . . . x + 2 — Danish 1, 4, 7, 10, . . . 3x + 1 — Yes, they all do.
  • 41.
    The Algorithm RW15d (v,k) : 1. Compute a and a. 2. Initialize ˆA := ∅ and ˆk := k. 3. For each i ∈ [1..n] do: 3.1 Compute ji and ji . 3.2 Add all dj/vi to ˆA for which ji ≤ j ≤ ji . 3.3 Update ˆk ← ˆk − ji . 4. Select and return ˆA(ˆk).
  • 42.
    The Algorithm RW15d (v,k) : 1. Compute a and a. 2. Initialize ˆA := ∅ and ˆk := k. 3. For each i ∈ [1..n] do: 3.1 Compute ji and ji . 3.2 Add all dj/vi to ˆA for which ji ≤ j ≤ ji . 3.3 Update ˆk ← ˆk − ji . 4. Select and return ˆA(ˆk). Θ (n) runtim e!
  • 43.
    In Context Puk CE14RW15 WC O(n)
  • 44.
    In Context Puk CE14RW15 WC O(n) Implementable
  • 45.
    Advantage: Code Complexity CE14:≈ 250 loc PukPQ: ≈ 80 loc RW15: ≈ 50 loc DMPQ: ≈ 25 loc plus library and shared code
  • 46.
    In Context Puk CE14RW15 WC O(n) Implementable Simple
  • 47.
    Advantage: Runtime Cost 24 6 8 10 0 1 2 3 4 n Averagerunningtimeinµs/n (α, β) = (2, 1) and k = 100n 0 50 100 150 200 0 0.2 0.4 0.6 n (α, β) = (1, 3/4) and k = 10n PukPQ CE14 RW15 DMPQ
  • 48.
    In Context Puk CE14RW15 WC O(n) Implementable Simple Fast
  • 49.
    Details Literature Michel L. Balinskiund H. Peyton Young. Fair Representation. Meeting the Ideal of One Man, One Vote. 2nd. Brookings Institution Press, 2001. isbn: 978-0-8157-0111-8 Friedrich Pukelsheim. Proportional Representation. Apportionment Methods and Their Applications. 1. Aufl. Springer, 2014. isbn: 978-3-319-03855-1. doi: 10.1007/978-3-319-03856-8 Zhanpeng Cheng und David Eppstein. “Linear-time Algorithms for Proportional Apportionment”. In: International Symposium on Algorithms and Computation (ISAAC) 2014. Springer, 2014. doi: 10.1007/978-3-319-13075-0_46 Raphael Reitzig und Sebastian Wild. A Practical and Worst-Case Efficient Algorithm for Divisor Methods of Apportionment. 2015. arXiv: 1504.06475 Code github.com/reitzig/2015 apportionment