This repository contains implementations of algorithms for proportional apportionment with divisor methods. Inspect and use at your own risk.
-
File
SandwichSelect.java
contains an implementation of the algorithmSandwichSelect
we have presented inWild, S. and Reitzig, R.
A Practical and Worst-Case Efficient Algorithm for Divisor Methods of Apportionment
submitted
[preprint (v3,2016)]Some variants exist.
-
In
ChengEppsteinSelect.java
we provide an implementation of the algorithm proposed inCheng, Z. and Eppstein, D.
Linear-time Algorithms for Proportional Apportionment
In: International Symposium on Algorithms and Computation (ISAAC) 2014.
Springer (2014)
[preprint (v1,2014)] -
Furthermore, we implement the jump-and-step algorithm from
Pukelsheim, F.
Proportional Representation
Springer, 2014in
PukelsheimPQ.java
with priority queues for determining the next party to modify, and inPukelsheimLS.java
using linear scan. -
Finally, we give implementations of the naive iterative algorithms using priority queues resp. a linear scan for finding maxima in
IterativeDMPQ.java
andIterativeDMLS.java
, respectively.
The core algorithms start in the respective implementations of method unitSize
resp. apportion
.
The remaining files provide interfaces, shared algorithmic parts and utility code. Some files are taken or adapted from Sedgewick/Wayne with our thanks; we re-release their files in agreement with their license statement (see Q + A here).
Execute ant compile
; you will need algs4.jar
(in folder lib
) from the book website of Sedgewick/Wayne.
Run ant test
for testing correctness of the implementations.
Besides rudimentary sanity checks, the test basically check Pukelsheim's
Max-Min Inequality for all computed assignments, i.e. for all ways to resolve ties.
Command ant run
executes a sample runtime experiment.
Run your own experiments by defining the parameters in a space-separated file
(see e.g. arxiv2.experiment; those are the ones from the article)
and passing it as parameter to run_experiments.rb
.
That is,
ruby run_experiments.rb arxiv.experiments
runs the exact experiments used in our article.
In case you can not get this to work, here is a workaround.
-
Open a terminal resp. command line in th repository and execute
ant compile
. -
Create the following folder structure within the code respository:
my_experiment |- data |- plots | |- times | |- counters | |- scatter | |- averages |- tmp
-
Change directory to folder
my_experiment
. -
For each non-comment line from
arxiv.experiment
(or your file), executejava -cp ../build de.unikl.csgak.appportionment.experiments.RunningTimeMain [line]
If you use
LDM(x,y)
as divisor method, enclose this parameter in double-quotes. -
Execute
gnuplot tmp/*.gp
.
Hint: For plotting purposes,
you can use script separate_by_alg
to split the .tab
-files in data
by algorithm.
If you need one file per input size, you can split these file using separate_by_n
.