1

Lets says I have a list of men and women. Each man(x) rates each woman, and each woman(y) rates each man, on a scale 0-9.

e.g.

x1: {y1: 0, y2: 5, y3: 9}

x2: {y1: 1, y2: 0, y3: 9}

x3: {y1: 5, y2: 5, y3: 8}

y1: {x1: 3, x2: 3, x3: 5}

y2: {x1: 8, x2: 2, x3: 2}

y3: {x1: 9, x2: 5, x3: 9}

I'm looking for an algorimthm that pairs all x & y as to maximise the total ratings.

In this case the optimal pairings would be x2:y3 = 9+9 = 18, x1:y2 = 5+8 = 13, x3:y1 = 5+9 = 14. for a total rating of 45. At least I think it is by eye.

I think its a simplified version of the maximum independent set problem, that isn't an NP-hard optimization problem.

1 Answers1

1

This problem is known as the stable marriage problem and the Nobel Prize in Economics was awarded for the solution. Algorithm is described in some detail on wikipedia:

http://en.wikipedia.org/wiki/Stable_marriage_problem

Pseudo-code cut/pasted from wikipedia:

function stableMatching {
    Initialize all m ∈ M and w ∈ W to free
    while ∃ free man m who still has a woman w to propose to {
       w = m's highest ranked 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
           m' becomes free
         else
           (m', w) remain engaged
    }
}
Asaph
  • 159,146
  • 25
  • 197
  • 199
  • That code results in x1:y3 = 9+9 = 18, x2:y1 = 1 + 3 = 4, & x3:y2 = 5+2 = 7. Which has a total rating of 29, a far worse result than the solution I eyeballed. – Kieron George Dec 07 '14 at 18:56
  • Your implicit assumption is that the numbers you're assigning and summing are meaningful. I would challenge that assumption. Does it matter that X1 rated y3 a 9, y2 a 5, and y1 a 0? I assert that it does not. It matters only that y3 is his first choice, y2 his second and y3 his 3rd. The specific ratings are meaningless. If you're going to measure something measure the average choice # received by each participant. 1.0 is optimal. The higher the average, the less optimal the solution. – Asaph Dec 08 '14 at 03:08