I would like to create a tool to split a group of persons into multiple teams "randomly". Here is a mockup that shows the UI: https://ibb.co/jDHFkdH


To generate the teams, the tool takes as input:

  • dataset of persons (firstname, lastname, any other fields as gender, level, year,...)
  • number of team to generate
  • constraints with weight


There are 2 types of constraints:

  • Field constraint: each team will have the same distribution of the field values. Ex: if I have a team with 60% of women and 40% of men, a Field constraint on "Gender" will make the tool trying to have each team with the same ratio
  • Group contraint: use as many persons as needed from the dataset
    • Should be together: the generator will create teams where the persons of this constraint will BE together
    • Should not be together: the generator will create teams where the persons of this constraint will NOT BE together

The constraints are SOFT constraints. The goal is to find solutions even if it does not respect every constraints or try to respect the constraint as much as possible. For example, if I have 60% women and 40% men, a field constraint on gender would try to create teams with this ratio. A 55%/45% ratio could still be OK but this would be a less good solution.

Each constrain has a weight. This is used to order constraints by importance. If I use a scoring function, not respecting a constraint with a big weight will reduce much more the score than not respecting a constraint with a small weight.


The tool gives back the best combinations. If multiple combinations have the same score, one is randomly chosen. The user can ask the tool to give more results.


I have no idea how to start it. I thought first I could use a brute force approach by generating all combinations and give each one a score based on the constraints (and multiplied by the constraint's weight).

I'm not asking for a complete solution but maybe some tips, ideas, terms to search. Maybe I should use math functions, matrices, probability, etc... Or maybe a brute force approach combined to some logic to improve the speed. Thanks

  • $\begingroup$ Please define what counts as the "best" combination. How do the weights on the constraints affect that? Also, are these hard constrains (all must be met exactly) or soft (some violations are OK)? If soft, how do you measure what level of violation is OK? $\endgroup$
    – D.W.
    Jan 14 at 6:48
  • $\begingroup$ @D.W. I edited the post $\endgroup$
    – Edwin ZAP
    Jan 14 at 12:43
  • 1
    $\begingroup$ I think you still have to be more precise. There has to be a measure to compare combinations, usuallyan objective function that maps each combination to real number. $\endgroup$
    – ttnick
    Jan 14 at 12:50
  • $\begingroup$ Please don't append "Edit: more stuff...". Instead, please revise the question to read well for someone who encounters it for the first time. Please see cs.meta.stackexchange.com/q/657/755 for more details. $\endgroup$
    – D.W.
    Jan 14 at 19:05


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.