跳到主要内容

Warehouse · beginner · 4 min read

Bin packing fundamentals for FBA shipments

A first-principles primer on the 1D bin-packing problem in the FBA context — what makes Amazon's variant tricky, and how MarginLock's solver handles it.

By Kenderson Tripaldi · April 10, 2026

If you've ever stared at a pile of unpacked SKUs and a stack of cartons and wondered whether the way you're packing them is actually the cheapest way, you've already encountered the bin-packing problem. It's one of the most heavily-studied problems in computer science, and Amazon's FBA program imposes a particularly nasty variant of it. This guide is the first-principles walkthrough — what the problem is, what makes the FBA variant hard, and how MarginLock's solver approaches it.

The classical problem

The classical bin-packing problem is short to state. You have a set of items of various sizes and a set of bins of fixed capacity. You want to pack every item into a bin without exceeding the bin's capacity, using as few bins as possible.

In one dimension — items have a single "size" attribute and bins have a single "capacity" attribute — the problem is NP-hard. There is no known algorithm that solves it optimally in polynomial time. There are, however, several heuristics that get within a few percent of optimal in practice:

  • First-fit: for each item, put it in the first bin that has room. Open a new bin if none does.
  • First-fit decreasing: sort the items largest-first, then run first-fit.
  • Best-fit decreasing: for each item, put it in the bin that will have the least remaining room after the item goes in.

For most practical inputs, first-fit decreasing is within 11% of optimal and runs in O(n log n).

Why FBA makes it harder

The FBA variant is harder than the textbook problem in three ways.

Multiple capacity dimensions

A box has a weight capacity, a cube capacity, and dimensional weight rules. Amazon penalizes you on whichever dimension you violate first. So your bin capacity isn't a single number — it's a vector, and "fitting" means staying under all three constraints simultaneously.

Mixed-SKU constraints

You can't combine arbitrary SKUs. There are mixed-SKU caps, hazmat restrictions, and per-marketplace rules. The solver has to know which items are compatible before it tries to pack them together.

Dimensional-weight thresholds

Amazon's pricing is non-linear. A box that weighs 49.9 lb is priced differently from a 50.1 lb box. The marginal cost of one extra pound near a threshold is enormous. A naïve "fill the box" heuristic that pushes you across the threshold by half a pound is the single most common bin-packing failure we see in the wild.

How MarginLock packs

We use a modified first-fit-decreasing as the base, then layer two extra rules on top.

  1. Sort items by cube, descending

    Largest items go first. This is the classical heuristic, unchanged.

  2. For each item, find candidate bins

    A bin is a candidate if it can accept the item under all three capacity dimensions (weight, cube, dim-weight) and under the mixed-SKU rules.

  3. Score each candidate against threshold proximity

    Among candidates, prefer the one whose post-pack state stays furthest from a dim-weight or weight pricing threshold. This is the rule that eliminates the "49.9 lb that becomes 50.1 lb" failure mode.

  4. Open a new bin if no candidate qualifies

    Only open a new bin when no existing bin satisfies the threshold-proximity score. This minimizes total bins without crossing thresholds.

Worked example

Consider three SKUs going into a single shipment:

SKUWeight (lb)Cube (in³)
A12600
B18900
C221,100

A first-fit-decreasing packer that ignores thresholds would happily put all three into one box at 52 lb. That's a 50-lb overweight violation, and the box will be Amazon-flagged for repacking on intake — which costs you both money and one operational day.

A threshold-aware packer notices that combining all three pushes weight past 50 lb and instead splits into two boxes:

  • Box 1: A + B = 30 lb
  • Box 2: C = 22 lb

Both boxes are well under the threshold and neither will be reboxed.

What about 3D packing?

We don't currently solve true 3D packing — the volumetric arrangement of items inside a carton — and for FBA in particular this isn't a meaningful gap. Amazon doesn't penalize you for sub-optimal arrangement inside a box, as long as the box itself is under the dim-weight threshold. The 1D bin-packing problem on cube and weight is what actually drives your fee outcomes.

If you sell extreme-shape items (long bats, wide canvases) where the bounding box drives dim-weight aggressively, the solver lets you mark those SKUs and will route them to dedicated cartons.

Further reading

For a deeper look at the bin-packing engine itself, including the metric callouts and the threshold-scoring formula: