-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsimple_school_choice.py
37 lines (30 loc) · 1.06 KB
/
simple_school_choice.py
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
26
27
28
29
30
31
32
33
34
35
36
37
from deferred_acceptance.deferred_acceptance import deferred_acceptance
from deferred_acceptance.utils import create_dataframes
def simple_school_choice() -> None:
"""
Here is a minimalistic example of deferred acceptance algorithm for school choice.
"""
# Prepare the dataframes
students_list = ["a", "b", "c", "d"]
schools_list = ["A", "B", "C"]
students_preferences = {
"a": [1, 2, 3],
"b": [2, 3, 1],
"c": [3, 2, 1],
"d": [2, 1, 3],
}
schools_preferences = {"A": [1, 2, 3, 4], "B": [1, 3, 2, 4], "C": [2, 3, 4, 1]}
students_df, schools_df = create_dataframes(
students_list=students_list,
students_preferences=students_preferences,
schools_list=schools_list,
schools_preferences=schools_preferences,
)
# Run the algorithm
schools_quota = {"A": 1, "B": 2, "C": 1}
matches = deferred_acceptance(
students_df=students_df, schools_df=schools_df, schools_quota=schools_quota
)
print(matches)
if __name__ == "__main__":
simple_school_choice()