Dear experts,

for a practical use in a warehouse I'm searching for a way to define this problem in an algorithm:

We need to pick an article with a given amount where .

The article is distributed in several boxes in the warehouse. Each box contains the article in different amounts. So we have a limited amount of boxes with each box containing a quantity where . We want to find the combination of boxes where the sum of the quantity of all selected boxes gets as close as possible to (but doesn't exceed ).

Example for 7 boxes of this article:

if then the ideal combination would be (15+20+18=53).

if the best combination would be (8+20=28).

It looks a little bit like a 0-1 knapsack problem to me but without the maximimizing of a value. Performance would certainly have to be considered. Can you help me to find an algorithm (I guess this problem is NP-hard)?

Regards,

Gunter