-
-
Notifications
You must be signed in to change notification settings - Fork 359
WIP: Further improved stable marriage in python #726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Further improved stable marriage in python #726
Conversation
b977f2e
to
0401a67
Compare
partner = possible_partner | ||
break | ||
else: | ||
raise Exception(f"Couldn't find a partner for {person}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite sure if this should be an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nor if else
is the right construct here, it's quite obscure
We determined that this algorithm doesn't show as clearly as previous implementations, how marriages are formed. Add to that the fact that it might not work, I don't think this PR should ever be merged, and I might close it soon. |
The first time I ran the algorithm, I got this output:
Problem is: C prefers a over d, and a prefers C over B. |
This is from the Gale-Shapely WIkipedia page Stability here means that there are no free men left. This is because engaged men do not propose and a change of partners only takes place if there is a free man who proposes to a woman and the woman likes him over her current partner. |
No, that's not what stability means. It means that you can't find a pair like C - a where they prefer each other over their partner. It is right that in the GS algorithm, the fact that there is no free man left means that the algorithm must stop, and thus that (as a consequence of the construction of the pairing) the pairing is stable. It doesn't mean that "all men have a partner" implies that "the pairing is stable". |
In Discord we discussed the original implementation of gale shapley, and the improvement @Amaras made (#687 ). This is just a draft which improves it further, making it more similar to the rust implementation. It's very different to the original one so you'll just have to say what you think about it.