Monday, March 23, 2009
Oops?
Yeah, been a while since the last post. Got caught up in pre-SB tests and SB itself. But school is starting up again today for the home-stretch. Got absolutely no work done over spring break and will spend most of my night in the Taylor basement. My team has not communicated but I'm confident we'll be fine as we'll iron out who does what today in class. More to come after I work on my part of TA1.
Friday, March 6, 2009
Man, busy week. I started and finished SMP yesterday. Funny since my last blogpost a week ago was about starting on that day. Anyway, it's not too bad. I used a dictionary for the women's preferences. One of the form { man number : rank } where man number is the ... number of the man, and rank is obviously his rank.
Thus a woman ranking her men as 5 2 4 3 1 will generate a dictionary of { 5:1, 2:2, 4:3, 3:4, 1:5 }.
Then we compare her current fiances' ranking to a competing free male's ranking (i.e., dict[single_male_number] < dict[competing_fiance_number]) when determining whether her current engagement will end (if single_male.number is less than competing_fiance.number) or not (if dict[single_male_number] is greater than dict[competing_fiance_number]). I used a dictionary for Woman since women must keep track of their preferences and I didn't feel I'd be able to implement this the way I wanted via a stack. However, a man can "pop()" a preference and if she doesn't accept his proposal, she never will, so it works out for Man in a man-optimal implementation.
I created a Woman, Man, and Stack class and have the algorithm run within a loop of the form: while(there_is_an_unmatched_couple()). This works by iterating through a list of Man to see if any Man is single. Any single male implies there is a single female out waiting for him. If so, find him a mate!
Thus a woman ranking her men as 5 2 4 3 1 will generate a dictionary of { 5:1, 2:2, 4:3, 3:4, 1:5 }.
Then we compare her current fiances' ranking to a competing free male's ranking (i.e., dict[single_male_number] < dict[competing_fiance_number]) when determining whether her current engagement will end (if single_male.number is less than competing_fiance.number) or not (if dict[single_male_number] is greater than dict[competing_fiance_number]). I used a dictionary for Woman since women must keep track of their preferences and I didn't feel I'd be able to implement this the way I wanted via a stack. However, a man can "pop()" a preference and if she doesn't accept his proposal, she never will, so it works out for Man in a man-optimal implementation.
I created a Woman, Man, and Stack class and have the algorithm run within a loop of the form: while(there_is_an_unmatched_couple()). This works by iterating through a list of Man to see if any Man is single. Any single male implies there is a single female out waiting for him. If so, find him a mate!
Subscribe to:
Posts (Atom)