grouping - Algorithm to group people based on their preference -


i need algorithm group people in tables based on preference. each person vote sorting tables favorite worse. example if there 4 tables in total 1 person vote like:

alice{ table1 => 2, table2 => 4, table3=>1, table4=>3} 

which means put on table3 , dislikes table2

the conditions are:

  • everyone must in group
  • all groups must have same number of people (tollerance of 1)
  • maximize global 'happiness'

trying sort out defined happiness points, each person have happiness 10 if put on favorite table, 6 on second choice, 4 on third , 1 on last.

happiness[10, 6, 4, 1] 

the global happiness sum of each person's happiness.

one way solve use integer linear programming. there many solvers out there ilp, example scip (http://scip.zib.de/).

you have binary variable each assigment, i.e. xij = 1 if person assigned table j (and 0 not assigned).

your goal maximize total happiness, i.e. sum of weights multiplied xij

now have write conditions ensure, that:

  • each person assigned 1 table, i.e. sum of xij each equal one.
  • all tables have similar number of persons (you can determine possible ranges number of persons beforehand), i.e. of xij each j in defined range.

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -