EDIT: Thanks Alain for a proper description for this:
The problem is this: a shop that tries to find the optimal size of their cardboard boxes, to be able to pack all goods, and trying to minimize wasted space in the boxes.
Currently I have a dataset with volumes. I need to figure out if for example the amount of containers I can use is 5, what are the 5 best sizes to fit all those volumes? For example, this array contains my volume:
var numbers =[10, 20, 20, 30, 50, 50, 50, 80];
And to make it simple, I have 2 containers. Each with the size of 50 and 80.
10 fits in 50, but the waste is 40. 20 fits also in 50, but the waste is 30 and so on. 50 fits in 50, but the waste is 0. Same holds for 80. In total the waste is 120.
But what if the sizes were different? 60 and 80. Then the total waste would be 180.
(60-10) + (60-20) + (60-20) + (60-30) + (60-50) + (60-50) + (60-50) + (80-80)
My question is, what is the most efficient way to determine how big the sizes should be for the containers? Given that you know the amount of how many containers you can use and the numbers(in this case it was volume) in an array.
So for example, what if I didn't knew the sizes of my container should be 50 and 80. How would I have calculated the best correct size if I only know how many containers I can use and what volume each object has?
Is there some kind of algorithm for this, and if so, can you give an example? I tried looking things up like the bin packing, knapsack and k-means but they are not very clear to me how I can apply them to this problem. I just want to calculate which sizes are best suited to store all the volumes with minimal waste.
I hope I was clear with this example, if not please ask more about. Thanks beforehand.