Skip to main content
CalcChef

Bin Packing Optimizer

Pack item sizes into bins of one capacity with First Fit, Best Fit, First Fit Decreasing or Best Fit Decreasing and compare the count with the lower bound. How it works

Use the Bin Packing Optimizer

These are heuristics: they pack quickly and usually well, but they do not promise the fewest possible bins. The lower bound shown with the result shows how close the result is.

Item Sizes

Separate sizes with commas, semicolons, spaces or new lines. This replaces the rows below.

#1
#2
#3
#4
#5
Bins used
2
Utilization 90.0% · Items 5
Available
10 bins
Unused capacity
2
Total size
18

Lower bound: 2 bins (total size 18 divided by capacity 10, rounded up). This packing uses 2, so it is the fewest possible.

Exact minimum

Tries packings one after another, with pruning, to find the fewest bins any packing can use. It stops after about 3 million steps and then says it could not prove the answer.

Packing Scheme

Bin 1
73

Remaining: 0 / 10

100% full
Bin 2
521

Remaining: 2 / 10

80% full

About the Bin Packing Optimizer

Items 3, 5, 2, 7 and 1 fit into 2 bins of capacity 10 with First Fit Decreasing: 7 + 3 and 5 + 2 + 1. The Bin Packing Optimizer also gives the lower bound, the total size divided by the capacity and rounded up (18 ÷ 10 gives 2): no packing can use fewer bins, so a result that reaches it is the fewest possible. For up to 25 items, Find the exact minimum searches for the proven fewest.

The four algorithms on items 2, 5, 4, 7, 1, 3 and 8, capacity 10

AlgorithmBins usedPackingUtilization
First Fit (FF)42 + 5 + 1; 4 + 3; 7; 875.0%
Best Fit (BF)42 + 5 + 1; 4; 7 + 3; 875.0%
First Fit Decreasing (FFD)38 + 2; 7 + 3; 5 + 4 + 1100.0%
Best Fit Decreasing (BFD)38 + 2; 7 + 3; 5 + 4 + 1100.0%

The sizes total 30, so the lower bound is 3 bins: FFD and BFD reach it, FF and BF do not.

Frequently asked questions

What is the difference between First Fit and Best Fit?
First Fit puts each item into the first bin that has room; Best Fit puts it into the bin where it leaves the least room. Both take the items in the order typed. The Decreasing versions sort the items from largest to smallest first: items 2, 5, 4, 7, 1, 3 and 8 need 4 bins of 10 with FF or BF and 3 with FFD or BFD.
Does First Fit Decreasing always find the fewest bins?
No. Bin packing is NP-hard and FFD is a heuristic. It never uses more than 11/9 of the optimum plus 6/9 of a bin (Dósa, 2007), and First Fit never more than 1.7 times the optimum, rounded down (Dósa and Sgall, 2013). When the result equals the lower bound the tool says it is the fewest possible; otherwise the fewest lies between the bound and the result. For 25 items or fewer, Find the exact minimum proves it: items 5, 6, 2, 2, 2 and 3 in bins of 10 take 3 bins with FFD (6 + 3, 5 + 2 + 2, 2), and the search finds 2 (6 + 2 + 2 and 5 + 3 + 2).
Can I use decimal sizes?
Yes, up to 9 decimal places. Sizes are added as exact decimals, so 0.1 and 0.2 fill a bin of 0.3 exactly, where floating-point arithmetic gives 0.30000000000000004 and would open a second bin.
Can I paste a list of sizes?
Yes. Paste them into Paste list, separated by commas, semicolons, spaces or new lines, and press Use pasted sizes: 3, 5, 2; 7 1 loads five sizes. The list replaces the rows, keeps the first 1,000 sizes, and says how many entries were not numbers and were left out.
How is bin utilization calculated?
Total size ÷ (bins used × capacity), rounded down to 0.1%: the starting 18 in 2 bins of 10 is 90.0%. Each bin's fill is rounded down to a whole percent, so 999.6 in a bin of 1000 reads 99% full and 99.9% utilization, never 100%.
What if I do not have enough bins?
The packing is still shown, with a note saying how many more bins it needs or that a larger capacity would do. The starting items with 1 bin available need 1 more bin.

Related Tools

View all tools