-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgale_shapley.cpp
25 lines (21 loc) · 1.11 KB
/
gale_shapley.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "gs.hpp"
#include <iostream>
#include <vector>
#include <utility>
#include <optional>
#include <tuple>
#include <algorithm>
// 2 sides (men and women in the original paper, where the gale_objects side sends proporals)
std::vector<std::string> gale_objects = {"a", "b", "c"};
std::vector<std::string> shapley_objects = {"f", "d", "e"};
// complete and non-repeating list of preferences for each object
std::vector<std::vector<std::string>> gale_pref = {{"e", "d", "f"}, {"f", "d", "e"}, {"f", "d", "e"}};
std::vector<std::vector<std::string>> shapley_pref = {{"a", "b", "c"}, {"a", "b", "c"}, {"a", "b", "c"}};
// the algorithm will check if 2 objects have same length and run stable matching until all gale (proposing sides) have a match
// this should satifsy stable matching because gales will always propose (1) to their first prefrences and (2) until they have a match
void main()
{
GaleShapley gshap(gale_objects, shapley_objects, gale_pref, shapley_pref); // todo: validate for non-duplicate preferences
std::vector<std::pair<std::string, std::string>> pairs = gshap.run();
gshap.print_matches(pairs);
}