Balanced offline allocation of weighted balls into bins

We propose a sorting-based greedy algorithm called SortedGreedy[m] for approximately solving the offline version of the d-choice weighted balls-into-bins problem where the number of choices for each ball is equal to the number of bins. We assume the ball weights to be non-negative. We compare the performance of the sorting-based algorithm with a naive algorithm called Greedy[m]. We show that by sorting the input data according to the weights we are able to achieve an order of magnitude smaller gap (the weight difference between the heaviest and the lightest bin) for small problems (<= 4000 balls), and at least two orders of magnitude smaller gap for larger problems. In practice, SortedGreedy[m] runs almost as fast as Greedy[m]. This makes sorting-based algorithms favorable for solving offline weighted balls-into-bins problems.