What is the proper problem name / algorithm for this problem description in computer science theory?
The problem is that I have X items of varying weighted values that must go into Y containers. The containers are of differing sizes (e.g. hold differing maximum weights). The total load of each container must be approximately equivalent to the others, but the containers don't need to be full or minimized. All of the containers must be used.
This reminds me of the "knapsack" problem, but I have multiple knapsacks of differing sizes and the loads between them all must be relatively equivalent (e.g. one knapsack may only hold 12 pounds, and another knapsack may only hold 8 pounds, but they both need to be fill开发者_运维知识库ed with the same percentage of total weight they can carry). It also reminds me of the "bin packing" problem, but that doesn't deal with the varying bin sizes or that the bins don't need to be full or minimized, they just need equivalent loads and all of them need to be used.
Can anyone please point me in the right direction as to the name of this problem within data structures and algorithm theory? I'd also be interested in any algorithms or heuristics that may be commonly used to solve a problem like this or info about the possible time complexity.
Sounds like multiple-knapsack to me. From Wikipedia:
If we have n items and m knapsacks with capacities Wi, we get the multiple knapsack problem
EDIT: Sorry, missed the bit about each container needing to be similarly loaded. Still, it smells like multiple-knapsack, albeit with an extra constraint.
If you map X to pictures of varying heights; and map Y to columns, then the solution given here should work for you too. It is a worst-fit bin packing solution with pre-sorting and additional item swapping coded in Python with examples.
精彩评论