From 9dd5d6ae745c29ac8d1b1cd7e32b8d6e4d07e155 Mon Sep 17 00:00:00 2001 From: Alec Li Date: Sun, 11 Aug 2024 21:59:20 -0700 Subject: [PATCH] Add randomness to matcher assignment generation --- csm_web/scheduler/views/matcher.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/csm_web/scheduler/views/matcher.py b/csm_web/scheduler/views/matcher.py index 23a786a8..499e0fe0 100644 --- a/csm_web/scheduler/views/matcher.py +++ b/csm_web/scheduler/views/matcher.py @@ -1,4 +1,5 @@ import datetime +import random from django.db import transaction from django.db.models import Q @@ -560,6 +561,13 @@ def run_matcher(course: Course): ) ) + # randomize lists, seeded with the course id; + # this ensures that tiebreaks are approximately uniform + random.seed(course.id) + random.shuffle(mentor_list) + random.shuffle(slot_list) + random.shuffle(preference_list) + # run the matcher return get_matches(mentor_list, slot_list, preference_list)