# Algorithms to find the allocation solution of placing items to bins that maximizes the number of total full bins

I have a problem that could be a variant of "bin packing problem".

1. Input: Given $$N$$ identical items: $$i_1, i_2, ...,i_N$$ with the same weight (or volume). Given $$M$$ bins: $$b_1, b_2, ..., b_M$$ with the same capacity $$K$$. Each bin has already contained a number of items: $$k_1, k_2, ..., k_M$$ in which $$k_i <= K$$. ($$k_i = K$$ means the bin $$i$$ is full).
2. Output: The allocation solution of placing $$N$$ items to $$M$$ bins that maximize the number of full bins. Is there any polynomial algorithm for this problem?

The same question but in the general case that items have different weights (or volumes): $$w_1, w_2, ..., w_N$$. The value $$k_i$$ of the bin $$i$$ is the total weight of the current inside items. And the bin is full when it contains enough items that the total weight above $$95$$% capacity ($$k_i \ge 0.95 K$$).

• Presumably your list should end at $b_M$ rather than $b_N$. Similarly for k. Commented Jun 11, 2021 at 11:23
• Does the 95% definition of full apply to the specific problem, or only to the general one? Commented Jun 11, 2021 at 11:24
• Are the weights to be treated as real numbers, or to some specified precision? Commented Jun 11, 2021 at 11:25
• When you same "number of items", I guess you mean "weight". Commented Jun 11, 2021 at 11:26
• @Blitzer: You are right, I corrected it to bM and kM. The 95% definition is just for a specific problem, we can use another value. The weights are the real number. Commented Jun 12, 2021 at 2:07

For each bin, define $$n_i$$ as the minimum number of items required to fill the bin - ie to get it to 95% full. Note that for some values of $$k_i$$ this may not be possible, so ignore those bins.
We now have a set of $$n_i$$ and we want a subset of them such that we have as many as possible with the total $$=N$$.Obviously we'll prefer smaller $$n_i$$s. Can we just pick the smallest ones until we get to $$N$$? I think we can. Done.