The Decomposition Algorithm

Example 18.7 Resource Allocation Problem

This example describes a model for selecting tasks to be run on a shared resource (Gamrath 2010). Consider a set I of tasks and a resource capacity C. Each item has a profit , a resource utilization level , a starting period , and an ending period . The time horizon that is considered is from the earliest starting time to the latest ending time of all tasks. With each task, associate a binary variable , which, if set to 1, indicates that the task is running from its start time until just before its end time. A task consumes capacity if it is running. The goal is to select which tasks to run in order to maximize profit while not exceeding the shared resource capacity. Let define the set of start times for all tasks, and let define the set of tasks that are running at each start time . You can model the problem as a mixed integer linear programming problem as follows:

In this formulation, CapacityCon constraints ensure that the running tasks do not exceed the resource capacity. To illustrate, consider the following five-task example with data: , , , , and . The formulation leads to a constraint matrix that has a staircase structure that is determined by tasks coming online and offline:

Lagrangian Decomposition

This formulation clearly has no decomposable structure. However, you can use a common modeling technique known as Lagrangian decomposition to bring the model into block-angular form. Lagrangian decomposition works by first partitioning the constraints into blocks. Then, each original variable is split into multiple copies of itself, one copy for each block in which the variable has a nonzero coefficient in the constraint matrix. Constraints are added to enforce the equality of each copy of the original variable. Then, you can write the original constraints in block-angular form by using the duplicate variables.

To apply Lagrangian decomposition to the resource allocation problem, define a set B of blocks and let define the set of start times for a given block b, such that . Given this partition of start times, let define the set of blocks in which task is scheduled to be running. Now, for each task , define duplicate variables for each . Let define the minimum block index for each class of variable that represents task i. You can now model the problem in block-angular form as follows:

In this formulation, the LinkDupVarsCon constraints ensure that the duplicate variables are equal to the original variables. Now, the five-task example has been transformed from a staircase structure to a block-angular structure:

To see how to apply Lagrangian decomposition in PROC OPTMODEL, consider the data set TaskData from Caprara, Furini, and Malaguti (2010), which consists of 2,916 tasks:

data TaskData;
   input profit weight start end;
   datalines;
99 92 1 9
56 30 1 3
39 73 1 20
86 76 1 9
...
24 94 768 769
95 40 768 769
66 17 768 769
18 48 768 769
97 23 768 769
;

Using the MILP Solver Directly in PROC OPTMODEL

The following PROC OPTMODEL statements read in the data and solve the original staircase formulation by calling the MILP solver directly:

%macro SetupData(task_data=, capacity=);
   set TASKS;
   num capacity=&capacity;
   num profit{TASKS}, weight{TASKS}, start{TASKS}, end{TASKS};

   read data &task_data into TASKS=[_n_] profit weight start end;
   /* the set of start times */

   set STARTS = setof{i in TASKS} start[i];
   /* the set of tasks i that are active at a given start time s */
   set TASKS_START{s in STARTS}
      = {i in TASKS: start[i] <= s < end[i]};
%mend SetupData;

%macro ResourceAllocation_Direct(task_data=, capacity=);
   proc optmodel sessref="mysess";
      %SetupData(task_data=&task_data,capacity=&capacity);

      /* select task i to come online from period [start to end) */
      var x{TASKS} binary;

      /* maximize the total profit of running tasks */
      max TotalProfit = sum{i in TASKS} profit[i] * x[i];

      /* enforce that the shared resource capacity is not exceeded */
      con CapacityCon{s in STARTS}:
         sum{i in TASKS_START[s]} weight[i] * x[i] <= capacity;

      solve with milp / maxtime=200 logfreq=10000;
   quit;
%mend ResourceAllocation_Direct;

%ResourceAllocation_Direct(task_data=TaskData, capacity=100);

The problem summary and solution summary are displayed in Output 18.7.1.

Output 18.7.1: Problem Summary and Solution Summary

The OPTMODEL Procedure

Problem Summary
Objective SenseMaximization
Objective FunctionTotalProfit
Objective TypeLinear
  
Number of Variables2916
Bounded Above0
Bounded Below0
Bounded Below and Above2916
Free0
Fixed0
Binary2916
Integer0
  
