简体   繁体   中英

Algorithms to Minimize Maximum Weight across Buckets filled with Balls by Making Least Number of Moves

I have K number of buckets. Each bucket contains some number of Balls, B, where each ball has some Weight.

I am wondering if there are algorithms out there that accomplish the following:

I would like to make one move at a time, and relocate some Weight from one bucket to another Bucket in a way that minimizes the maximum weight contained across all buckets. I would like to repeat this process until I have achieved the most balanced configuration of Weights in Buckets by taking the least number of steps.

Are there algorithms out there that would be useful to look at when solving this problem?

Here are approaches I thought of:

  1. Naive: Go through all combinations of balls in buckets, and take the variant that has min(max(weight across all buckets). This is my optimal configuration. Now move one ball at a time until you have achieved this configuration. This would work, but would not be possible to program because we have num_buckets^num_balls complexity which would be inefficient in number of balls were great.

  2. Greedy Tree: Start from scratch and greedily distribute balls across bins in a round-robin fashion. At each iteration - put the ball into a bin that has the smallest maximum. This would not give optimal balance, but it would give a better balance, and then I can take one step a time to achieve this configuration.

This feels like a problem where I have a cost function, and have BxK number of moves at my first step.

Are there known algorithms out there that can inspire a better solution? (Bin packing would not work here because I have a fixed number of bins.) I am not looking for a solution, but rather algorithms that solve balancing problems that look similar to this one, even if not exactly the same.

First, let's restrict the greedy algorithm a bit: place the balls in descending order, heaviest first.

After that, work through the bins from heaviest to lightest. For each bin, look for a swap or move that will reduce its weight without making the move's other bin reach the max weight. Continue this process until the heaviest bin(s) can no longer be improved.

I can't prove whether or not this will give you the optimal solution, but it's going to be pretty good. :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM