Find the optimal way to use combinations of summands to get the most sum with a limited number of summands I have a bit of a problem, I have a set of sums that add up to X, like so:

A: $i + j + k = X$

B: $t + z = X$

C: $z + z = X$

D: $j + j + k + k = X$

I have a limited number of summands so for example I have: 12 of $i$, 35 of $z$, 12 of $j$, and 18 of $k$, 21 of $t$. 

What I need is an algorithm that will determine the best way to use those combinations so that I end up with the most complete sums of $X$

So in the example above using:

17 of combination $C$, 1 of combination $B$, and 12 of combination $A$, total 30 sums of $X$, 72 summands used

is worse then using:

21 of combination $B$, 7 of combination $C$, and 6 of combination $D$, total 34 sums of $X$, 80 summands used

EDIT:

To further explain:

using 21 of combination $B$ will "spend" 21 $t$ and 21 $z$ leaving us with: 12 of $i$, 14 of $z$, 12 of $j$, 18 of $k$, 0 of $t$

using 7 of combination $C$ will "spend" 14 of $z$ (because it uses 2 summands of $z$ to be achieved) leaving us with: 12 of $i$, 0 of $z$, 12 of $j$, 18 of $k$, 0 of $t$

using 6 of combination $D$ will spend 12 of $j$ and 12 of $k$ (because it uses both of them twice) leaving us with: 12 of $i$, 0 of $z$, 0 of $j$, 6 of $k$, 0 of $t$

we can no longer make combinations that will add up to $X$ thus the algorithm is concluded.
The problem is a generalization of the set packing problem (exercise: why?), and therefore it is NP-hard even to approximate in a very weak sense.  See Maximum Set Packing and Maximum Clique in the compendium.