The Dantzig-Wolfe Decomposition Algorithm

Example 18.6 Bin Packing Problem

The bin packing problem (BPP) finds the minimum number of capacitated bins that are needed to store a set of products of varying size. Define a set P of products, their sizes s Subscript p, and a set upper B equals StartSet 1 comma ellipsis comma StartAbsoluteValue upper P EndAbsoluteValue EndSet of candidate bins, each having capacity C. Let x Subscript p b be a binary variable that, if set to 1, indicates that product p is assigned to bin b. In addition, let y Subscript b be a binary variable that, if set to 1, indicates that bin b is used.

A BPP can be formulated as a MILP as follows:

StartLayout 1st Row 1st Column Blank 2nd Column minimize 3rd Column sigma-summation Underscript b element-of upper B Endscripts y Subscript b 2nd Row 1st Column Blank 2nd Column subject to 3rd Column sigma-summation Underscript b element-of upper B Endscripts x Subscript p b 4th Column equals 1 5th Column Blank 6th Column p element-of upper P 7th Column Blank 8th Column left-parenthesis Assignment right-parenthesis 3rd Row 1st Column Blank 2nd Column Blank 3rd Column sigma-summation Underscript p element-of upper P Endscripts s Subscript p Baseline x Subscript p b 4th Column less-than-or-equal-to upper C y Subscript b Baseline 5th Column Blank 6th Column b element-of upper B 7th Column Blank 8th Column left-parenthesis Capacity right-parenthesis 4th Row 1st Column Blank 2nd Column Blank 3rd Column x Subscript p b 4th Column element-of StartSet 0 comma 1 EndSet 5th Column Blank 6th Column p element-of upper P comma b element-of upper B 5th Row 1st Column Blank 2nd Column Blank 3rd Column y Subscript b 4th Column element-of StartSet 0 comma 1 EndSet 5th Column Blank 6th Column b element-of upper B EndLayout

In this formulation, the Assignment constraints ensure that each product is assigned to exactly one bin. The Capacity constraints ensure that the capacity restrictions are met for each bin. In addition, these constraints enforce the condition that if any product is assigned to bin b, then y Subscript b must be positive.

In this formulation, the bin identifier is arbitrary. For example, in any solution, the assignments to bin 1 can be swapped with the assignments to bin 2 without affecting feasibility or the objective value. Consider a decomposition by bin, where the Assignment constraints form the master problem and the Capacity constraints form identical subproblems. As described in the section Special Case: Identical Blocks and Ryan-Foster Branching, this is a situation in which an aggregate formulation and Ryan-Foster branching can greatly improve performance by reducing symmetry.

Consider a series of University of North Carolina basketball games that are recorded on a DVR. The following data set, dvr, provides the name of each game in the column opponent and the size of that game in gigabytes (GB) as it resides on the DVR in the column size:

/* game, size (in GBs) */
data dvr;
   input opponent $ size;
   datalines;
Clemson  1.36
Clemson2 1.97
Duke     2.76
Duke2    2.52
FSU      2.56
FSU2     2.34
GT       1.49
GT2      1.12
IN       1.45
KY       1.42
Loyola   1.42
MD       1.33
MD2      2.71
Miami    1.22
NCSU     2.52
NCSU2    2.54
UConn    1.25
VA       2.33
VA2      2.48
VT       1.41
Vermont  1.28
WM       1.25
WM2      1.23
Wake     1.61
;

The goal is to use the fewest DVDs on which to store the games for safekeeping. Each DVD can hold 4.38GB recorded data. The problem can be formulated as a bin packing problem and solved by using PROC OPTMODEL and the Dantzig-Wolfe decomposition algorithm. The following PROC OPTMODEL statements read in the data, declare the optimization model, and use the Dantzig-Wolfe decomposition algorithm to solve it:

proc optmodel;
   /* read the product and size data */
   set <str> PRODUCTS;
   num size {PRODUCTS};
   read data dvr into PRODUCTS=[opponent] size;

   /* 4.38 GBs per DVD */
   num binsize = 4.38;

   /* the number of products is a trivial upper bound on the
      number of bins needed */
   num upperbound init card(PRODUCTS);
   set BINS = 1..upperbound;

   /* Assign[p,b] = 1, if product p is assigned to bin b */
   var Assign {PRODUCTS, BINS} binary;
   /* UseBin[b] = 1, if bin b is used */
   var UseBin {BINS} binary;

   /* minimize number of bins used */
   min Objective = sum {b in BINS} UseBin[b];

   /* assign each product to exactly one bin */
   con Assignment {p in PRODUCTS}:
      sum {b in BINS} Assign[p,b] = 1;

   /* Capacity constraint on each bin (and definition of UseBin) */
   con Capacity {b in BINS}:
      sum {p in PRODUCTS} size[p] * Assign[p,b] <= binsize * UseBin[b];

   /* decompose by bin (subproblem is a knapsack problem) */
   for {b in BINS} Capacity[b].block = b;

   /* solve using decomp (aggregate formulation) */
   solve with milp / decomp;

