Next-fit-decreasing
Next-fit-decreasing (NFD) is an algorithm for bin packing. Its input is a list of items of different sizes. Its output is a packing - a partition of the items into bins of fixed capacity, such that the sum of sizes of items in each bin is at most the capacity. Ideally, we would like to use as few bins as possible, but minimizing the number of bins is an NP-hard problem. The NFD algorithm uses the following heuristic:
- Order the items from largest to smallest.
- Initialize an empty bin and call it the "open bin".
- For each item in order, check if it can fit into the open bin:
- If it fits, then place the new item into it.
- Otherwise, close the current bin, open a new bin, and put the current item inside it.
In short: NFD orders the items by descending size, and then calls next-fit bin packing.