/stable-marriage

Various algorithms that solve the stable marriage problem. Implemented in Java.

Primary LanguageJavaMIT LicenseMIT

Details

Implementation of algorithms that solve the stable marriage problem and the binary affiliate matching problem. (https://en.wikipedia.org/wiki/Stable_marriage_problem)

Code has been adapted from the ntzia stable-marriage repo (https://github.com/ntzia/stable-marriage), used in "Equitable Stable Matchings in Quadratic Time" (https://papers.nips.cc/paper/8337-equitable-stable-matchings-in-quadratic-time).

Binary affiliate matching problem algorithms:

  • ILP: a standard integer linear program to solve BAM
  • PriorityMatch: an implementation of our proposed PriorityMatch algorithm (specifically, the SmartPriorityMatch implementation)

Stable marriage algorithms implemented from the literature:

Stable Marriage algorithms from previous work:

Usage

Clone from github

Install your gurobi.jar file with maven in the repo directory:

mvn install:install-file -Dfile=path/to/gurobi/jar/from/repository/gurobi.jar -DgroupId=gurobi -DartifactId=gurobi-jar -Dversion=7.5.1 -Dpackaging=jar

Run:

mvn package

To reproduce the small-scale PriorityMatch vs ILP experiments:

cd scripts/
bash create_binary_data.sh 
cd Experiment_Binary/
bash run.sh
python3 plot.py

To reproduce the large-scale PriorityMatch experiments (varying n):

cd scripts/
bash create_binary_n_data.sh
cd Experiment_Binary_n/
bash run.sh
python3 plot.py

To reproduce the quota-varying PriorityMatch experiments:

cd scripts/
bash create_binary_cap_data.sh
cd Experiment_Binary_Cap/
bash run.sh
python3 plot.py

To reproduce the affiliates-per-employer-varying PriorityMatch experiments:

cd scripts/
bash create_binary_aff_data.sh
cd Experiment_Binary_Aff/
bash run.sh
python3 plot.py

To reproduce the threshold-varying PriorityMatch experiments:

cd scripts/
bash create_binary_thresh_data.sh
cd Experiment_Binary_Thresh/
bash run.sh
python3 plot.py

Note: creating data cleans out all old data from all previous experiments. However, experiment results are kept until that specific experiment is run again.

Dependencies

You need maven and gurobi to build the project:

  • Maven: sudo apt-get install maven
  • Gurobi: https://www.gurobi.com/ (either use a free trial or get an academic license)

For the plotting scripts you need:

  • pip install numpy
  • pip install pandas
  • pip install seaborn
  • sudo apt-get install python-tk
  • sudo apt-get install texlive-full

Tested on Ubuntu 18.04.