The following PROC OPTMODEL statements create a sequential numbering of the bins and then output to the data set dvd the optimal assignments of games to bins:

   /* create a map from arbitrary bin number to sequential bin number */
   num binId init 1;
   num binMap {BINS};
   for {b in BINS: UseBin[b].sol > 0.5} do;
      binMap[b] = binId;
      binId     = binId + 1;
   end;

   /* create map of product to bin from solution */
   num bin {PRODUCTS};
   for {p in PRODUCTS} do;
      for {b in BINS: Assign[p,b].sol > 0.5} do;
         bin[p] = binMap[b];
         leave;
      end;
   end;

   /* create solution data */
   create data dvd from [product] bin size;
quit;

The solution summary is displayed in Output 18.6.1.

Output 18.6.1: Solution Summary

The OPTMODEL Procedure

Solution Summary
SolverMILP
AlgorithmDecomposition
Objective FunctionObjective
Solution StatusOptimal
Objective Value11
  
Relative Gap0
Absolute Gap0
Primal Infeasibility8.881784E-16
Bound Infeasibility2.220446E-16
Integer Infeasibility8.881784E-16
  
Best Bound11
Nodes1
Solutions Found4
Iterations2
Presolve Time0.00
Solution Time0.05


The iteration log is displayed in Output 18.6.2.

Output 18.6.2: Log

NOTE: There were 24 observations read from the data set WORK.DVR.                               
NOTE: Problem generation will use 4 threads.                                                    
NOTE: The problem has 600 variables (0 free, 0 fixed).                                          
NOTE: The problem has 600 binary and 0 integer variables.                                       
NOTE: The problem has 48 linear constraints (24 LE, 24 EQ, 0 GE, 0 range).                      
NOTE: The problem has 1176 linear constraint coefficients.                                      
NOTE: The problem has 0 nonlinear constraints (0 LE, 0 EQ, 0 GE, 0 range).                      
NOTE: The initial MILP heuristics are applied.                                                  
NOTE: The MILP presolver value AUTOMATIC is applied.                                            
NOTE: The MILP presolver removed 0 variables and 0 constraints.                                 
NOTE: The MILP presolver removed 0 constraint coefficients.                                     
NOTE: The MILP presolver modified 384 constraint coefficients.                                  
NOTE: The presolved problem has 600 variables, 48 constraints, and 1176 constraint coefficients.
NOTE: The MILP solver is called.                                                                
NOTE: The Decomposition algorithm is used.                                                      
NOTE: The Decomposition algorithm is executing in single-machine mode.                          
NOTE: The DECOMP method value USER is applied.                                                  
NOTE: All blocks are identical and the master model is set partitioning.                        
NOTE: The Decomposition algorithm is using an aggregate formulation and Ryan-Foster branching.  
NOTE: The number of block threads has been reduced to 1 threads.                                
NOTE: The problem has a decomposable structure with 24 blocks. The largest block covers 2.083%  
      of the constraints in the problem.                                                        
NOTE: The decomposition subproblems cover 600 (100%) variables and 24 (50%) constraints.        
NOTE: The deterministic parallel mode is enabled.                                               
NOTE: The Decomposition algorithm is using up to 4 threads.                                     
      Iter         Best       Master         Best       LP       IP  CPU Real                   
                  Bound    Objective      Integer      Gap      Gap Time Time                   
NOTE: The continuous bound was improved to 11 due to objective granularity.                     
         2      11.0000      11.0000      11.0000    0.00%    0.00%    0    0                   
         Node  Active   Sols         Best         Best      Gap    CPU   Real                   
                                  Integer        Bound            Time   Time                   
            0       1      4      11.0000      11.0000    0.00%      0      0                   
NOTE: The Decomposition algorithm used 4 threads.                                               
NOTE: The Decomposition algorithm time is 0.05 seconds.                                         
NOTE: Optimal.                                                                                  
NOTE: Objective = 11.                                                                           
NOTE: The data set WORK.DVD has 24 observations and 3 variables.                                


The following call to PROC SORT sorts the assignments by bin:

proc sort data=dvd;
   by bin;
run;

The optimal assignments from the output data set dvd are displayed in Figure 7.

Figure 7: Optimal Assignment of Games to DVDs

productsize
VA2.33
WM21.23
bin3.56

productsize
VA22.48
Vermont1.28
bin3.76

productsize
KY1.42
MD1.33
WM1.25
bin4.00

productsize
Loyola1.42
NCSU22.54
bin3.96

productsize
Miami1.22
NCSU2.52
bin3.74

productsize
IN1.45
MD22.71
bin4.16

productsize
Clemson1.36
GT1.49
VT1.41
bin4.26

productsize
Clemson21.97
FSU22.34
bin4.31

productsize
FSU2.56
UConn1.25
bin3.81

productsize
Duke22.52
Wake1.61
bin4.13

productsize
Duke2.76
GT21.12
bin3.88
 43.57


In this example, the objective function ensures that there exists an optimal solution that never assigns a product to more than one bin. Therefore, you could instead model the Assignment constraint as an inequality rather than an equality. In this case, the best performance would come from forcing the use of an aggregate formulation and Ryan-Foster branching by specifying the option VARSEL=RYANFOSTER. An example of doing this is shown in Example 18.8.

Last updated: June 22, 2026