The Decomposition Algorithm
Example 15.9 Kidney Donor Exchange and METHOD=SET
(View the complete code for this example.)
This example looks at an application of integer programming to help create a kidney donor exchange. Suppose someone needs a kidney transplant and a family member is willing to be a donor. If the donor and recipient are incompatible (because of blood type, tissue mismatch, and so on), the transplant cannot happen. Now suppose two donor-recipient pairs, i and j, are in this situation, but donor i is compatible with recipient j and donor j is compatible with recipient i. Then two transplants can take place in a two-way swap, shown in Figure 9. More generally, an n-way swap can be performed involving n donors and n recipients (CNN 2012).
Figure 9: Kidney Donor Exchange Two-Way Swap

Figure 10: Kidney Donor Exchange Network

To model this problem, define a directed graph as follows. Each node is an incompatible donor-recipient pair. Link exists if the donor from node i is compatible with the recipient from node j, as shown in Figure 10. Let N define the set of nodes and A define the set of arcs. The link weight, , is a measure of the quality of the match. By introducing dummy links whose weight is 0, you can also include altruistic donors who have no recipients or recipients who have no donors. The idea is to find a maximum-weight node-disjoint union of directed cycles. You want the union to be node-disjoint so that no kidney is donated more than once, and you want cycles so that the donor from node i donates a kidney if and only if the recipient from node i receives a kidney.
Without any other constraints, the problem could be solved as a linear assignment problem. But doing so would allow arbitrarily long cycles in the solution. For practical considerations (such as travel) and to mitigate risk, each cycle must have no more than L links. The kidney exchange problem is to find a maximum-weight node-disjoint union of short directed cycles.
Define an index set of candidate disjoint unions of short cycles (called matchings). Let be a binary variable that, if set to 1, indicates that arc is in a matching m. Let be a binary variable that, if set to 1, indicates that node i is covered by matching m. In addition, let be a binary slack variable that, if set to 1, indicates that node i is not covered by any matching.
The kidney donor exchange can be formulated as a MILP as follows:
In this formulation, the Packing constraints ensure that each node is covered by at most one matching. The Donate and Receive constraints enforce the condition that if node i is covered by matching m, then the matching m must use exactly one arc that leaves node i (Donate) and one arc that enters node i (Receive). Conversely, if node i is not covered by matching m, then no arcs that enter or leave node i can be used by matching m. The Cardinality constraints enforce the condition that the number of arcs in matching m must not exceed L.
In this formulation, the matching identifier is arbitrary. Because it is not necessary to cover each incompatible donor-recipient pair (node), the Packing constraints can be modeled by using set partitioning constraints and the slack variable s. Consider a decomposition by matching, in which the Packing constraints form the master problem and all other constraints form identical matching 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.
The following DATA step sets up the problem by first creating a random graph on n nodes with link probability p and Uniform(0,1) weight:
/* create random graph on n nodes with arc probability p
and uniform(0,1) weight */
%let n = 100;
%let p = 0.02;
data ArcData;
call streaminit(1);
do i = 0 to &n - 1;
do j = 0 to &n - 1;
if i eq j then continue;
else if rand('UNIFORM') < &p then do;
weight = rand('UNIFORM');
output;
end;
end;
end;
run;
In this case, you can specify METHOD=SET and let the decomposition algorithm automatically detect the set partitioning master constraints (Packing) and each independent matching subproblem. The following PROC OPTMODEL statements read in the data, declare the optimization model, and use the decomposition algorithm to solve it:
%let max_length = 10;
proc optmodel;
set <num,num> ARCS;
num weight {ARCS};
read data ArcData into ARCS=[i j] weight;
print weight;
set NODES = union {<i,j> in ARCS} {i,j};
set MATCHINGS = 1..card(NODES)/2;
/* UseNode[i,m] = 1 if node i is used in matching m, 0 otherwise */
var UseNode {NODES, MATCHINGS} binary;
/* UseArc[i,j,m] = 1 if arc (i,j) is used in matching m, 0 otherwise */
var UseArc {ARCS, MATCHINGS} binary;
/* maximize total weight of arcs used */
max TotalWeight
= sum {<i,j> in ARCS, m in MATCHINGS} weight[i,j] * UseArc[i,j,m];
/* each node appears in at most one matching */
/* rewrite as set partitioning (so decomp uses identical blocks)
sum{} x <= 1 => sum{} x + s = 1, s >= 0 with no associated cost */
var Slack {NODES} binary;
con Packing {i in NODES}:
sum {m in MATCHINGS} UseNode[i,m] + Slack[i] = 1;
/* at most one recipient for each donor */
con Donate {i in NODES, m in MATCHINGS}:
sum {<(i),j> in ARCS} UseArc[i,j,m] = UseNode[i,m];
/* at most one donor for each recipient */
con Receive {j in NODES, m in MATCHINGS}:
sum {<i,(j)> in ARCS} UseArc[i,j,m] = UseNode[j,m];
/* exclude long matchings */
con Cardinality {m in MATCHINGS}:
sum {<i,j> in ARCS} UseArc[i,j,m] <= &max_length;
/* automatically decompose using METHOD=SET */
solve with milp / presolver=basic decomp=(method=set);
/* save solution to a data set */
create data Solution from
[m i j]={m in MATCHINGS, <i,j> in ARCS: UseArc[i,j,m].sol > 0.5}
weight[i,j];
quit;
In this case, the PRESOLVER=BASIC option ensures that the model maintains its specified symmetry, enabling the algorithm to use the aggregate formulation and Ryan-Foster branching. The solution summary is displayed in Output 15.9.1.
Output 15.9.1: Solution Summary
| Solution Summary | |
|---|---|
| Solver | MILP |
| Algorithm | Decomposition |
| Objective Function | TotalWeight |
| Solution Status | Optimal |
| Objective Value | 24.850855395 |
| Relative Gap | 0 |
| Absolute Gap | 0 |
| Primal Infeasibility | 3.618616E-14 |
| Bound Infeasibility | 3.618616E-14 |
| Integer Infeasibility | 3.618616E-14 |
| Best Bound | 24.850855395 |
| Nodes | 13 |
| Solutions Found | 12 |
| Iterations | 117 |
| Presolve Time | 0.04 |
| Solution Time | 52.05 |
The iteration log is displayed in Output 15.9.2.
Output 15.9.2: Log
| NOTE: There were 208 observations read from the data set WORK.ARCDATA. |
| NOTE: Problem generation will use 4 threads. |
| NOTE: The problem has 15092 variables (0 free, 0 fixed). |
| NOTE: The problem has 15092 binary and 0 integer variables. |
| NOTE: The problem has 9751 linear constraints (49 LE, 9702 EQ, 0 GE, 0 range). |
| NOTE: The problem has 45080 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 BASIC is applied. |
| NOTE: The MILP presolver removed 5081 variables and 3366 constraints. |
| NOTE: The MILP presolver removed 15175 constraint coefficients. |
| NOTE: The MILP presolver modified 0 constraint coefficients. |
| NOTE: The presolved problem has 10011 variables, 6385 constraints, and 29905 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 SET 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 49 blocks. The largest block covers 2.02% |
| of the constraints in the problem. |
| NOTE: The decomposition subproblems cover 9947 (99.36%) variables and 6321 (99%) 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 |
| . 350.7353 11.3381 11.3381 96.77% 96.77% 0 0 |
| 2 332.0499 11.3381 11.3381 96.59% 96.59% 0 0 |
| 3 332.0499 15.5255 15.5255 95.32% 95.32% 0 0 |
| 4 330.3118 15.5255 15.5255 95.30% 95.30% 0 0 |
| 6 306.5935 15.5255 15.5255 94.94% 94.94% 0 0 |
| 8 306.5935 16.0266 16.0266 94.77% 94.77% 0 0 |
| 9 297.0018 17.0049 17.0049 94.27% 94.27% 0 0 |
| . 297.0018 19.7076 17.0049 93.36% 94.27% 0 1 |
| 10 297.0018 19.7076 17.0049 93.36% 94.27% 0 1 |
| 12 264.8075 20.7664 20.4103 92.16% 92.29% 7 7 |
| 13 260.5519 20.8157 20.4103 92.01% 92.17% 7 7 |
| 14 169.5522 20.8157 20.4103 87.72% 87.96% 7 7 |
| 16 162.7629 22.0203 20.4103 86.47% 87.46% 7 7 |
| 19 129.8164 22.6387 20.4103 82.56% 84.28% 7 7 |
| . 129.8164 22.7679 22.3688 82.46% 82.77% 7 7 |
| 20 129.8164 22.7679 22.3688 82.46% 82.77% 7 7 |
| 21 109.3664 23.2694 22.3688 78.72% 79.55% 7 7 |
| 23 94.4110 23.7787 22.3688 74.81% 76.31% 7 8 |
| 24 94.0535 24.4761 22.3688 73.98% 76.22% 7 8 |
| 26 84.9704 24.5230 22.3688 71.14% 73.67% 7 8 |
| 29 59.8574 24.9312 22.3688 58.35% 62.63% 7 8 |
| 30 59.8574 24.9938 22.3688 58.24% 62.63% 7 8 |
| 32 58.7970 25.1492 22.3688 57.23% 61.96% 8 8 |
| 35 45.8445 25.2737 22.3688 44.87% 51.21% 8 8 |
| 37 39.9698 25.3037 22.3688 36.69% 44.04% 8 8 |
| 38 32.8786 25.3422 22.3688 22.92% 31.97% 8 8 |
| . 32.8786 25.3882 23.5488 22.78% 28.38% 8 8 |
| 40 32.8786 25.3882 23.5488 22.78% 28.38% 8 8 |
| 43 27.0791 25.4056 23.5488 6.18% 13.04% 8 8 |
| 46 26.9391 25.4155 23.5488 5.66% 12.58% 8 8 |
| 47 25.4194 25.4194 23.5488 0.00% 7.36% 8 9 |
| NOTE: Starting branch and bound. |
| Node Active Sols Best Best Gap CPU Real |
| Integer Bound Time Time |
| 0 1 11 23.5488 25.4194 7.36% 8 9 |
| 1 3 12 24.8509 25.4194 2.24% 21 21 |
| 3 5 12 24.8509 25.1550 1.21% 41 41 |
| 12 0 12 24.8509 24.8509 0.00% 50 52 |
| NOTE: The Decomposition algorithm used 4 threads. |
| NOTE: The Decomposition algorithm time is 52.05 seconds. |
| NOTE: Optimal. |
| NOTE: Objective = 24.850855395. |
| NOTE: The data set WORK.SOLUTION has 47 observations and 4 variables. |
The solution is a set of arcs that define a union of short directed cycles (matchings). The following call to PROC OPTNET extracts the corresponding cycles from the list of arcs and outputs them to the data set Cycles.
data Solution;
set Solution;
run;
proc optnet
direction = directed
links = Solution;
links_var
from = i
to = j;
cycle
mode = all_cycles
out = Cycles;
run;
For more information about PROC OPTNET, see SAS/OR User's Guide: Network Optimization Algorithms. Alternatively, you can extract the cycles by using the SOLVE WITH NETWORK statement in PROC OPTMODEL (see Chapter 9, The Network Solver). The optimal donor exchanges from the output data set Cycles are displayed in Figure 11.
Figure 11: Optimal Donor Exchanges
| order | node |
|---|---|
| 1 | 2 |
| 2 | 18 |
| 3 | 90 |
| 4 | 26 |
| 5 | 84 |
| 6 | 53 |
| 7 | 62 |
| 8 | 2 |
| order | node |
|---|---|
| 1 | 6 |
| 2 | 96 |
| 3 | 27 |
| 4 | 93 |
| 5 | 23 |
| 6 | 51 |
| 7 | 87 |
| 8 | 78 |
| 9 | 43 |
| 10 | 41 |
| 11 | 6 |
| order | node |
|---|---|
| 1 | 38 |
| 2 | 79 |
| 3 | 71 |
| 4 | 38 |
| order | node |
|---|---|
| 1 | 3 |
| 2 | 56 |
| 3 | 5 |
| 4 | 83 |
| 5 | 45 |
| 6 | 63 |
| 7 | 14 |
| 8 | 64 |
| 9 | 69 |
| 10 | 92 |
| 11 | 3 |
| order | node |
|---|---|
| 1 | 37 |
| 2 | 39 |
| 3 | 89 |
| 4 | 77 |
| 5 | 37 |
| order | node |
|---|---|
| 1 | 21 |
| 2 | 85 |
| 3 | 82 |
| 4 | 73 |
| 5 | 21 |
| order | node |
|---|---|
| 1 | 0 |
| 2 | 99 |
| 3 | 33 |
| 4 | 29 |
| 5 | 20 |
| 6 | 24 |
| 7 | 97 |
| 8 | 31 |
| 9 | 46 |
| 10 | 0 |