Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/reitzig/2015_apportionment
Implementations of several algorithms for proportional apportionment by divisor methods
https://github.com/reitzig/2015_apportionment
algorithm apportionment divisor-methods java research
Last synced: 19 days ago
JSON representation
Implementations of several algorithms for proportional apportionment by divisor methods
- Host: GitHub
- URL: https://github.com/reitzig/2015_apportionment
- Owner: reitzig
- License: gpl-3.0
- Created: 2015-04-21T17:07:46.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2022-10-20T09:18:11.000Z (over 2 years ago)
- Last Synced: 2024-11-23T14:18:52.152Z (3 months ago)
- Topics: algorithm, apportionment, divisor-methods, java, research
- Language: Java
- Homepage:
- Size: 157 KB
- Stars: 0
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Algorithms for Divisor Methods of Apportionment
This repository contains implementations of algorithms for proportional
apportionment with divisor methods. Inspect and use at your own risk.* File
[`SandwichSelect.java`](https://github.com/reitzig/2015_apportionment/blob/master/src/de/unikl/cs/agak/appportionment/algorithms/SandwichSelect.java)
contains an implementation of the algorithm `SandwichSelect` we have presented in> Wild, S. and Reitzig, R.
> A Practical and Worst-Case Efficient Algorithm for Divisor Methods of Apportionment
> submitted
> [[preprint](http://arxiv.org/abs/1504.06475) (v3,2016)]
Some variants exist.* In
[`ChengEppsteinSelect.java`](https://github.com/reitzig/2015_apportionment/blob/master/src/de/unikl/cs/agak/appportionment/algorithms/ChengEppsteinSelect.java)
we provide an implementation of the algorithm proposed in> Cheng, Z. and Eppstein, D.
> [Linear-time Algorithms for Proportional Apportionment](http://link.springer.com/chapter/10.1007/978-3-319-13075-0_46)
> In: International Symposium on Algorithms and Computation (ISAAC) 2014.
> Springer (2014)
> [[preprint](http://arxiv.org/abs/1409.2603) (v1,2014)]* Furthermore, we implement the jump-and-step algorithm from
> Pukelsheim, F.
> Proportional Representation
> Springer, 2014in
[`PukelsheimPQ.java`](https://github.com/reitzig/2015_apportionment/blob/master/src/de/unikl/cs/agak/appportionment/algorithms/PukelsheimPQ.java)
with priority queues for determining the next party to modify, and in
[`PukelsheimLS.java`](https://github.com/reitzig/2015_apportionment/blob/master/src/de/unikl/cs/agak/appportionment/algorithms/PukelsheimLS.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`](https://github.com/reitzig/2015_apportionment/blob/master/src/de/unikl/cs/agak/appportionment/algorithms/IterativeDMPQ.java)
and
[`IterativeDMLS.java`](https://github.com/reitzig/2015_apportionment/blob/master/src/de/unikl/cs/agak/appportionment/algorithms/IterativeDMLS.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](http://algs4.cs.princeton.edu)
with our thanks; we re-release their files in agreement with their
license statement (see Q + A [here](http://algs4.cs.princeton.edu/code/)).### Compilation
Execute `ant compile`; you will need [`algs4.jar`](https://algs4.cs.princeton.edu/code/algs4.jar)
(in folder `lib`) from the [book website of Sedgewick/Wayne](http://algs4.cs.princeton.edu/code/).### Usage
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](https://github.com/reitzig/2015_apportionment/blob/master/arxiv2.experiment); those are the ones from the article)
and passing it as parameter to [`run_experiments.rb`](https://github.com/reitzig/2015_apportionment/blob/master/run_experiments.rb).
That is,ruby run_experiments.rb arxiv.experiments
runs the exact experiments used in [our article](http://arxiv.org/abs/1504.06475).In case you can not get this to work, here is a workaround.
1. Open a terminal resp. command line in th repository and
execute `ant compile`.2. Create the following folder structure within the code respository:
my_experiment
|- data
|- plots
| |- times
| |- counters
| |- scatter
| |- averages
|- tmp
3. Change directory to folder `my_experiment`.
4. For each non-comment line from `arxiv.experiment` (or your file), execute
java -cp ../build de.unikl.csgak.appportionment.experiments.RunningTimeMain [line]
If you use `LDM(x,y)` as divisor method, enclose this parameter in double-quotes.
5. 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`.