Logistics

A Minimalist 3D Bin Packing Algorithm & Universal CSP Solver

Charles Dana & Claude — April 2026

Original manuscript: ORIJ-D-23-00102, Operational Research, March 2023

Repo: logistics.aws.monce.ai

Abstract

This article introduces Logistics: a minimalist 3D bin packing algorithm that clusters items within a container while minimizing empty space. The algorithm uses package superposition to simulate the presence of a single box at multiple places, reducing the number of operations needed to fill the container. The algorithm can be viewed as a Markov chain on the space of multiple partial solutions, enabling it to explore the solution space efficiently.

We show that the same framework — superposition + conflict-oriented random walk — generalizes to any constraint satisfaction problem: Graph Coloring, SAT, Sudoku, N-Queens, and in principle any NP-complete problem reducible to CSP.

1. The Framework

The core insight is that many combinatorial optimization problems share the same structure:

  1. Variables — things you're assigning (items, vertices, boolean vars, cells, rows)
  2. Domains (Φ sets) — candidate values per variable (positions, colors, {T,F}, digits, columns)
  3. Conflict predicate — any polynomial-time checkable pairwise constraint (overlap, adjacency, clause violation, duplicate-in-group, diagonal attack)

The solver operates on Xt = Π Φ(i): the Cartesian product of all domains. Each state is a complete assignment. The Markov chain walks this space by:

  1. Detecting a conflict (a, b) via the conflict-oriented heuristic
  2. Re-assigning one of the conflicting variables to a new value from its domain
  3. Accepting improvements, tolerating lateral moves, and using SA for worse moves

2. Definitions (from the 2023 paper)

Definition 1: Orthogonal 3DBPP

Given {(ai, bi, ci, i) : i ≤ n} rectangular shapes and a container (A, B, C), find an anchor function A : (ai, bi, ci, i) ↦ (xi, yi, zi) ∈ [0,A] × [0,B] × [0,C] such that no two items overlap.

Definition 2: Package Superposition (Φ)

Φ : i ↦ {(xi,t, yi,t, zi,t) : t ≤ mi} maps each item to a set of candidate placements. The algorithm explores the Cartesian product X0 = Π Φ(i), narrowing to a consistent assignment.

In the implementation, Φ is generated using an item-dimension-aligned grid: candidate positions at multiples of all item dimensions present in the problem. This produces a compact but complete set of structurally meaningful positions.

Definition 3: Fast Collision Detection

Two placements collide iff they overlap on all three axes (separating axis theorem):