Number of Constraints768
Linear LE (<=)768
Linear EQ (=)0
Linear GE (>=)0
Linear Range0
  
Constraint Coefficients23236

Solution Summary
SolverMILP
AlgorithmBranch and Cut
Objective FunctionTotalProfit
Solution StatusOptimal within Relative Gap
Objective Value40982
  
Relative Gap0.0000998535
Absolute Gap4.0926039503
Primal Infeasibility0
Bound Infeasibility0
Integer Infeasibility0
  
Best Bound40986.092604
Nodes42773
Solutions Found18
Iterations854833
Presolve Time0.11
Solution Time37.18


The iteration log, which contains the problem statistics, the progress of the solution, and the best integer feasible solution found, is shown in Output 18.7.2.

Output 18.7.2: Log

NOTE: There were 2916 observations read from the data set WORK.TASKDATA.                        
NOTE: Problem generation will use 4 threads.                                                    
NOTE: The problem has 2916 variables (0 free, 0 fixed).                                         
NOTE: The problem has 2916 binary and 0 integer variables.                                      
NOTE: The problem has 768 linear constraints (768 LE, 0 EQ, 0 GE, 0 range).                     
NOTE: The problem has 23236 linear constraint coefficients.                                     
NOTE: The problem has 0 nonlinear constraints (0 LE, 0 EQ, 0 GE, 0 range).                      
NOTE: The SOLVE statement is executing in the distributed computing environment in              
      single-machine mode.                                                                      
NOTE: The remaining solution time after problem generation and solver initialization is 199.30  
      seconds.                                                                                  
NOTE: The initial MILP heuristics are applied.                                                  
NOTE: The MILP presolver value AUTOMATIC is applied.                                            
NOTE: The MILP presolver removed 1021 variables and 126 constraints.                            
NOTE: The MILP presolver removed 12544 constraint coefficients.                                 
NOTE: The MILP presolver modified 987 constraint coefficients.                                  
NOTE: The presolved problem has 1895 variables, 642 constraints, and 10692 constraint           
      coefficients.                                                                             
NOTE: The MILP solver is called.                                                                
NOTE: The parallel Branch and Cut algorithm is used.                                            
NOTE: The Branch and Cut algorithm is using up to 8 threads.                                    
          Node   Active   Sols    BestInteger      BestBound      Gap    Time                   
             0        1      3  33939.0000000         109181   68.91%       0                   
             0        1      3  33939.0000000  45862.9249030   26.00%       0                   
             0        1      7  39381.0000000  45862.9249030   14.13%       0                   
             0        1      7  39381.0000000  43471.6068311    9.41%       0                   
             0        1      7  39381.0000000  42707.3723942    7.79%       0                   
             0        1      7  39381.0000000  42241.1002514    6.77%       0                   
             0        1      7  39381.0000000  41955.1816775    6.14%       1                   
             0        1      7  39381.0000000  41734.1601960    5.64%       1                   
             0        1      7  39381.0000000  41607.5699470    5.35%       1                   
             0        1      7  39381.0000000  41505.9202811    5.12%       2                   
             0        1      7  39381.0000000  41425.0313262    4.93%       2                   
             0        1      7  39381.0000000  41362.4491601    4.79%       2                   
             0        1     10  40449.0000000  41362.4491601    2.21%       2                   
             0        1     10  40449.0000000  41305.7252510    2.07%       2                   
             0        1     10  40449.0000000  41274.6068425    2.00%       3                   
             0        1     10  40449.0000000  41234.5169431    1.90%       3                   
             0        1     10  40449.0000000  41215.4383549    1.86%       3                   
             0        1     10  40449.0000000  41190.2974715    1.80%       3                   
             0        1     10  40449.0000000  41171.5824493    1.76%       3                   
             0        1     10  40449.0000000  41160.1367199    1.73%       4                   
             0        1     10  40449.0000000  41149.4384559    1.70%       4                   
             0        1     10  40449.0000000  41139.0749379    1.68%       4                   
             0        1     10  40449.0000000  41127.2553311    1.65%       4                   
             0        1     10  40449.0000000  41113.7119945    1.62%       4                   
             0        1     10  40449.0000000  41103.9721930    1.59%       4                   
             0        1     10  40449.0000000  41097.6440386    1.58%       5                   
             0        1     10  40449.0000000  41092.5748715    1.57%       5                   
             0        1     13  40874.0000000  41092.5748715    0.53%       5                   
             0        1     13  40874.0000000  41088.3184301    0.52%       5                   
             0        1     13  40874.0000000  41084.3901110    0.51%       5                   
             0        1     13  40874.0000000  41078.2336982    0.50%       5                   
