4.2 Primal Heuristics
4.2.3 Improving Bisections
Once we have derived a bisection (S, V \ S), we try to improve it by exchanging or moving nodes between the two clusters. Of course, we have to keep an eye on the capacity constraint, i.e., we may not be able to move every node. Let the bisection be given by a vector z∈ {−1, 1}|V | so that
Algorithm 4 Initial heuristic SumPi Input: P ∈ R|V |×k, weights f
vfor all v∈ V , capacity F , constant ¯k ≤ k, a ∈ {−1, 1} ¯
k−1, objective
coefficient matrix C, approach m∈ {1, 2}
Output: Bisection vector z∈ {−1, 1}|V | or zero vector 0|V |
1: Compute pv= Pv1+P ¯ k
l=2al−1Pvl for all v∈ V
2: if m = 1 then{first approach} 3: zv= sgn(pv) for all v∈ V
4: else{second approach} 5: zv= 1 for all v∈ V 6: Sort V ={v1, . . . , v|V |} s.t. pvi ≤ pvj if i < j 7: for v = v1, . . . , v|V |do 8: if fv+ X i∈V :zi=−1 f (i) < f (V )− F then 9: zv=−1 10: else 11: if fv+ X i∈V :zi=−1 f (i) > F then 12: zv = 1 13: else 14: if hC(z − 2ev), z− 2evi < hCz, zi then 15: zv =−1 16: else 17: zv = 1 18: end if 19: end if 20: end if 21: end for 22: end if
23: return z := Algorithm 5(z, f, F ){try to derive a bisection}
v∈ V the following value:
D(v) := X iv∈E,zi=zv wiv− X iv∈E,zi6=zv wiv . (4.10)
A negative D(v) < 0 means that we can improve the cut by the amount D(v) by moving v to the other cluster. If D(v) is positive, we increase the costs of the cut if we move v. Based on this information, we encoded three local search heuristics called Swap, Move and Fiduccia-Mattheyses. Improve Heuristic Swap
This heuristic, as displayed in Algorithm 6, swaps node pairs until no further improvement of the current bisection seems possible. To this end, it computes in every iteration for at most ¯k arbitrarily chosen node pairs{i, j} with zi 6= zj the values
D(i, j) = D(i) + D(j) + 2wij . (4.11)
Among the analysed node pairs {i, j} that can be swapped without violating the capacity con- straint, we choose the pair with the smallest value D(i, j) < 0 and swap the two nodes. Ties with respect to D(i, j) are broken arbitrarily. Then, we iterate. We stop once there is no node pair left
Algorithm 5 Heuristic Bisection
Input: Partition vector z∈ {−1, 1}|V |, capacity F , objective coefficient matrix C
Output: Bisection vector z∈ {−1, 1}|V | or zero vector 0|V |
1: fs:= X v∈V :zv=s fv for s∈ {−1, 1} 2: b := TRUE 3: while (f1> F ∨ f−1> F ) ∧ b = TRUE do 4: s∗:= argmax s {f s: s ∈ {−1, 1}}, ¯s := −s∗ 5: V∗:= Argmin v∈V n hC ¯z, ¯zi : ¯z = z − 2zvev ∧ fs¯+ fv< fs ∗o 6: if V∗6= ∅ then 7: Choose arbitrarily v∗∈ V∗ 8: zv∗ :=−zv∗ 9: fs¯:= fs¯+ f v∗, fs ∗ := fs∗ − fv∗ 10: else 11: b := FALSE 12: end if 13: end while 14: if b = TRUE then 15: return z 16: else 17: return 0|V | 18: end if
among the analysed pairs with a negative D(i, j).
Algorithm 6 Improve heuristic Swap
Input: Bisection vector z∈ {−1, 1}|V |, weights f
v for all v∈ V , capacity F , costs wij for every
{i, j} ∈ E, constant ¯k
Output: Bisection vector z∈ {−1, 1}|V |
1: repeat
2: E :=¯ ∅, E∗:=∅
3: for k = 1, . . . , ¯k do
4: Choose arbitrarily{i, j} so that zi=−1 and zj = 1
5: if fi− fj+ X v∈V :zv=1 fv≤ F ∧ fj− fi+ X v∈V :zv=−1 fv≤ F then 6: E := ¯¯ E∪ {{i, j}} 7: end if 8: end for 9: E∗:= Argmin
{i,j}∈ ¯E{D(i, j) : D(i, j) = D(i) + D(j) + 2w ij < 0}
10: if E∗6= ∅ then
11: Choose arbitrarily{i, j} ∈ E∗ 12: zi:=−zi, zj:=−zj
13: end if 14: until E∗=∅
Improve Heuristic Move
In this heuristic, as displayed in Algorithm 7, we move individual nodes between the two clusters. Among the nodes that can be moved without violating the capacity constraint, we choose the one with the smallest negative value D(v), and move it to the opposite cluster. Again, ties with respect to D(v) are broken arbitrarily. We iterate until no movable node with negative D(v) exists. Algorithm 7 Improve heuristic Move
Input: Bisection vector z ∈ {−1, 1}|V |, weights f
v for all v ∈ V , capacity F , costs wij for every
{i, j} ∈ E
Output: Bisection vector z∈ {−1, 1}|V |
1: repeat 2: v∗:=−1, D
min:=∞
3: Generate a random sequence v1, . . . , v|V | of nodes in V
4: for j = 1, . . . ,|V | do 5: if fvj + X i∈V :zi=−zv fi≤ F ∧ D(vj) < Dminthen 6: Dmin:= D(vj), v∗:= vj 7: end if 8: end for 9: if v∗6= −1 then 10: zv∗ :=−zv∗ 11: end if 12: until Dmin≥ 0 13: return z
Improve Heuristic Fiduccia-Mattheyses
Observe that both our heuristics Swap and Move can get stuck in local minima. Our attempt to deal with this difficulty was inspired by the heuristics proposed by Kernighan and Lin [86] and Fiduccia and Mattheyses [47], and is displayed in Algorithm 8.
Given an equicut defined by (S, V \ S), the Kernighan-Lin heuristic swaps nodes of pairs {i, j} with i ∈ S and j ∈ V \ S like our heuristic Swap. However, it tries to avoid the pitfalls of local minima by temporarily considering swaps with a positive D(i, j), i.e., equicuts with a worse objective value than the one we start with. To be more precise, for fv = 1 for all v ∈ V and
|V | even, and a given equicut (S, V \ S) with |S| = 1
2|V |, one pass of the Kernighan-Lin heuristic
computes a sequence of 12|V | tentative swaps, so that each node is swapped exactly once. Each further swap results in a new equicut. The next pair{i, j} to be swapped is chosen as the one with the smallest D(i, j) among those nodes that were not yet swapped. Every tentative swap results in a new equicut, and we keep track of the one with minimum cut costs. Once the sequence of swaps is complete, the best encountered equicut is realised, provided that it is better than the one we started with, and the next pass of the heuristic computes a new sequence of tentative swaps. Otherwise, the heuristic stops.
Since Kernighan and Lin consider all node pairs when constructing a sequence of swaps, the heuristic has a time complexity of at least O(|V |2). Lengauer states that the Kernighan-Lin
heuristic usually computes about five sequences until no better equicut can be found and that it can be implemented with a run time of O(|V |2log
In our context, the Kernighan-Lin heuristic has two major drawbacks. First, it only works with equal node weights fv = 1 for all v ∈ V , and, second, it exclusively considers equicuts. To
overcome these drawbacks, Fiduccia and Mattheyses just adapted the idea of a sequence of tentative bisections, but, in contrast to Kernighan and Lin, they consider to move individual nodes to be able to work with bisections that are no equicuts. Every node is moved at most once. Furthermore, they assume that the capacity restriction is not too tight, i.e., F ≥12f (V )+maxv∈V fv. In this way,
they ensure that at any time in the construction of the tentative list of bisections there is always at least one node that can be moved without violating the capacity restriction, provided that there are nodes in both clusters that have not yet been moved. The next tentative bisection is computed by moving the node ¯v that has the smallest D(¯v) and that can be moved without violating the capacity restriction (line 5). Ties between nodes are broken randomly (line 7). As in the Kernighan-Lin heuristic, one keeps track of the best bisection encountered during the construction of the list (line 10 and 11). If it improves on the initial bisection, it is realised (lines 15 and 16), and the next list is computed (return to line 2).
A remark on the initial assumption F ≥ 1
2f (V ) + maxv∈V fv for the Fiduccia-Mattheyses
heuristic is due. Without this assumption, it can happen that there are no nodes that can be moved without violating the capacity restriction although there still are nodes in both clusters that have not been moved yet ( ¯V =∅ in line 5). In this case, we abandon the computation of the current tentative list early.
Lengauer reports an average of seven list computations for Fiduccia-Mattheyses until no better bisection can be found [91]. If the edge weights are identical for all edges, the run time can be speeded up to O(|E|), using a bucket data structure to store and update the values D(v). Thus, the run time becomes linear in the number of edges [47, 91].
Johnson et al. report practical experiences with both the Kernighan-Lin heuristic and the Fiduccia-Mattheyses heuristic: If Kernighan-Lin is allowed to use similar data structures as Fiducia- Mattheyses, both have comparable run times [77]. Moreover, Johnson et al. were not able to outperform Kernighan-Lin by Fiduccia-Mattheyses with respect to solution quality.