A framework for modelling and solving stable matching problems