Thank you both for the reply. Knowing the exact scientific name makes it a lot easier to find more information on this. So thanks for putting me in the right direction. I am sure I will be able to find a way that I
can implement on my tool.
You might also want to search for references to the "knapsack problem," which is closely related. It is one of the canonical NP-complete problems, meaning that there currently exists no know algorithm that will find the optimal solution in polynomial time (like N^2 or N^3). Thus, most solutions are approximations that give you "good enough" answers in relatively fast time, or solutions that take a lot of time to try *all* (or a substantial subset) of solutions, to get the optional solution.
-- Americans might object: there is no way we would sacrifice our living standards for the benefit of people in the rest of the world. Nevertheless, whether we get there willingly or not, we shall soon have lower consumption rates, because our present rates are unsustainable.