I am wondering if there is an efficient way to partition a set of numbers into subsets that sum to values in a set of target values.
Specifically, let's assume that we are given $k$ distinct values (i.e., no repeats) in one set $S$ and $m$ values in another set $T$ where repeats are possible, where $m < k$. The goal is to find a set of subsets of $S$ that sum to the elements in $T$, where we must use up all of the elements of $T$ and $S$.
I think this is easiest understood with a concrete example:
$k = 6$, $m = 3$, $T = \{37, 44, 55\}$, $S = \{4, 5, 9, 30, 37, 51\}$.
The correct answer should be $\{\{37\}, \{4, 51\}, \{5, 9, 30\} \}$ since $37 \in T$, $4 + 51 = 55 \in T$, and $5 + 9 + 30 = 44 \in T$.
My approach: Go through all integer partitions of $k$ of length $m$. Here, we need to partition 6 into a sum of 3 numbers, of which there are 3 such partitions: $\{1, 1, 4\}, \{2, 2, 2\}$, and $\{1, 2, 3\}$. Then, go through each partition and see if it works given the values in $S$ and $T$. For $\{1, 1, 4\}$, we can see that there is a 37 in both sets, so we have a subset of length 1 that works, but there is no other such subset, so we can't have $\{1, 1, 4\}$. For $\{2,2,2\}$, we can see that $\{4, 51\}$ works since $4 + 51 = 55$, which is in $T$, but there are no other subsets of length 2 that work. That leaves $\{1, 2, 3\}$. We already showed that $\{37\}$ and $\{4, 51\}$ work, so let's just check that the remaining values work: $5 + 9 + 30 = 44$, which is in $T$, so that works. Thus, our final "partitioning" is $\{\{37\}, \{4, 51\}, \{5, 9, 30\}\}$.
This is fine for small values of $k$ and $m$, but using my approach it quickly blows up. Is there a better way to approach this problem?
Helpful addition: it is possible to get more sets $T_1, T_2, ...$ of length $m$ that have different values that the same values in $S$ must sum to, not sure if this is helpful or not.