






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







1โ (^) 6โ
1 2 3 4 5 6 7 8 9 10
2โ 3โ 4โ^ 5โ 7โ 8โ 9โ 10โ
Fig. 9.5. The greedy inpection of the graph of Example 31 reveals a matching of cardinality 9.
1โ 6โ
1 2 3 4 5 6 7 8 9 10
2โ 3โ 4โ^ 5โ 7โ 8โ 9โ 10โ
1 1
6โ 1โ 2โ 8โ 4โ^ 10โ
8 8 4 8
Fig. 9.6. Labeling and scanning reveals that the greedy matching was optimal.
9.2. The Hungarian Algorithm for the Assignment Problem. In Sec- tion 1 we had a brief encounter with the assignment problem
(AP) max
โ^ n
i=
โ^ n
j=
c (^) ij xij
s.t.
โ^ n
j=
xij = 1 (i โ [1, n]),
โ^ n
i=
xij = 1 (j โ [1, n]),
xij โ B (i, j โ [1, n]).
By now we recognise that this is an easy type of IP, since its constraint matrix is easily recognisable as satisfying the sufficient criterion of Theorem 7.6 and hence as a totally unimodular matrix. Thus, the assignment problem can be solved via its LP
relaxation
(P) max
โ^ n
i=
โ^ n
j=
c (^) ij xij
s.t.
โ^ n
j=
xij = 1 (i โ [1, n]),
โ^ n
i=
xij = 1 (j โ [1, n]),
xij โฅ 0 (i, j โ [1, n]).
We will now discuss a specialised algorithm based on the maximum cardinality match- ing problem that solves the assignment problem in polynomial time. This method is known as the Hungarian Algorithm.
We start by noting that the dual of (P) is
(D) min
โ^ n
i=
u (^) i +
โ^ n
j=
vj
s.t. u (^) i + vj โฅ c (^) ij (i, j = 1,... , n).
Since the assignment problem is neither infeasible nor unbounded, the same must be true for its LP dual (P), as well as for the dual (D). Thus, strong LP duality applies. Let us now derive a slightly weaker form of strong duality independently in the specific context of problems (P) and (D). The insight gained from this derivation will be useful in the construction of the algorithm.
The following observation holds both for the assignment problem and the TSP problem:
Lemma 9.13. Given real numbers {u (^) i } ni=1 and {vj } nj=1 , let us consider the ana- logue of problem (P) with changed weights cยฏ (^) ij = c (^) ij โ u (^) i โ vj ,
(Pโ) max
โ^ n
i=
โ^ n
j=
ยฏc (^) ij xij
s.t.
โ^ n
j=
xij = 1, (i โ [1, n]),
โ^ n
i=
xij = 1, (j โ [1, n]),
xij โฅ 0 , (i, j โ [1, n]).
Then the objective value of (Pโ) differs from that of (P) only by an additive constant.
matching problem. If the optimal matching is of cardinality n, we found an optimal assignment. Otherwise, we need to improve our guess of (u โ^ , v โ^ ). We call solving a max cardinality matching problem a primal step, since it concerns the computation of the primal variables x. Correspondingly, the updating procedure of (u, v) will be called a dual step. As we will see, the final labelling information from the primal step preceding a dual step will provide the information on how to update the dual variables.
Algorithm 9.15.
Before we analyse this algorithm further, let us see it in action for a specific ex- ample.
Example 32. Find a lower bound on the optimal value of a 6-city travelling salesman problem instance with distance matrix
๏ฃฎ ๏ฃฏ ๏ฃฏ ๏ฃฏ ๏ฃฏ ๏ฃฏ ๏ฃฏ ๏ฃฐ โ 2 3 4 1 11 9 โ 7 6 0 5 8 2 โ 4 9 8 2 1 3 โ 4 6 1 6 2 9 โ 3 7 4 6 12 7 โ
by solving its assignment problem relaxation.
We start by setting up the corresponding assignment problem graph. For this purpose, we split each node i of the TSP into two nodes i and i โฒ^ and set up a complete bipartite graph as follows: Arc (i, j โฒ^ ) in the new bipartite graph is given the edge weight of the arc (i, j) from the TSP. Arcs (i, i โฒ^ ) which donโt have a corresponding arc in the TSP and should be avoided are given a weight corresponding to an a priori upper bound on the length of a tour, e.g.,
c (^) iiโฒ^ = n max k$ =j c (^) kj + 1 = 73,
so that these arcs cannot appear in an optimal assignment solution. The TSP
min x
โn
i=
โ^ n
j=
c (^) ij xij
s.t.
j:j$ =i
xij = 1 (i โ [1, n]),
โ
i:i$=j
xij = 1 (j โ [1, n]),
โ
iโS
j /โS
xij โฅ 1 (S โ V, S += โ ),
x โ Bnรn^.
can now be relaxed by the assignment problem
min x
โn
i=
โ^ n
j โฒ^ =
c (^) ij โฒ^ xij โฒ
s.t.
j โฒ^ :j$ =i
xij โฒ = 1 (i โ [1, n]),
โ
i:i$=j
xij โฒ = 1 (j โ [1, n]),
x โ Bnรn^.
Algorithm 9.15 is designed for a maximisation problem instead of a minimisation problem. Thus, we multiply the objective function by โ 1 and find the vector xโ^ that maximises the problem
max x
โn
i=
โ^ n
j โฒ^ =
c (^) ij โฒ^ xij โฒ
s.t.
j โฒ^ :j $=i
xij โฒ = 1 (i โ [1, n]),
โ
i:i$=j
xij โฒ^ = 1 (j โ [1, n]),
x โ Bnรn
with the weights matrix
c (^) ij
Having completed our preparation works, we are now ready to start Algorithm 9.15.
Initialisation: Find dual feasible variables (u, v). One possible solution would be to set (u, v) = (0, 0). However, we can do better, as we want to introduce as many
3
4
2โ
4โ
6โ
5โ
4โ
3โ
2โ
1โ
6
5
4
3
2
1
Fig. 9.8. The labelling of the first residual graph, proving that the greedy matching was of maximum cardinality.
maximum cardinality. No augmenting path exists!
Since the matching found so far is of cardinality less than 6 , we need to improve our guess of the dual variables by taking a dual step: First we find
ฮด = min{โcยฏ (^) ij : i โ { 1 , 3 , 4 , 6 }, j โ { 1 โฒ^ , 3 โฒ^ , 5 โฒ^ , 6 โฒ^ }} = min
And then we compute the new edge weights,
ยฏc (^) ij โ ยฏc (^) ij (i โ V 1 + , j โ V 2 + ), ยฏc (^) ij โ ยฏc (^) ij (i โ V 1 โ , j โ V 2 โ ), ยฏc (^) ij โ ยฏc (^) ij โ ฮด (i โ V 1 โ , j โ V 2 + ), ยฏc (^) ij โ ยฏc (^) ij + ฮด (i โ V 1 + , j โ V 2 โ ).
Thus, the revised edge weight matrix is as follows,
ยฏc (^) ij
Using this matrix, we can construct the revised residual graph of Figure 9.9.
The old labelling remains valid and can be reused in the next primal step. Res- canning node 1 identifies an augmenting path 3 โ 4 โฒ^ โ 1 โ 3 โฒ^ , see Figure 9.10. We update the matching and start labelling again, see Figure 9.11. This leads to a further augmenting path 4 โ 1 โฒ^ , and to the optimal assignment of Figure 9.12.
Extracting the optimal decision vector xโ^ , we find
xij = 1 โ (i, j) โ {(1, 3), (3, 4), (4, 1)} โช {(5, 6), (6, 2), (2, 5)}.
3
4
2โ
4โ
6โ
5โ
4โ
3โ
2โ
1โ
6
5
4
3
2
1
Fig. 9.9. The second residual graph. Note that none of the edges already in the matching have been removed, and that the old labelling remains valid, but that the labelled nodes in V 1 now need rescanning, as they are incident to new edges that are not in the matching.
5โ
1
1 exposed!
1 2 3 4 5 6 1โ
2โ
3โ
4โ
5โ
6โ
4โ
2โ
4
3
Fig. 9.10. Rescanning Node 1 yields the discovery of an augmenting path 3 โ 4 โฒ^ โ 1 โ 3 โฒ^.
4โ
5โ
1
1
3โ exposed!
4
4
4
2โ
6โ
5โ
4โ
3โ
2โ
1โ
6
5
4
3
2
1
Fig. 9.11. The new labelling identifies an augmenting path 4 โ 1 โฒ^.
Proof. By the choice of ฮด, this is trivial to check.
As a consequence of this lemma, the new residual graph contains at least one new edge (i, j) with i โ V 1 + and j โ V 2 โ , and since M โ V 1 + ร V 2 + , all the edges of M appear in the new residual graph. The process of finding a matching of size n can thus be continued.
Keeping the labels of V 1 + and V 2 + , and marking the nodes of V 1 + as โunscannedโ yields the labelling that would be obtained if the nodes of the dual-step-updated graph Gยฏnew^ = (V 1 , V 2 , Eยฏ new^ ) were scanned in the same order as in the old graph Gยฏold^ = (V 1 , V 2 , Eยฏ old^ ). Note that all the edges used under the previous labelling are now in V 1 + ร V 2 + and thus remain in the new graph. The nodes in V 1 + need to be rescanned because they can be incident to new edges leading to nodes in V 2 โ.
Lemma 9.19. i) In each primal step in which no augmenting path is detected the cardinality of V 2 + increases by at least one from the labelling information inherited from the previous primal step. ii) After at most n dual steps, |M | will increase in the next primal step. Proof. i) Since V 2 + is inherited from one primal step to the next, |V 2 + | keeps increasing until an augmenting path is detected. The increase is strict because there exists (i, j) โ V 1 + ร V 2 โ that will have been added to the residual graph in the dual step in-between, so that j joins V 2 + upon rescanning i.
ii) An augmenting path is detected at the latest when |V 2 + | > |M |. By part i), it takes at most |M | + 1 primal steps before this happens.
Theorem 9.20. Algorithm 9.15 solves the assignment problem in O(n 3 ) work. Proof. The final output of Algorithm 9.15 corresponds to an optimal assignment, because the vector x โ Bn
2 defined by
xij = 1 โ (i, j) โ M
together with the final (u, v) satisfies the criteria of Theorem 9.14. In fact, ยฏc (^) ij โค 0 by dual feasibility of (u, v), and xij = 1 โ (i, j) โ Eยฏ โ ยฏc (^) ij = 0. Since |M โ^ | โค n, |M โ^ | can increase at most n times. By Lemma 9.19, it takes at most n primal and dual steps between increases. Due to the re-use of the labelling information, the overall complexity of finding an augmenting path is O(n 2 ). Thus, the overall complexity is O(n ยท n 2 ).
We remark that if the labelling is computed from scratch every time the bipartite maximum cardinality matching algorithm is called in a primal step, the complexity is O(n 4 ): Each such call has complexity O(n 2 ), and by Lemma 9.19 there are O(n) calls between increases in |M |, and it takes n increases until |M | = n.