A bin packing algorithm is a decision rule that assigns indivisible items to fixed-capacity bins while minimizing the number of bins used and preventing capacity violations.
In the standard one-dimensional model, every item has one positive scalar size, every bin has the same capacity, and an item cannot be divided. The goal is to assign each item exactly once, keep every bin at or below capacity, and use as few bins as possible. A bin packing algorithm may be an exact optimization method or a faster heuristic. First Fit Decreasing, or FFD, is the deterministic heuristic used by the Bin Packing Calculator.

The objective behind the algorithm
The core bin packing problem contains four requirements:
- All bins have one common capacity.
- Every item is assigned whole to exactly one bin.
- No bin’s combined item size exceeds its capacity.
- The number of bins opened is as small as possible.
The objective can be expressed as minimizing the number of bins while preserving those constraints. A simple size-based lower bound is ceil(total item size ÷ capacity). It estimates how many bins are unavoidable from total demand alone, but it does not account for the fact that particular item sizes may not combine neatly into the available space.
| Approach | How it decides | What the result establishes |
|---|---|---|
| First Fit Decreasing | Sorts items by decreasing size and uses the first open bin with enough room. | A deterministic, feasible assignment that is not guaranteed to use the minimum number of bins. |
| Exact optimization model | Searches item-to-bin assignments while enforcing the capacity and assignment constraints. | The minimum bin count when the solver is allowed to finish with an optimality proof. |
How First Fit Decreasing makes its decisions
FFD applies a short sequence of rules rather than testing every possible arrangement:
- It stably sorts the items from largest to smallest. Items of equal size retain their original input order.
- It examines bins in the order they were opened.
- It places the current item in the first open bin with enough remaining capacity.
- If no open bin can hold the item, it opens a new bin.
Here, first means the earliest open bin, not the bin with the smallest remaining space or the highest utilization. This distinction makes the result reproducible and lets you trace why an item reached a particular bin. The same capacity and item list produce the same FFD assignments each time.
FFD is useful when a quick, consistent grouping is more important than a proof of global optimality. Its weakness is that an early placement can leave a combination that would have supported a better overall arrangement.
Create an FFD plan in the calculator
- Open the Bin Packing Calculator and enter the common capacity available in every bin. The interface enforces its own capacity limit.
- List one item on each line. A row can contain only a size, such as 12, or a label followed by one comma and a size, such as Memory block A, 12. Use the same unit for the capacity and every item. The list accepts up to 1,000 items, while labels have a limited length. Rows containing only a number receive automatic labels; commas inside custom labels are outside the simple import format.
- Run FFD and inspect every bin. Check that each item appears once, compare used and remaining capacity, and review both overall utilization and the simple size lower bound before accepting the grouping.
- Copy the plan if it is appropriate for a worksheet, loading draft, memory-allocation example, or operations-research exercise. The calculator assigns positive items no larger than the capacity and reports a clear error for invalid or oversized entries.
Processing stays entirely in the browser, so the capacity and item list do not need to be uploaded. The FFD procedure and the resulting assignments are deterministic.
Interpret the bin count, utilization, and lower bound
The output contains several related figures. Each measures something different, so they should not be treated as interchangeable.
| Output | How to read it | Important qualification |
|---|---|---|
| Bins opened | The number of bins used by the FFD plan. | FFD can use more bins than a globally optimal arrangement. |
| Item assignments | The bin receiving each item. | Every item is assigned whole to exactly one bin. |
| Used and remaining capacity | The scalar capacity consumed and still available in each bin. | Remaining capacity is unused space in the model, not necessarily recoverable physical volume. |
| Overall utilization | Total item size divided by the total capacity of all opened bins. | It is an aggregate measure and does not prove that the assignment is globally best. |
| Size lower bound | Ceil(total item size ÷ capacity). | No solution can use fewer bins, but the bound alone does not prove that the displayed plan is optimal. |
For a single lower-bound calculation, suppose the total item size is 17 and the capacity is 10. The result is ceil(17 ÷ 10) = ceil(1.7) = 2 bins. This rules out a one-bin solution. It does not identify every feasible combination of individual items, which is why the calculator presents the value as a lower bound rather than an optimality certificate.
When FFD opens more bins than the lower bound, the gap may reflect indivisible item combinations, an avoidable local placement, or both. It shows that total size alone does not explain the result, but it does not reveal how many bins an exhaustive search would require.
What the model can and cannot represent
The algorithm works with abstract scalar quantities. These can represent weight, memory, workload, length, or another one-dimensional resource provided that the capacity and all item sizes use the same unit. This makes the model useful for exploring batch groupings, resource assignments, and ordering effects before applying domain-specific rules.
The calculator does not model several important real-world constraints:
- It has no three-dimensional dimensions, orientation, balance, fragility, stacking strength, center of gravity, hazardous separation, or vehicle axle limits.
- It cannot split an item, combine capacities, reserve space, or apply item values and priorities.
- It does not produce a proof of minimum cost or a safe physical loading plan.
For example, an item size of 10 does not describe a box with a length, width, and height. Broad container-loading decisions require specialist software, documented safety rules, and validation of the final assignment. Logistics, cloud capacity, manufacturing, and safety-critical applications should also be checked with an appropriate validated solver rather than relying solely on this one-dimensional heuristic.
Choose FFD or exact optimization
FFD is appropriate for fast, reproducible grouping when a feasible plan and transparent audit trail are enough. If the minimum bin count itself must be established, use an optimization solver that searches alternative assignments. Google OR-Tools’ bin packing documentation describes the item-to-bin constraints and the minimum-bin objective.
Other objectives require different models. If stock can be cut into different required pieces, the task is a cutting-stock problem rather than indivisible-item bin packing; Lehigh University’s analysis of cutting stock problems explains that formulation. Similarly, values, reserved capacity, multiple resource dimensions, and scheduling priorities lead toward knapsack, multiple-knapsack, or scheduling variants that this calculator does not solve.