On page 5 of your textbook, the authors describe an example that has two different stable matchings. One of the matchings has very happy men, and the other has very happy women. Later (pages 10-11), the authors discuss the fact that the Gale-Shapely Algorithm as stated on page 6 always yields the stable matching that makes the collection of men as happy as possible given the preference lists. This "male-optimal" version of the algorithm becomes "female-optimal" if you swap the roles of the men and the women in the algorithm.
Define partner_rankM(P) to be the preference rank that person P gives to his/her partner in matching M. Further, define the total happiness of a matching M to be the sum over all people P of partner_rankM(P). For example, the matching described on the bottom of page 4 and the top of page 5 has a total happiness of 6:
partner_rankM(w) = 1
partner_rankM(m) = 1
partner_rankM(w') = 2
partner_rankM(m') = 2
Your jobs for this exercise are: