1

This is a problem that involves matching students with various skills into groups so that there are as many groups as possible while ensuring that each group has certain skills present. I've reduced it to this:

  1. Given a set of $N$ people with $S$ skills where $A_{n,s}$ is the quantity of skill $s$ that person $n$ has.
  2. Group the $N$ people into as many groups as possible, such that there are no more than $G$ people in any group, and so that the sum of each skill in each group is at least $B_s$.

Constraints: $N, S, G < 100$ and $A_{n,s}, B_s < 10$

I haven't been able to come up with a better solution that a brute force so far. Would be very keep for some pointers as to what I should be searching for to find an algorithm for this class of problem.

D.W.
  • 159,275
  • 20
  • 227
  • 470
thomasfedb
  • 113
  • 4
  • This problem reads very much like 3-dimensional matching would be a special case: https://en.wikipedia.org/wiki/3-dimensional_matching If so, then your problem is NP-hard and you won't have any luck finding an algorithm that's substantially better than brute-force. – Sebastian Oberhoff Apr 03 '18 at 04:08
  • What's the context where you encountered this? Can you credit the source? Do you know how to use ILP? – D.W. Apr 03 '18 at 15:06
  • @D.W. Encountered in a real life context involving rostering volunteer ambulance officers onto ambulance crews. I'm not familiar with any ILP implementations. – thomasfedb Apr 03 '18 at 16:08
  • Unfortunately this is NP-hard even in the very restricted case where there is just 1 skill, and we are trying to decide if we can form 2 groups or only 1. (There is a simple reduction from the Partition Problem -- trying to partition a set of integers into two parts with the same sum.) – j_random_hacker Apr 04 '18 at 10:01
  • @j_random_hacker I'm interested in how you reduced it to a problem that involves finding groups with equal sums. The problem only requires that the sum of skills is above a cutoff. – thomasfedb Apr 05 '18 at 06:50
  • @thomasfedb: The reduction is from Partition -- that is, given an instance of Partition, we can build an instance of (the decision version of) your problem whose YES/NO answer is also the correct answer to the original Partition instance. Here it is: Given an instance of Partition consisting of the numbers $x_1, \dots, x_n$ with sum $t$, make an instance of your problem with $N=n$ people, $S=1$ skills, and $A_{i,1} = x_i$ for all $1 \le i \le n$. Finally set $B_1 = t/2$. The only way to get 2 groups from this instance is if they both have exactly $t/2$ total skill. – j_random_hacker Apr 05 '18 at 08:59
  • @thomasfedb: By "the decision version of your problem", I mean a version of it in which instead of asking for the highest number of groups that can be formed, we include one more parameter $k$ in the problem description, and ask whether at least $k$ groups can be formed. In the previous reduction, we would set $k=2$. – j_random_hacker Apr 05 '18 at 09:01
  • You're welcome :) With NP-hardness established, D.W.'s suggestion of using an ILP solver is apt. – j_random_hacker Apr 06 '18 at 08:41

1 Answers1

3

I suggest expressing this as an instance of integer linear programming (ILP). Express boolean logic operations in zero-one integer linear programming (ILP) might be useful to you in figuring out how to do that.

In particular, introduce zero-or-one variables $x_{n,j}$, which is one if person $n$ is placed into group $j$, or zero otherwise. You can now express each of your requirements as a linear inequality, and then use an ILP solver to test for feasibility. Now do binary search (or simple iterative search) over the number of groups, to find the maximum number of groups for which you can find a feasible solution.

D.W.
  • 159,275
  • 20
  • 227
  • 470