4.2. Crossover Operator
In our proposal, a central component is the recombination operator. It takes two partitions as input (the parents) and creates a new offspring partition that combines their features. This is achieved by employing the Hungarian-based crossover (HBX), which was recently proposed for the graph partitioning problem [
51].
Two features are particularly important in our context:
Balance: Since the upper bound is tight, the operator should promote balanced partitions.
Feature retention: To maintain the characteristics of the parents, pairs of vertices that were grouped together in the original partitions should have a higher probability of remaining together in the offspring than those that were not.
The HBX operator promotes these features by first calculating an intersection matrix C (with dimensions ), where each element represents the intersection between cluster i of the first parent and cluster j of the second parent. Each new cluster in the offspring is then generated by joining p of these intersections.
Since each new cluster is the union of the same number of intersections, balanced clusters are promoted. Furthermore, intersections that appear in the same column or row are joined with a higher probability, and the initial positions are selected using the Hungarian algorithm. Consequently, the largest intersections are distributed across different clusters, which further promotes a proper balance and maximizes the number of vertex pairs that share a cluster in at least one parent.
Algorithm 2 shows all the internal details of HBX. First, line 1 starts by creating a complete edge-weighted bipartite graph
G through Algorithm 3, where the vertices are the cycles of the parent solutions, and the weights are the number of common vertices between said cycles. Algorithm 3 has a time complexity of
, since for each pair of cycles
, computing their intersection can be performed in
. Then, a maximum weighted-matching
M is obtained in line 2. This is performed using the Hungarian algorithm, which solves the assignment problem in polynomial time. Note that, in this case, the time complexity of the Hungarian algorithm is
, since the constructed bipartite graph has
vertices. The HBX uses the edges of
M to create an offspring partition from the solutions
s and
k by promoting the creation of new clusters with vertices that are part of the same clusters from the parents. The purpose is to keep clusters of good-quality cycles in the offspring. Each cluster of the offspring must be composed exactly of the union of
p intersections of the bipartite graph
G. In addition, each edge of
M can be used only once. Thus, to avoid repetitions,
B (line 3) is used to track the edges used in the recombination process.
S and
K (lines 4–5) store eligible vertices that will be used to ensure that each offspring cluster is composed exactly of the union of
p intersections. In line 6, the offspring partition
is first created as empty. Then, each iteration of the for-loop in line 7 will select the vertices that compose the
ith cluster of the offspring. Inside this for-loop, the following actions take place. In line 8, an edge in
is taken and removed from
M, and in line 9, the i
cluster of the offspring is initialized as the empty set. Then, lines 11–19 will be executed in odd iterations, whereas lines 21–29 will be executed in even iterations. In odd iterations, endpoint
is fixed, and all adjacent unused edges of
are used to compose the
ith cluster of the offspring (lines 12–15). Finally, if fewer than
p edges are available to compose the i
cluster of the offspring, lines 16–19 will ensure that the missing edges are considered to form the i
cluster of the offspring. This is performed by taking endpoint
and considering all its unused adjacent edges as eligible vertices in
S. Even iterations (lines 21–29) run the same steps but fix the endpoint
. The time complexity of Algorithm 2 relies on the bipartite graph
. As discussed before, this graph is constructed in
in line 1. Then, the maximum weighted matching
M is computed in
. Then, in the main for-loop of line 7, the most expensive computations rely on the unions and intersections of clusters of size
U for each edge in
M. Thus, the complexity of this main for-loop is
. We conclude that the time complexity of the HBX is
. For better comprehension,
Table 2 and
Table 3 show an example of two parent solutions,
s and
k, and the weights of the complete bipartite edge-weighted graph formed by said solutions.
Figure 1 shows the maximum weighted matching and the execution of the HBX.
Table 2.
Two candidate solutions, and , for an example instance with vertices, cycles, and .
Table 2.
Two candidate solutions, and , for an example instance with vertices, cycles, and .
| s | k |
|---|
| |
| |
| |
| |
| Algorithm 2: Hungarian-based crossover (HBX) |
![Mca 31 00064 i002 Mca 31 00064 i002]() |
Table 3.
Weights of bipartite graph generated from the
s and
k solutions of
Table 2.
Table 3.
Weights of bipartite graph generated from the
s and
k solutions of
Table 2.
| | | | | |
|---|
| 1 | 3 | 1 | 1 |
| 3 | 1 | 1 | 1 |
| 1 | 1 | 3 | 1 |
| 1 | 1 | 1 | 3 |
After the recombination process ends, the offspring generated may violate the upper-bound constraints. Thus, the balancing phase of Algorithm 4 is executed. This algorithm verifies if clusters exist that exceed the maximum number of vertices allowed. If so, a random vertex is extracted from said cluster and inserted into a random available cluster. Regarding complexity, since each element is moved at most once, this simple balancing algorithm has a complexity of
, where
n is the total number of vertices in the partition.
| Algorithm 3: Create bipartite graph |
Input: Two candidate solutions and Output: A complete bipartite graph - 1
- 2
//
- 3
// build complete bipartite graph - 4
return
G
|
Figure 1.
(a) is the bipartite complete edge-weighted graph formed by solutions s and k, where maximum weighted matching is in bold. (b–e) correspond to the iterations of the HBX. At each iteration, the clusters of the offspring are composed of the intersections of cycles connected with red edges. For this example, the clusters of the offspring are , , , and .
Figure 1.
(a) is the bipartite complete edge-weighted graph formed by solutions s and k, where maximum weighted matching is in bold. (b–e) correspond to the iterations of the HBX. At each iteration, the clusters of the offspring are composed of the intersections of cycles connected with red edges. For this example, the clusters of the offspring are , , , and .
4.3. The Intensification Process
The intensification and evaluation phase (Algorithm 5) represents a crucial element of our approach. It uses the Lin–Kernighan heuristic through the LKH implementation and works as follows. Overall, this phase consists of two different ideas. On the one hand, the first idea is that subpaths are interchanged among the cycles. The motivation behind this idea is to explore solutions, since new cycles with different vertices are created. On the other hand, the second idea involves intensification and exploitation. The latter uses the Lin–Kernighan and the classic cheapest insertion (CI) heuristics to improve the cycles. We now describe the intensification and evaluation phase in detail.
| Algorithm 4: Balancing operator |
![Mca 31 00064 i003 Mca 31 00064 i003]() |
First, the intensification phase is executed for a predefined time
, as enforced by the while-loop in line 2. Then, the boolean function
is evaluated in line 3. This Boolean function aims to ensure the proper distribution of the LKH executions throughout the intensification phase. It determines when
should be invoked and guarantees that it is executed exactly
times during the algorithm’s execution to intensify and evaluate solution
s. For instance, if the LKH must be executed 5 times (i.e.,
) during all the intensification phase for a total time of
s, the
function ensures that
is executed at the beginning (
s), and the other times at
s,
s, and
s respectively. The fifth time will be executed after the main while-loop finishes. Subsequently, the exploration phase is initiated in lines 7 and 8. Here, two cycles of
s are chosen randomly and copied. Then, in line 9, a subpath of size
l is selected. In our proposal, we choose the value of
l as a random integer in the range of Equation (
4).
Choosing the value of l in this way ensures that at the beginning of the intensification phase, longer sizes of subpaths are selected. Then, as the intensification phase progresses, smaller values of l will be selected. In lines 10–13, random subpaths of length l are extracted from the selected cycles and inserted into each other using the CI heuristic. The CI heuristic inserts a vertex into the cycle at the position that yields the smallest possible increase in cost. Then, in lines 14–16, if the cost of the new cycles is lower, they replace the old selected cycles in s. Note that a final call to is executed after the while loop terminates, ensuring the function is invoked exactly times.
In summary, Algorithm 5 implements a two-pronged intensification strategy. First, it performs exploration by interchanging subpaths between cycles. Second, this heuristic search is periodically complemented by the Lin–Kernighan heuristic to improve the quality of the cycles. Note that executes the Lin–Kernighan heuristic over each during running time . Using the Lin–Kernighan heuristic may be computationally expensive. Thus, a small value of is recommended.
| Algorithm 5: Intensity and evaluation |
![Mca 31 00064 i004 Mca 31 00064 i004]() |