daffidwilde / matching

A package for solving matching games
https://daffidwilde.github.io/matching/
MIT License
149 stars 42 forks source link

[Bug] HR algorithm tries to remove non-existing element #165

Closed dfukagaw28 closed 11 months ago

dfukagaw28 commented 11 months ago

Steps to Reproduce

from matching.games import HospitalResident
num_residents, num_hospitals = 3, 2
resident_prefs = {0: [0], 1: [1], 2: [0]}
hospital_prefs = {0: [2, 1, 0], 1: [1, 2, 0]}
capacities = {0: 1, 1: 1}
game = HospitalResident.create_from_dictionaries(
    resident_prefs, hospital_prefs, capacities
)
game.solve()

Current Behavior

throws ValueError: list.remove(x): x not in list at: https://github.com/daffidwilde/matching/blob/1.4.2/src/matching/algorithms/hospital_resident.py#L97

Expected Behavior

does not try to remove successor when it does not exist in the list free_residents.