NOTE: The MILP solver added 845 cuts with 11367 cut coefficients at the root.                   
          1451      558     14  40963.0000000  41051.4422601    0.22%       7                   
          3153     1427     15  40975.0000000  41035.7236064    0.15%       8                   
          3165     1434     16  40976.0000000  41035.7236064    0.15%       8                   
         14178     6526     17  40978.0000000  41013.5398043    0.09%      16                   
         14242     6514     18  40982.0000000  41013.3993884    0.08%      16                   
         42772      576     18  40982.0000000  40986.0926040    0.01%      37                   
NOTE: Optimal within relative gap.                                                              
NOTE: Objective = 40982.                                                                        


Using the Decomposition Algorithm in PROC OPTMODEL

To transform this data into block-angular form, first sort the task data to help reduce the number of duplicate variables that are needed in the reformulation as follows:

proc sort data=TaskData;
   by start end;
run;

Then, create the partition of constraints into blocks of size block_size as follows:

%macro ResourceAllocation_Decomp(task_data=, capacity=, block_size=);
   proc optmodel sessref="mysess";
      %SetupData(task_data=&task_data,capacity=&capacity);
      /* partition into blocks of size blocks_size */
      num block_size = &block_size;
      num num_blocks = ceil( card(TASKS) / block_size );
      set BLOCKS     = 1..num_blocks;

      /* the set of starts s for which task i is active */
      set STARTS_TASK{i in TASKS} = {s in STARTS: start[i] <= s < end[i]};

      /* partition the start times into blocks of size block_size */
      set STARTS_BLOCK{BLOCKS} init {};
      num block_id    init 1;
      num block_count init 0;
      for{s in STARTS} do;
         STARTS_BLOCK[block_id] = STARTS_BLOCK[block_id] union {s};
         block_count = block_count + 1;
         if(mod(block_count, block_size) = 0) then
             block_id = block_id + 1;
      end;

Then, use the following PROC OPTMODEL statements to define the block-angular formulation and solve the problem by using the decomposition algorithm, the PRESOLVER=BASIC option, and block_size=20. Because this reformulation is equivalent to the original staircase formulation, disabling some of the advanced presolver techniques ensures that the model maintains block-angularity.

      /* blocks in which task i is online */
      set BLOCKS_TASK{i in TASKS} =
         {b in BLOCKS: card(STARTS_BLOCK[b] inter STARTS_TASK[i]) > 0};

      /* minimum block id in which task i is online */
      num min_block{i in TASKS} = min{b in BLOCKS_TASK[i]} b;

      /* select task i to come online from period [start to end)
         in each block */
      var x{i in TASKS, b in BLOCKS_TASK[i]} binary;

      /* maximize the total profit of running tasks */
      max TotalProfit = sum{i in TASKS} profit[i] * x[i,min_block[i]];

      /* enforce that task selection is consistent across blocks */
      con LinkDupVarsCon{i in TASKS, b in BLOCKS_TASK[i] diff {min_block[i]}}:
         x[i,b] = x[i,min_block[i]];

      /* enforce that the shared resource capacity is not exceeded */
      con CapacityCon{b in BLOCKS, s in STARTS_BLOCK[b]}:
         sum{i in TASKS_START[s]} weight[i] * x[i,b] <= capacity;

      /* define blocks for decomposition algorithm */
      for{b in BLOCKS, s in STARTS_BLOCK[b]} CapacityCon[b,s].block = b;

      solve with milp / presolver=basic decomp;
   quit;
%mend ResourceAllocation_Decomp;

%ResourceAllocation_Decomp(task_data=TaskData, capacity=100, block_size=20);

The problem summary and solution summary are displayed in Output 18.7.3. Compared to the original formulation, the numbers of variables and constraints are increased by the number of duplicate variables.

