π§© Constraint Solving POTD:Bin Packing β 2026-03-30 #23548
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Constraint Solving β Problem of the Day. A newer discussion is available at Discussion #23705. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Category: Packing & Cutting Β· Date: 2026-03-30
Problem Statement
You have a collection of items, each with a known size, and an unlimited supply of identical bins, each with a fixed capacity. The goal is to pack all items into the fewest bins possible.
Formal specification
nitems, itemihas sizes_i β (0, 1](normalized to bin capacity = 1)nbins available (worst case: one item per bin)x_{ij} = 1if itemiis placed in binj;y_j = 1if binjis usedβ_j y_jSmall concrete instance (5 items, capacity = 10)
One optimal packing uses 2 bins:
{2, 3}(sizes 7+3=10) and{1, 4, 5}(sizes 4+6... wait, 4+6=10, +2=12 β). Better:{2, 3}and{1, 5}(6) and{4}(6) β 3 bins, or{2, 3}and{4, 5}(8) and{1}β still 3 bins. Lower bound: β(4+7+3+6+2)/10β = β22/10β = 3 bins. Optimal = 3.Why It Matters
Cloud resource allocation β Virtual machines of varying memory/CPU requirements must be packed onto physical hosts to minimize the number of active servers, directly reducing operational costs.
Freight and logistics β Shipping containers, trucks, and cargo holds must be loaded efficiently; bin packing captures the 1-D capacity version of a ubiquitous daily optimization.
Compiler register allocation β Live variable ranges are "items" to be packed into a fixed set of CPU registers (the "bins"), making bin packing central to code generation.
Modeling Approaches
Approach 1 β Constraint Programming (CP)
Decision variables
bin[i] β {1..n}β which bin itemigoes intoload[j] β {0..C}β total load in binj(implied, linked viabin_packingglobal)Key constraints
Trade-offs: Tight LP relaxations via cutting planes (e.g., cover inequalities) make branch-and-bound effective for moderate instances. However, the
O(nΒ²)binary variables scale poorly for largen; column generation (set-cover reformulation) is the industrial-strength remedy.Example Model β MiniZinc (CP)
Key Techniques
1. Energy-Based Lower Bounds
The classic lower bound
ββ s_i / Cβis often weak. Dual-feasible functions (DFFs) transform item sizes to tighter lower bounds without changing the feasibility structure. The Floorceiling bound is a well-known DFF-based improvement. These bounds guide both branch-and-bound and CP search.2. The
bin_packingGlobal ConstraintCP solvers expose
bin_packing(andbin_packing_load) as a global constraint. Internally it applies knapsack-based filtering: for each bin, it checks whether the remaining "slack" can accommodate subsets of unassigned items, pruningbin[i]domains accordingly. This is exponentially stronger than decomposing into element/sum constraints.3. First-Fit Decreasing (FFD) Heuristic + Symmetry Breaking
FFD β sort items by decreasing size and greedily pack each into the first bin with room β runs in
O(n log n)and guarantees β€11/9 Β· OPT + 6/9bins. In exact solvers, FFD gives an upper bound to seed branch-and-bound. Pairing FFD with the symmetry-breaking constraintload[1] β₯ load[2] β₯ ...eliminates the vast majority of symmetric optima, often reducing search by orders of magnitude.Challenge Corner
References
bin_packingglobal constraint with knapsack-based filtering.Beta Was this translation helpful? Give feedback.
All reactions