A problem arose to solve the problem with a solution that became impracticable. Well, I have a set of 12 elements that represent quantities: $$\Omega = \{16, 132, 135, 135, 136, 138, 138, 139, 301, 334, 355, 361\}$$ I can join elements, get subsets, of this set such that the sum of the elements does not exceed 533, for example, the sum of the first 4 elements of the set is equal to 418, so I have a subset $S$ that does not accept any more elements.
The problem is basically to find the $\Omega$ partition that has the least number of elements possible and variance is minimal.
As an illustration, consider the two possible partitions,
$$S_1 = \{ \{16, 132, 135, 135\}, \{136, 138, 138\}, \{139, 301\}, \{334\}, \{355\}, \{361\}\}$$
$$S_2 = \{ \{16, 138, 138, 139\}, \{135, 135, 136\}, \{132, 361\}, \{301\}, \{334\}, \{355\}\}$$
The associated totals, sum of the elements of the subsets, to each element for the two partitions are respectively
$$T_1 = \{418, 412, 440, 334, 355, 361\}$$ $$T_2 = \{431, 406, 493, 301, 334, 355\}$$
Which has as variances $\sigma^2_{T_1} = 4952,267$ and $\sigma^2_{T_2} = 1780,667$.
Therefore, partition $S_2$ is preferable.
I know that my partition has to have only 6 elements and when using my approach, generate all partitions and search for the optimal partition, it was computationally infeasible.
I wonder if there is a better approach, any text on something like that, any tips?
Sorry for the informality and abuse of notation, thank you in advance!
In what follows, I'm interpreting "variance" to mean "population variance" rather than "sample variance", a minor distinction. Rob used sample variance; the population variance of his solution is 1048.89.
The optimal partition seems to be $$\lbrace\lbrace 16, 138, 138, 139\rbrace, \lbrace 136, 301\rbrace, \lbrace 135, 334 \rbrace, \lbrace 135, 355 \rbrace, \lbrace 132, 361\rbrace\rbrace$$with group sums $$\lbrace 431, 437, 469, 490, 493\rbrace$$and (population) variance 672. Ordinarily I would hesitate to say "optimal" since you have multiple criteria (smallest number of subsets, minimum variance), but in this case the minimum feasible number of subsets is five and the smallest possible variance is 672, so this wins on both criteria.
You mentioned "I know that my partition has to have only 6 elements". Is this a constraint? If so, Rob's solution is optimal.
The solution was obtained using a quadratic programming model that minimizes variance for a fixed number of sets in the partition, solving the model for 1, 2, ..., 12 partition sets. This took about 2 seconds total using CPLEX 12.10 (Java API).
I was slightly surprised to note that the minimum variance increased monotonically with the number of sets in the partition.