Output 18.7.3: Problem Summary and Solution Summary

The OPTMODEL Procedure

Problem Summary
Objective SenseMaximization
Objective FunctionTotalProfit
Objective TypeLinear
  
Number of Variables3924
Bounded Above0
Bounded Below0
Bounded Below and Above3924
Free0
Fixed0
Binary3924
Integer0
  
Number of Constraints1776
Linear LE (<=)768
Linear EQ (=)1008
Linear GE (>=)0
Linear Range0
  
Constraint Coefficients25252

Solution Summary
SolverMILP
AlgorithmDecomposition
Objective FunctionTotalProfit
Solution StatusOptimal within Relative Gap
Objective Value40982
  
Relative Gap0.0000975943
Absolute Gap4
Primal Infeasibility4.440892E-16
Bound Infeasibility4.440892E-16
Integer Infeasibility4.440892E-16
  
Best Bound40986
Nodes13
Solutions Found77
Iterations254
Presolve Time0.06
Solution Time77.64


The iteration log, which contains the problem statistics, the progress of the solution, and the optimal objective value, is shown in Output 18.7.4.

Output 18.7.4: Log

NOTE: There were 2916 observations read from the data set WORK.TASKDATA.                        
NOTE: Problem generation will use 4 threads.                                                    
NOTE: The problem has 3924 variables (0 free, 0 fixed).                                         
NOTE: The problem has 3924 binary and 0 integer variables.                                      
NOTE: The problem has 1776 linear constraints (768 LE, 1008 EQ, 0 GE, 0 range).                 
NOTE: The problem has 25252 linear constraint coefficients.                                     
NOTE: The problem has 0 nonlinear constraints (0 LE, 0 EQ, 0 GE, 0 range).                      
NOTE: The SOLVE statement is executing in the distributed computing environment in              
      single-machine mode.                                                                      
NOTE: The initial MILP heuristics are applied.                                                  
NOTE: The MILP presolver value BASIC is applied.                                                
NOTE: The MILP presolver removed 4 variables and 0 constraints.                                 
NOTE: The MILP presolver removed 23 constraint coefficients.                                    
NOTE: The MILP presolver modified 7297 constraint coefficients.                                 
NOTE: The presolved problem has 3920 variables, 1776 constraints, and 25229 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: The problem has a decomposable structure with 39 blocks. The largest block covers 1.126%  
      of the constraints in the problem.                                                        
