1

Let's say there is a group of 4n people, and each of them rank their top 3 people they would like to be in a smaller, 4-person group with. What would be a good algorithm to create these groups randomly, but with a greater chance of one person being with the first, second, and/or third person on their list?

I.e. a weighted grouping algorithm. (The ones that Google finds are all for networking)

ZuluDeltaNiner
  • 725
  • 2
  • 11
  • 27

1 Answers1

3

This problem is underspecified. An easy approach would Metropolis--Hastings. Define a score function where, e.g., the score of a grouping is one plus three times the number of satisfied first choices plus two times the number of satisfied second choices plus the number of satisfied third choices. Start with completely random groups. Choose two people at random (with replacement, for technical reasons), swap them, and recompute the score. If Math.random() is greater than the new score divided by the old score, then swap them back. This Markov chain Monte Carlo process converges to a score-weighted random grouping.

David Eisenstat
  • 64,237
  • 7
  • 60
  • 120