student_preferences = {
"A": ["X1", "X2"],
"B": ["Y2", "X1"],
"C": ["X1", "Y1"],
"D": ["Y2", "Y1"],
}
supervisor_preferences = {"X": ["C", "A", "B"], "Y": ["C", "D", "B"]}
project_supervisors = {"X1": "X", "X2": "X", "Y1": "Y", "Y2": "Y"}
project_capacities = {project: 1 for project in project_supervisors}
supervisor_capacities = {
supervisor: 2 for supervisor in supervisor_preferences
}Create a game from dictionaries
Every game in Matching can be made using the create_from_dictionaries method (except StableRoommates which uses create_from_dictionary). This is an efficient way of creating more complex games.
Consider the instance of SA described below.
Now the game can be created using the StudentAllocation class.
from matching.games import StudentAllocation
game = StudentAllocation.create_from_dictionaries(
student_preferences,
supervisor_preferences,
project_supervisors,
project_capacities,
supervisor_capacities,
)Creating a StableRoommates instance instead uses the create_from_dictionary method.
Consider the instance of SR described below.
roommate_preferences = {
"A": ["B", "C", "D"],
"B": ["A", "C", "D"],
"C": ["D", "A", "B"],
"D": ["C", "B", "A"],
}Now the game can be created using the StableRoommates class.
from matching.games import StableRoommates
game = StableRoommates.create_from_dictionary(roommate_preferences)