NOTE: The decomposition subproblems cover 3920 (100%) variables and 768 (43.24%) constraints.   
NOTE: The deterministic parallel mode is enabled.                                               
NOTE: The Decomposition algorithm is using up to 8 threads.                                     
      Iter         Best       Master         Best       LP       IP  CPU Real                   
                  Bound    Objective      Integer      Gap      Gap Time Time                   
         .   44109.0000   37727.0000   37727.0000   14.47%   14.47%    1    2                   
         5   44109.0000   37762.0000   37762.0000   14.39%   14.39%    3    3                   
         7   44109.0000   37815.0000   37815.0000   14.27%   14.27%    3    3                   
         8   44109.0000   37969.0000   37969.0000   13.92%   13.92%    4    4                   
        10   44109.0000   37969.0000   38272.0000   13.92%   13.23%    4    4                   
        12   44109.0000   38474.0000   38474.0000   12.78%   12.78%    6    5                   
        14   44109.0000   38597.0000   38597.0000   12.50%   12.50%    7    5                   
        16   44109.0000   38856.0000   38856.0000   11.91%   11.91%    8    5                   
         .   44109.0000   39216.0000   39216.0000   11.09%   11.09%    9    6                   
        20   44109.0000   39216.0000   39216.0000   11.09%   11.09%    9    6                   
        23   44109.0000   40097.0000   40097.0000    9.10%    9.10%   12    7                   
        25   44109.0000   40167.0000   40167.0000    8.94%    8.94%   14    7                   
        28   44109.0000   40355.0000   40355.0000    8.51%    8.51%   17    8                   
        30   44109.0000   40382.0000   40382.0000    8.45%    8.45%   18    9                   
        32   44109.0000   40443.0000   40443.0000    8.31%    8.31%   20    9                   
        36   44109.0000   40523.5000   40522.0000    8.13%    8.13%   25   11                   
        40   44109.0000   40523.5000   40592.0000    8.13%    7.97%   30   12                   
        43   44109.0000   40685.5000   40684.0000    7.76%    7.76%   34   13                   
        47   44109.0000   40748.5000   40747.0000    7.62%    7.62%   40   14                   
        50   44109.0000   40748.8333   40747.0000    7.62%    7.62%   46   16                   
        53   44109.0000   40780.3333   40780.0000    7.55%    7.55%   50   17                   
        60   44109.0000   40784.5833   40780.0000    7.54%    7.55%   62   20                   
        62   41744.8048   40840.5833   40831.0000    2.17%    2.19%   65   21                   
        64   41503.1109   40861.3433   40831.0000    1.55%    1.62%   70   22                   
        70   41503.1109   40913.2083   40928.0000    1.42%    1.39%   77   24                   
        78   41503.1109   40972.5833   40957.0000    1.28%    1.32%   83   27                   
         .   41503.1109   40972.5833   40957.0000    1.28%    1.32%   84   27                   
        80   41503.1109   40972.5833   40957.0000    1.28%    1.32%   85   27                   
        81   41100.3405   40972.5833   40957.0000    0.31%    0.35%   87   28                   
        82   41065.6548   40991.0833   40957.0000    0.18%    0.26%   88   28                   
        83   41045.1722   40991.0833   40957.0000    0.13%    0.21%   89   28                   
        90   41045.1722   40997.5833   40957.0000    0.12%    0.21%   92   30                   
        95   40997.5833   40997.5833   40957.0000    0.00%    0.10%   94   31                   
         .   40997.5833   40997.5833   40982.0000    0.00%    0.04%   94   31                   
NOTE: Starting branch and bound.                                                                
         Node  Active   Sols         Best         Best      Gap    CPU   Real                   
                                  Integer        Bound            Time   Time                   
            0       1     77   40982.0000   40997.5833    0.04%     94     31                   
            2       2     77   40982.0000   40991.5833    0.02%    174     49                   
            5       3     77   40982.0000   40991.5833    0.02%    218     60                   
           10       2     77   40982.0000   40987.3333    0.01%    271     73                   
           12       0     77   40982.0000   40986.0000    0.01%    284     77                   
NOTE: The Decomposition algorithm used 8 threads.                                               
NOTE: The Decomposition algorithm time is 77.64 seconds.                                        
NOTE: Optimal within relative gap.                                                              
NOTE: Objective = 40982.                                                                        


The Trade-Off between Coverage and Subproblem Difficulty

The reformulation of this resource allocation problem provides a nice example of the potential trade-offs in modeling a problem for use with the decomposition algorithm. As seen in Example 18.2, the strength of the bound is an important factor in the overall performance of the algorithm, but it is not always correlated to the magnitude of the subproblem coverage. In the current example, the block size determines the number of blocks. Moreover, it determines the number of linking variables that are needed in the reformulation. At one extreme, if the block size is set to be , then the number of blocks is 1, and the number of copies of original variables is 0. Using one block would be equivalent to the original staircase formulation and would not yield a model conducive to decomposition. As the number of blocks is increased, the number of linking variables increases (the size of the master problem), the strength of the decomposition bound decreases, and the difficulty of solving the subproblems decreases. In addition, as the number of blocks and their relative difficulty change, the efficient utilization of your machine’s parallel architecture can be affected.

The previous section used a block size of 20. The following statement calls the decomposition algorithm and uses a block size of 80:

%ResourceAllocation_Decomp(task_data=TaskData, capacity=100, block_size=80);

The solution summary is displayed in Output 18.7.5.

Output 18.7.5: Solution Summary

The OPTMODEL Procedure

Solution Summary
SolverMILP
AlgorithmDecomposition
Objective FunctionTotalProfit
Solution StatusOptimal
Objective Value40982
  
Relative Gap0
Absolute Gap0
Primal Infeasibility0
Bound Infeasibility0
Integer Infeasibility0
  
Best Bound40982
Nodes1
Solutions Found54
Iterations52
Presolve Time0.06
Solution Time40.77


