π§© Constraint Solving POTD:Bin Packing β minimise the number of bins #32350
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 #32609. |
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.
-
ποΈ Problem of the Day β Bin Packing
Problem Statement
You have
nitems, each with a weightw_i, and an unlimited supply of bins each with capacityC. The goal is to pack all items into the fewest bins possible.Concrete Instance (8 items, capacity = 10)
Optimal solution uses 4 bins:
Input: item weights
w_1, ..., w_nand bin capacityCOutput: minimum number of bins
kand an assignmentbin(i) β {1..k}for each itemWhy It Matters
Modeling Approaches
Approach 1 β Constraint Programming (CP)
Decision variables:
bin(i) β {1..n}β bin assigned to itemikβ number of bins used (minimise)Key constraints:
Global constraint:
bin_packing_capa(load, bin, w)(available in most CP solvers) computes the load on each bin via a single propagator β far stronger than decomposing into sums.Trade-offs: Excellent propagation via the global constraint; symmetry among bins must be broken explicitly or search explodes.
Approach 2 β Mixed Integer Programming (MIP)
Decision variables:
y_j β {0,1}β binjis usedx_ij β {0,1}β itemiis in binjModel:
Trade-offs: LP relaxation gives a useful lower bound (
βw_i / C); scales to large instances with branch-and-bound + column generation; less natural for expressing ordering symmetry.Example Model β MiniZinc (CP)
Key Techniques
1. The
bin_packing_capaGlobal ConstraintThis single propagator simultaneously enforces capacity limits on all bins and filters
bin(i)values by checking whether itemican feasibly be placed anywhere. It achieves bounds consistency in O(n log n) time β vastly better than a sum-decomposition.2. Symmetry Breaking
Bins are interchangeable: swapping items between bin 1 and bin 2 gives an equivalent solution but blows up the search space. Common fixes:
bin(i) β€ bin(i+1)whenw_i = w_{i+1}3. Column Generation for MIP
The MIP formulation above has O(n2) binary variables. Column generation (GilmoreβGomory, 1961) works over the exponentially many feasible packing patterns instead. The restricted master problem has far fewer variables at any time; new columns are generated by solving a bounded knapsack subproblem. This is the method of choice for industrial-scale instances (n > 10 000).
Challenge Corner
References
bin_packing_capa.bin_packing_capadocumentation]((www.minizinc.org/redacted) with worked examples and solver hints.Beta Was this translation helpful? Give feedback.
All reactions