I am very happy to announce that, as of next academic year, I will be joining the faculty of the Department of Economics and Finance at Utah State University as a Visiting Assistant Professor.
Patrick Prosser has some great java code at http://www.dcs.gla.ac.uk/~pat/roommates/distribution/ which, among other things, can compute all the stable matchings in roommate problems.
If you are interested in two-sided matchings, rejoice : Patrick’s code allows preferences over roommates to include unacceptable roommates. To implement a two-sided market, just make sure any roommates on one side of the market views any other roommate on the same side of the market as unacceptable, and you’re good to go.
If (like myself) you are not used to java, you might struggle a little to get the code working. Here is a little tutorial for Mac OS, which worked for me as of today.
- Make sure you have java installed and that java can be executed from the terminal (get help from google if you have troubles with this point).
- Download the code at http://www.dcs.gla.ac.uk/~pat/roommates/distribution/code20160401/
- Download the code at http://www.dcs.gla.ac.uk/~pat/roommates/distribution/choco/
- Open your terminal and add the path to choco to your classpath by running
export CLASSPATH=$CLASSPATH:/(path to choco folder)/choco-solver-2.1.5.jar
- where (path to choco folder) should be the place where you put the choco folder you downloaded from http://www.dcs.gla.ac.uk/~pat/roommates/distribution/choco/, e.g. /Users/Me/Desktop/choco/ if that’s where you put it.
- Travel to the directory where you put the code you downloaded at http://www.dcs.gla.ac.uk/~pat/roommates/distribution/code20160401/ by running
cd /(path to code20160401 folder)/code20160401
- again, make sure you have the right path, e.g. /Users/Me/Desktop/code20160401 if that’s where you put it.
- Compile the java classes from the .java files in the directory by running
- Have fun and run any example you like (follow the readme at http://www.dcs.gla.ac.uk/~pat/roommates/distribution/ for a description of what the code can do). For instance, you can grab one of the examples at http://www.dcs.gla.ac.uk/~pat/roommates/distribution/data/, say sr6.txt, put it in (path to code20160401 folder)/code20160401 and run
java SR sr6.txt
- to get a stable matching in example sr6.txt, or
java SR sr6.txt all
- to obtain all stable matchings in profile sr6.txt.