1xi-xj ∈ ]-ai, aj[ · 1yi-yj ∈ ]-bi, bj[ · 1zi-zj ∈ ]-ci, cj[ = 1

Computed in O(1) per pair, O(n2) for all pairs.

Definition 4: Clustering

Identical items are grouped and placed as block arrangements (nx × ny × nz grids). This reduces the effective problem size for homogeneous item sets.

Definition 5: Bounded Random Walk

The state Xt evolves via: at each step, pick a conflicting pair, re-assign one variable. The process is a random walk on [0, n ln(M)] with step size ln(1 ± 1/M), where M = max |Φ(i)|.

Proposition 1 (Convergence)

Under the assumption that fast collision detection contradicts Xt in O(na) time, the process converges with probability approaching 1 when N ≥ M2 n ln M steps. The probabilistic upper bound: O(na+1 M2 ln M).

3. The Generalization

The 3DBPP-specific definitions map directly to a general CSP:

3DBPP conceptCSP conceptWhat changes
Item iVariable iName only
Φ(i) positionsDomain(i) valuesDomain semantics
Collision detectionConflict predicateConstraint check
Container boundsUnary constraintsDomain pruning
ClusteringSymmetry breakingOptional preprocessing

The solver code is identical. Only the variable/domain/conflict definitions change:

ProblemVariablesΦ (domain)Conflict
3D Bin Packingitemspositions × orientationsoverlap
Graph Coloringvertices{0, ..., k-1}adjacent & same color
SATboolean vars{True, False}unsatisfied clause
Sudokucells{1, ..., 9}duplicate in row/col/box
N-Queensrows{0, ..., n-1} columnssame col or diagonal

4. Implementation Optimizations

4.1 Greedy Initialization

Instead of random X0, we place variables in decreasing order of constraint difficulty (largest item / smallest domain first). For each, we sample up to 20 candidates and pick the one with fewest conflicts. This often solves easy instances in 0 Markov chain iterations.

4.2 Incremental Conflict Tracking

Instead of O(n2) full conflict scan per iteration, we maintain per-variable conflict counts and update only the affected neighborhood when a variable changes: O(degree) per iteration.

4.3 Arc Consistency (AC-3)

For Sudoku and similar tightly-constrained CSPs, we run AC-3 preprocessing to prune domains before the Markov chain. This alone solves easy Sudoku instances (the domain collapses to singleton sets via propagation).

4.4 Domain-Specific Solvers

N-Queens uses a specialized min-conflicts solver with O(1) conflict counting via column/diagonal counters. This enables solving 1000-Queens in ~230ms.

5. Experimental Results

5.1 3D Bin Packing

n itemsContainerFill ratioSolvedIterationsTime (ms)
87368.2%YES3,49027
5012342.7%YES012
10015342.7%YES650
20019344.9%YES16229
30022344.7%YES13505
50027340.4%YES31,507

Perfect tilings solved: 8 cubes in 43, 27 cubes in 93, 64 cubes in 123. Solution validity verified: all items in bounds, zero collisions, valid orientations. 50/50 random instances solved and verified.

5.2 Graph Coloring

GraphColorsSolvedIterationsTime (ms)
Petersen (10v, 15e)3 (chromatic)YES1<1
K5 (complete)5 (chromatic)YES0<1
K54 (impossible)NO100K2,800
G(50, 0.1) random5YES0<1

5.3 SAT

InstanceSolvedIterationsTime (ms)
3 vars, 3 clausesYES0<1
Random 3-SAT (20v, 70c, ratio 3.5)YES0<1
Random 3-SAT (50v, 150c, ratio 3.0)YES01

5.4 Sudoku

DifficultySolvedIterationsTime (ms)Method
Easy (30+ clues)YES0<1AC-3 alone
Hard (17 clues)NO500K6,000Needs backtracking

Honest limitation: the Markov chain excels at resolving local conflicts but cannot perform the global constraint propagation that hard Sudoku puzzles require. This is exactly the gap between local search and DPLL/CDCL.

5.5 N-Queens

nSolvedIterationsTime (ms)
8YES15<1
50YES1523
100YES1154
200YES21216
500YES34670
1,000YES553229

6. Complexity

Bin Packing: Greedy init O(n · |Φ| · n), Markov chain O(iterations · n) per step. With item-aligned grid, |Φ| is polynomial in container size.

CSP (general): Greedy init O(n · |D| · deg), Markov chain O(iterations · deg) per step with incremental tracking. AC-3 preprocessing: O(e · d2) where e = edges, d = max domain.

N-Queens: O(n) per iteration with column/diagonal counters. Empirically near-linear total iterations in n.

7. Connection to AUMA

The Logistics framework shares DNA with AUMA (Dana, 2023):

Both encode the problem as "pick one value per variable from a finite domain" and walk the space. The Φ function in Logistics plays the same role as the clause set W in AUMA. The conflict predicate is the analogue of clause evaluation.

The lineage: AUMA (2023) → Dana Theorem (2024) → Snake (SAT classifier) → Logistics (CSP solver). Each step narrows the gap between "everything is MAXSAT" and "how much of combinatorial optimization is tractable with the right framework."

8. What Logistics Does NOT Claim

The contribution is the framework: one algorithm structure that works across multiple NP-complete problems by changing only the domain and conflict definitions. The experiments show where it excels (bin packing, graph coloring, N-Queens) and where it struggles (hard Sudoku, very tight 100% tilings).

API Reference

EndpointMethodDescription
/packPOST3D Bin Packing: items + container → placements
/colorPOSTGraph Coloring: adjacency + k colors → assignment
/satPOSTSAT: clauses + n_vars → truth assignment
/sudokuPOSTSudoku: grid (0=empty) → solution
/nqueensPOSTN-Queens: n → row-to-column assignment
/healthGETHealth check
/paperGETThis page
/docsGETOpenAPI interactive documentation

References

  1. Dana, C. (2023). A O(2n/2) Universal Maximization Algorithm. MSc thesis, Ecole Polytechnique.
  2. Levin, D.A., Peres, Y., Wilmer, E.L. (2009). Markov Chains and Mixing Times. AMS.
  3. Lovász, L. (1993). Random Walks on Graphs: A Survey. Paul Erdos is Eighty, Vol. 2.
  4. Hopper, E. & Turton, B. (2001). A survey of results and recent work on the 3D bin packing problem. JORS, 52(1).
  5. Vázquez-Rodríguez, J.A. et al. (2013). A hybrid heuristic for the 3D bin packing problem. C&OR, 40(12).
  6. Martello, S. & Toth, P. (1990). Knapsack Problems. Wiley.

Back to Logistics