We have N groups of objects. Objects could be triangles and rectangles (it's just an example to generalize question). Number of triangles and rectangles are not the same. Each group contains $r_{i}$ - rectangles, $t_{i}$ - triangles, so overall $k_{i} = t_{i} + r_{i}$ number of objects.
Problem: I want to divide these groups into three subgroups with ratio (80/10/10 percent of object per group). And at the same time I want, that ratio of triangles and rectangles will be approximately the same in each group (minimize difference between ration among all groups).
My attempts: Obviously, we may compute ratio $c_{i} = \frac{r_{i}}{t_{i}}$ for each group and check all variants, overall $3^{N}$. I wrote algorithm, that slightly better, than exhaustive search. Maybe we should use methods like https://en.m.wikipedia.org/wiki/Branch_and_bound ? (Which is also has complexity about $3^{N}$)