Gale-Shapley algorithm game algorithm

Source: Internet
Author: User

It's really a good algorithm and it's very easy to use. I 've come out early and won the Nobel Prize recently.

The pseudocode is as follows:

 

[Java]
Algorithm pseudocode
// GS Algorithm marriage pairing
Function stableMatching {
// Initialize all m and w
Initialize all m, M and w, W to free
// If a free man does not ask all women for marriage
While? Free man m who still has a woman w to propose {
// W value is assigned to the woman with the highest score currently.
W = m's highest ranked such woman to whom he has not yet proposed
If w is free
(M, w) become engaged
Else some pair (m', w) already exists
If w prefers m to m'
(M, w) become engaged
// The following implicit operation is to move the man's proposal list to the next one.
M'becomes free
Else
(M', w) remain engaged
}
}


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.