data-structures-algorithms-group4 / student-project-matching

1 stars 0 forks source link

Algorithm: fails "test_s_lose_reeval" because student added twice to unassigned queue after "losing" reevaluation #20

Closed lonnychen closed 6 months ago

lonnychen commented 6 months ago

Test file: test_algorithm.py Test case: test_s_lose_reeval

Failing message: AssertionError: PREFERRED PROJECT AVAILABILITY for s4 in p2

Failing mechanism: When a new student goes into reevaluate_assignments but does not "win" an assignment because of higher priority students being current assignees, the main code adds that student twice to the unassigned queue which can cause problems later as the while loop makes two attempts to match that student. In this test case, the student later gets matched with a non-best-priority project causing the failure.

Relevant code: matching_algorithm.py (failing mechanism when both appends happen)

if student not in matches:  # If student is not matched
      unassigned_students.append(student)
  if displaced:  # Requeue displaced students
      for d_student in displaced:
          unassigned_students.append(d_student)

test_s_lose_reeval.log snippet (bolding added for emphasis): INFO:matching_algorithm:Process student s4 INFO:matching_algorithm:Check project p1 with availability 0 INFO:reevaluate_assignments:Reevaluating p1 with potential addition of s4 DEBUG:reevaluate_assignments:current_assignees: ['s1', 's2', 's3'] DEBUG:reevaluate_assignments:kept_assignees: ['s1', 's2', 's3'] DEBUG:reevaluate_assignments:displaced_students: ['s4'] INFO:reevaluate_assignments:Updated project assignments for p1: ['s1', 's2', 's3'] INFO:matching_algorithm:Updated project assignments: defaultdict(<class 'list'>, {'p1': ['s1', 's2', 's3']}) DEBUG:matching_algorithm:Updated unassigned students: deque(['s5', 's6', 's7', 's8', 's9', 's4', 's4'])

lonnychen commented 6 months ago

Great! Looks fixed now.

Logfile attached: test_s_lose_reeval.log