The algorithm finds the stable matching for two parties with a set of preferences. The purpose of this project is to provide illustrative learning experience.
The Stable Matching algorithm used in this project is called the Gale-Shapley algorithm, which is a simple but powerful algorithm to find stable matches for two parties, each with a set of preferences. It was first introduced by D. Gale and L.S. Shapley in the article "College Admissions and the Stability of Marriage" published in 1962 in "The American Mathematical Monthly" (see http://www.jstor.org/stable/2312726). This algorithm and the theory behind it are so invaluable and interesting that it led Lloyd S. Shapley together with Alvin E. Roth to win the Nobel Prize in Economics in 2012 "for the theory of stable allocations and the practice of market design" (see http://www.nobelprize.org/nobel_prizes/economics/laureates/2012/).
S = a set of stable matching, M = group of males, W = group of females
S ⟸ { }
Initially all m ∈ M and w ∈ W have no partners
While ∃ m who is unmatched and has not proposed to every w
w ⟸ first w on m's list to propose
If w = unmatched
Add m-w pair to S
Else if w prefers m to her current parnter m'
Delete m'-w pair from S
Add m-w pair to S
Else
w rejects m
End While
Return S
Follow the instructions here to install mono:
http://www.mono-project.com/docs/getting-started/install/linux/
Do not forget to install also these other packages:
sudo apt install mono-mcs
sudo apt install mono-devel
Compile:
mcs stableMatcher.cs utils.cs examples.cs
Run:
mono stableMatcher.exe
- Start Visual Studio.
- Go to the menu option "Datei->Neu->Projekt aus vorhandenem Code".
- Choose "Visual C#" and click "Weiter".
- You should see a dialog box "Wo sind die Daten?" Browse to the directory where you have clone the Git repository of the project and click on "Ordner auswählen".
- Give a name to your visual studio program.
- You should see a dialog box with the option "Ausgabetyp". Choose "Konsolenanwendung".
- Click in "Fertigstellen".
- Navigate to the file Program.cs generated by visual Studio and comment out the Main function and the program should now run.
Please just commit/push only those files that are needed to run the program in all platforms, i.e. please do not add/commit project files auto-generated by visual studio, for example: Program.cs and files with extensions .suo, .user, .sln, etc.