= {
student_preferences "A": ["X1", "X2"],
"B": ["Y2", "X1"],
"C": ["X1", "Y1"],
"D": ["Y2", "Y1"],
}
= {"X": ["C", "A", "B"], "Y": ["C", "D", "B"]}
supervisor_preferences
= {"X1": "X", "X2": "X", "Y1": "Y", "Y2": "Y"}
project_supervisors = {project: 1 for project in project_supervisors}
project_capacities = {
supervisor_capacities 2 for supervisor in supervisor_preferences
supervisor: }
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
= StudentAllocation.create_from_dictionaries(
game
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
= StableRoommates.create_from_dictionary(roommate_preferences) game