The iteration log, which contains the problem statistics, the progress of the solution, and the optimal objective value, is shown in Output 18.7.6.

This version of the model provides a stronger initial bound and solves to optimality in the root node.

Output 18.7.6: Log

NOTE: There were 2916 observations read from the data set WORK.TASKDATA.                        
NOTE: Problem generation will use 4 threads.                                                    
NOTE: The problem has 3151 variables (0 free, 0 fixed).                                         
NOTE: The problem has 3151 binary and 0 integer variables.                                      
NOTE: The problem has 1003 linear constraints (768 LE, 235 EQ, 0 GE, 0 range).                  
NOTE: The problem has 23706 linear constraint coefficients.                                     
NOTE: The problem has 0 nonlinear constraints (0 LE, 0 EQ, 0 GE, 0 range).                      
NOTE: The SOLVE statement is executing in the distributed computing environment in              
      single-machine mode.                                                                      
NOTE: The initial MILP heuristics are applied.                                                  
NOTE: The MILP presolver value BASIC is applied.                                                
NOTE: The MILP presolver removed 5 variables and 0 constraints.                                 
NOTE: The MILP presolver removed 29 constraint coefficients.                                    
NOTE: The MILP presolver modified 7295 constraint coefficients.                                 
NOTE: The presolved problem has 3146 variables, 1003 constraints, and 23677 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: The problem has a decomposable structure with 10 blocks. The largest block covers 7.976%  
      of the constraints in the problem.                                                        
NOTE: The decomposition subproblems cover 3146 (100%) variables and 768 (76.57%) constraints.   
NOTE: The deterministic parallel mode is enabled.                                               
NOTE: The Decomposition algorithm is using up to 8 threads.                                     
      Iter         Best       Master         Best       LP       IP  CPU Real                   
                  Bound    Objective      Integer      Gap      Gap Time Time                   
         .   41762.0033   37361.0000   37361.0000   10.54%   10.54%    4    1                   
        10   41762.0033   38529.0000   38533.0000    7.74%    7.73%   12    4                   
        16   41762.0033   39213.0000   39213.0000    6.10%    6.10%   20    7                   
        18   41762.0033   40697.0000   40697.0000    2.55%    2.55%   24    9                   
         .   41762.0033   40697.0000   40697.0000    2.55%    2.55%   28   10                   
        20   41762.0033   40697.0000   40697.0000    2.55%    2.55%   32   11                   
        24   41762.0033   40740.0000   40740.0000    2.45%    2.45%   40   14                   
        26   41762.0033   40806.0000   40806.0000    2.29%    2.29%   49   17                   
        30   41762.0033   40806.0000   40806.0000    2.29%    2.29%   63   22                   
        36   41762.0033   40883.0000   40883.0000    2.10%    2.10%   77   25                   
        39   41762.0033   40910.0000   40910.0000    2.04%    2.04%   83   27                   
         .   41762.0033   40910.0000   40910.0000    2.04%    2.04%   83   27                   
        40   41762.0033   40910.0000   40910.0000    2.04%    2.04%   87   28                   
        41   41098.8341   40910.0000   40910.0000    0.46%    0.46%   92   30                   
        42   41032.0012   40910.0000   40910.0000    0.30%    0.30%   95   31                   
        45   41032.0012   40928.0000   40928.0000    0.25%    0.25%  102   34                   
        46   41032.0012   40935.0000   40935.0000    0.24%    0.24%  104   35                   
        49   41032.0012   40982.0000   40982.0000    0.12%    0.12%  109   37                   
        50   41032.0012   40982.0000   40982.0000    0.12%    0.12%  110   38                   
        52   40982.0000   40982.0000   40982.0000    0.00%    0.00%  112   40                   
         Node  Active   Sols         Best         Best      Gap    CPU   Real                   
                                  Integer        Bound            Time   Time                   
            0       0     54   40982.0000   40982.0000    0.00%    112     40                   
NOTE: The Decomposition algorithm used 8 threads.                                               
NOTE: The Decomposition algorithm time is 40.77 seconds.                                        
NOTE: Optimal.                                                                                  
NOTE: Objective = 40982.                                                                        


Last updated: June 14, 2018