Filling a parcel, a pallet, or a truck as tightly as possible is the 3D bin-packing problem, and it is NP-hard: the number of ways to arrange boxes explodes with item count, so there is no fast method that is always optimal. The practical question for an operations team is therefore not “what is the best algorithm” but “when is a fast, good-enough heuristic the right call, and when is it worth reaching for an exact solver.”
Why it is hard
Each item can be placed at many positions and (if rotation is allowed) several orientations, and every placement changes what fits next. Add real constraints, weight limits, stacking rules, this-side-up, load stability, and the search space becomes astronomically large. Exact optimisation is only tractable for small instances.
Heuristics: fast and usually good enough
Heuristics build a solution greedily by a sensible rule, in milliseconds:
- First-Fit Decreasing (FFD): sort items largest-first, place each in the first bin it fits. Simple and surprisingly strong.
- Extreme-point / maximal-space methods: track the open corners where a new box can go and pick the best fit. The workhorse for parcel cartonisation.
- Layer-based: build flat layers, natural for palletising where stability matters.
For a warehouse cartonising thousands of orders an hour, a good heuristic that returns in milliseconds and gets within a few percent of optimal is almost always the right answer. Warehouse throughput usually matters more than squeezing out the last percent of fill.
When CP-SAT (or another exact solver) is worth it
A constraint solver like CP-SAT models the problem exactly and can prove optimality, but it needs time and the instance has to be small enough.
# illustrative decision sketch
if items_per_container <= ~15 and decisions_per_hour is low:
use CP-SAT # optimality is reachable and the gain is worth the runtime
elif throughput is high or instances are large:
use a heuristic # milliseconds, within a few % of optimal
else:
heuristic to seed, optionally refine the few high-value loads with CP-SAT
CP-SAT earns its keep on small, high-value, infrequent decisions: a complex high-value pallet configuration, a container load you plan once and ship thousands of times, or a master-carton spec. On the high-volume parcel line, its runtime is a non-starter.
The honest rule
Match the method to the decision’s frequency and value. High-volume, low-stakes per decision (parcels): heuristic. Low-volume, high-stakes (a recurring container or pallet pattern): exact solver, or a heuristic seed that the solver refines. Reaching for CP-SAT on every parcel is how a packing optimiser becomes the bottleneck it was meant to remove. The goal, as with all inventory operations, is the best result you can compute in the time the operation actually allows.
Implementing this at your scale?
The walkthrough above comes from production work. AvanSaber’s inventory practice has implemented variations of this pattern across multiple customer engagements.
If you are building this and want expert review of your design, or would rather have the team that built this build yours, book a discovery conversation or describe your situation at [email protected].