Introduction to Bin Packing Problems Fabio Furini March 13, 2015
Outline Origins and applications Applications: Definition: Bin Packing Problem (BPP) Solution techniques for the BPP Heuristic Algorithms Compact MIP formulation Stronger MIP formulation Pseudo-polynomial MIP formulation Arc-flow Formulation Dyckhoff Formulation
Extended Formulations Branch-and-Price Algorithms Knapsack Problems (KP01) Set Partitioning Formulation for BPP Set Covering Formulation for BPP Column Generation Lagrangian Dual bound Branch and Price Algorithm Branching rule Fabio Furini Université Paris Dauphine LAMSADE 3/35
Origins and applications Fabio Furini Université Paris Dauphine LAMSADE 4/35
Applications: Consider the following problem: determining the smallest number of rolls of a fixed width that have to be cut in order to satisfy the demand of clients. filling up containers; loading trucks with weight capacity constraints; creating file backups; placing data on multiple disks; job scheduling. Fabio Furini Université Paris Dauphine LAMSADE 5/35
Definition: Bin Packing Problem (BPP) Fabio Furini Université Paris Dauphine LAMSADE 6/35
Given a positive integer number of bins m of capacity W and a list of n items of integer sizes w 1,..., w n (0 w i W ), the problem is to assign the items to the bins so that the capacity of the bins is not exceeded and the number of bins used is minimized Fabio Furini Université Paris Dauphine LAMSADE 7/35
Theorem (Garey and Johnson (1979)) The BPP is NP-Hard (reduce from PARTITION). BPP has several real-world applications such as: Fabio Furini Université Paris Dauphine LAMSADE 8/35
How difficult is the BPP in practice? Some NP-Hard problems can be solved to optimality for instances of reasonable size: TSP thousands of nodes (cutting planes) BPP up to 1000 items (Branch and Bound, Branch and Price) BPP and its variants are really difficult from the practical viewpoint. Fabio Furini Université Paris Dauphine LAMSADE 9/35
Solution techniques for the BPP Fabio Furini Université Paris Dauphine LAMSADE 10/35
Heuristic Algorithms First Fit Algorithm: pack the current item into the first nonempty bin in which it fits. If no such bin exists, pack the current item into an empty bin. Best Fit Algorithm: pack the current item into the nonempty bin of largest free space in which it fits. If no such bin exists, pack the current item into an empty bin. Fabio Furini Université Paris Dauphine LAMSADE 11/35
Compact MIP formulation Variables (i = 1,..., n h = 1,..., m): { { 1 item i goes to bin h 1 if bin h is used x h i = y h = 0 otherwise 0 otherwise m min y h (1) h=1 m x h i = 1 i = 1,..., n (2) h=1 n w ix h i W y h h = 1,..., m (3) i=1 x h i {0, 1} i = 1,..., n, h = 1,..., m (4) y h {0, 1} h = 1,..., m (5) Fabio Furini Université Paris Dauphine LAMSADE 12/35
Question 1: write the Model ((1),(5)) for the following example: 3 bins and 3 items, W = 4, w 1 = 1, w 2 = 3, w 3 = 4. Question 2: try to figure out the optimal solution value of its Linear Programming relaxation and a possible solution vector of the variable values. Question 3: Cutting Stock Problem try to extend the Model ((1),(5) in case each item has a demand of d i copies (i = 1,..., n) Fabio Furini Université Paris Dauphine LAMSADE 13/35
Model ((1),(5)) is a weak! The Linear Relax has a useless value of: LR = ni=1 w i W (6) y h = LR/m h = 1,..., m (7) x h i = 1/m i = 1,..., n, h = 1,..., m (8) Huge symmetry!! for each integer solution of value k, there exist ( m k ) k! equivalent solutions. Fabio Furini Université Paris Dauphine LAMSADE 14/35
Stronger MIP formulation a feasible solution of value k (k < m) Variables (i = 1,..., n; min h=1,...,k h=1,...,k h = 1,..., k): y h (9) x h i = 1 i = 1,..., n (10) n w ix h i W y h h = 1,..., k (11) i=1 x h i y h i = 1,..., n, h = 1,..., k (12) x h i {0, 1} i = 1,..., n, h = 1,..., k (13) y h {0, 1} h = 1,..., k (14) Fabio Furini Université Paris Dauphine LAMSADE 15/35
Pseudo-polynomial MIP formulation Fabio Furini Université Paris Dauphine LAMSADE 16/35
Arc-flow Formulation Cutting pattern corresponds to a path in an acyclic directed graph G = (V, A), with V = 0, 1,..., W as its set of W + 1 vertices, which define positions in the stock sheet, and A = {(a, b) : 0 a < b W, b a = w i, i = 1,..., n} as its set of arcs. Minimum flow problem, where: variables ν ab correspond to the flow in arc (a, b), (item number of width b a placed at a units from the beginning of a bin variable φ corresponds to the total flow through the graph, and can be seen as the return flow from vertex W to vertex 0. Fabio Furini Université Paris Dauphine LAMSADE 17/35
min φ (a,b) A (c,c+w i ) A ν b a R + ν b a (a,b) A φ if b=0 νb a = 0 if b=1,...,w-1 φ if b=w (15) (16) ν c+w i c 1 i = 1,..., n (17) (a, b) A (18) Fabio Furini Université Paris Dauphine LAMSADE 18/35
Example: graph associated with an instance with bins of capacity W = 7 and items of sizes 5, 3, 2, respectively: Fabio Furini Université Paris Dauphine LAMSADE 19/35
Dyckhoff Formulation Residual Bins (RB): each time a bin of width W is cut in order to produce an item i of length w i, a residual bin of size W w i is obtained, which can be further used to produce additional items. m is the number of all the possible Residual Bins. Decision variables: 1 if item i is cut in residual bin z µ iz = 0 otherwise. Fabio Furini Université Paris Dauphine LAMSADE 20/35
1 if RB t results from cutting item type i from the RB z a izt = 0 otherwise. Fabio Furini Université Paris Dauphine LAMSADE 21/35
min n µ i0 (19) i=1 m µ iz 1 i = 1,..., n (20) z=0 m n n a izt µ iz µ it t = 1,..., m (21) z=1 i=1 i=1 µ iz R + i = 1,..., n z = 0,..., m (22) Fabio Furini Université Paris Dauphine LAMSADE 22/35
Extended Formulations Branch-and-Price Algorithms Fabio Furini Université Paris Dauphine LAMSADE 23/35
Knapsack Problems (KP01) Given: n items, with p j profit and w j weight of item j (j = 1,..., n) 1 container ( knapsack ) of capacity W select a subset of the items so that the sum of the profits is maximum and the sum of the weights does not exceed the capacity W. n N P-Hard problem, p j and w j integer, w j W, w j > W j=1 Fabio Furini Université Paris Dauphine LAMSADE 24/35
n max p i x i (23) i=1 n w i x i W (24) i=0 x i {0, 1} i = 1,..., n (25) Fabio Furini Université Paris Dauphine LAMSADE 25/35
Set Partitioning Formulation for BPP S = {s N : s is a KP 01 solution}. { 1 if KP01 s is in the solution x s = 0 otherwise min x s (26) s S x s = 1 i = 1,..., n (27) s S:i s x s {0, 1} s S (28) Fabio Furini Université Paris Dauphine LAMSADE 26/35
Set Covering Formulation for BPP min s S x s s S:i s (29) x s 1 i = 1,..., n (30) x s {0, 1} s S (31) S can be defined as the family of all maximal KP01 solutions. The LP of this formulation leads to tight lower bounds and avoids symmetry The number of maximal KP01 solutions is exponential in the number of items n (we need column generation and Branch-and-Price). Fabio Furini Université Paris Dauphine LAMSADE 27/35
Question 6: explicitly write the Set Partitioning and the Set Covering formulation of the following instance: bins of capacity W = 7 and items of sizes 5, 3, 2. Question 7: write the dual of these models and discuss how they change in case of having only a subset of the original variables Fabio Furini Université Paris Dauphine LAMSADE 28/35
Primal Dual min max n variables n constraints m constraints m variables constraint a i x b i variable u i 0 constraint a i x b i variable u i 0 constraint a i x = b i variable u i R variable x j 0 constraint a T j u c j variable x j 0 constraint a T j u c j variable x j R constraint a T j u = c j Fabio Furini Université Paris Dauphine LAMSADE 29/35
Column Generation min x s (32) s S s S:i s x s 1 i N (33) x s 0 s S (34) max π i (35) i N π i 1 s S (36) i s π i 0 i N (37) We solve the model with a subset S of the variables. Given an optimal solution (x,π ) of the restricted master problem, does it exist a set s S: i s π i > 1 (38) Fabio Furini Université Paris Dauphine LAMSADE 30/35
Lagrangian Dual bound i s π i > φ (33) i s π i φ = 1 LB = i N π i φ (35) Fabio Furini Université Paris Dauphine LAMSADE 31/35
Question 8: write a MIP model which allow the separation of the family of constraints (36) Question 9: write this MIP model for the following instance: bins of capacity W = 7 and items of sizes 5, 3, 2. Fabio Furini Université Paris Dauphine LAMSADE 32/35
Branch and Price Algorithm Column generation methods: necessary when the number of variables of a Linear Program is exponential Branch-and-Price Impose a subset of the variables 1 Solve the LP and get the current solution x, π 2 If some constraints in the Dual are violated by x, π, add the columns to the LP and go to 1 3 x is optimal and feasible for the LP (possibly fractional) Branch on a feasible disjunction for the problem and go to 1 Fabio Furini Université Paris Dauphine LAMSADE 33/35
Branching rule Basic idea (Ryan/Foster branching): at each node of the search tree we select two items i and j N. Then: 1) Same bin create a super item merging i and j, 2) Different bins create an extra constraints: x i + x j 1 In both cases 1) and 2) the resulting pricing problem is still a KP01, with 1) a super item forced to be packed together 2) an extra constraints not allowed to be packed together Fabio Furini Université Paris Dauphine LAMSADE 34/35
Questions?