HYBRIDIZATION OF PARTICLE SWARM OPTIMIZATION AND SIMULATED ANNEALING FOR MAXIMUM PARTITION PROBLEM

The maximum partition problem (MPP) is to divide the set of nodes in directed weighted graph into two disjoint subsets such that the sum of weights of edges crossing from one subset of the partition to the other is maximized. The MPP is NP-hard. Hence, this paper presents a hybrid discrete particle swarm optimization (DPSO) simulated annealing (SA) algorithm to solve MPP. The proposed algorithm first applies DPSO to the problem until improvement in fitness slows down (stagnates). Then, the algorithm uses SA augmented with a heuristic method to improve the fitness of the solution obtained from DPSO. Experiments on randomly generated graphs of different size show that the proposed algorithm produces better partitions than conventional DPSO. Additionally, the proposed algorithm converges to near optimal solutions faster than conventional DPSO.


INTRODUCTION
The maximum partition problem (MPP) of a directed weighted graph with a set of nodes N and a set of edges E is to divide the set of nodes N into two nonempty disjoint subsets N0 and N1 such that the sum of the weights of edges that connect a node in N0 to a node in N1 is maximized. As an example, Fig. 1 shows a weighted directed graph (a) and its maximum partition (b). This partition can be expressed as a pair (N0={c, d}, N1={e, f}). The sum of the weights of edges that cross from N0 to N1 in this example is 22. MPP applications include data clustering where a set of objects needs to be separated into classes such that the distance (dissimilarity) between objects in different classes is maximized [1][2][3]. Another application of MPP is in text compression that supports direct search in compressed data [4]. In this application, nodes in the graph represent characters and the weight of an edge from character x to character y represents the number of occurrences of the string xy in the text that is being compressed. The maximum partition of the set of characters is used to find the pairs of characters that occur consecutively the most in the text. Compression is achieved by coding such pairs using single unused characters in the text.
The MPP problem is NP-hard problem with a large search space. For a directed graph with n nodes, the number of possible partitions is This is the number of subsets of the set of n nodes excluding the empty set and the set itself.
These two subsets are excluded from possible partitions because they assign all nodes to one side of the partition and result in no edge crossing between the two sides of the partition; the total weight of crossing edges is zero. 2060 WAEL MUSTAFA Existing methods [6][7][8] to solve the MPP, known as heuristic or approximate methods, are often efficient with respect to execution time, but they do not guarantee an optimal solution. These methods suffer from the local maximum problem where a good solution is reached that is better than the neighboring solutions, but is not better than a global optimal solution. Discrete particle swarm optimization (DPSO) have been widely used to solve combinatorial problems effectively [9][10][11][12].
DPSO converges to a good solution for MPP in a relatively short time. However, solutions obtained from DPSO alone are often not optimal and these solutions can be improved further using simulated annealing (SA) which has the ability to escape a local maximum solution. This is achieved by accepting moves that result in slightly worse solutions. After accepting a bad move, SA often recovers from the move and has a good chance of reaching better solutions later. This paper presents a hybrid DPSO-SA algorithm to solve the MPP. The proposed algorithm consists of two phases. First, DPSO executes until improvement in fitness slows down. Then, SA starts and continue on improving the solution produced by DPSO. The SA phase in the proposed algorithm is augmented with a heuristic method that moves nodes between two sides of the partition to improve fitness further.
The remaining sections of this paper proceed as follows. Section two reviews algorithms related to the proposed algorithm. Section three formulates the MPP problem and discuses concepts and parameters needed to solve MPP using DPSO and SA. Section four presents the proposed algorithm and section five discuss the results of the algorithm. Finally, section six concludes the paper and suggests future work.

BACKGROUND
This section describes the algorithms that are used in the proposed hybrid algorithm.

Particle Swarm Optimization
The basic particle swarm optimization (PSO) mimics the collective behavior of a group of birds searching for food location [13][14][15]. To solve a particular problem, a population of random 2061 MAXIMUM PARTITION PROBLEM solutions, called particles, is first created. The set of all particles is called swarm. The algorithm searches for a high-quality solution by updating particles over generations. In PSO, each particle has current location, fitness, velocity, local best location, and global best location. Fitness of a particle, which represents the quality of solution, is computed using certain objective function that is usually problem dependent. The local best of a particle is the best location the particle encountered so far during execution while global best is the best location found by the entire swarm so far.
In basic PSO, each particle X at iteration i has a location vector Xi= (x1i, x2i,…, xni), and also has a velocity vector Vi=(v1i, v2i, ..,vni), where n is usually the number of variables of the continuous function being optimized. The velocity vector components are real numbers within a limited range.
The velocity vector determines the movement of the particle in the next iteration of the algorithm.
At each iteration, velocity is updated and used to update the position of the particle using the two equations: Where r1 and r2 are two random variables in the range of zero to one, c1 and c2 are positive constants that control how how much the particle moves in the direction of local best and global best, respectively. The component c1r1 (local_best -Xi) is known as personal influence which moves the particle in the direction of local best, while c2r2 (global_best -Xi) is known as social influence which moves the particle in the direction of global best solution.

Discrete Particle Swarm Optimization
The basic PSO has been found to be efficient in optimizing continuous functions in various domains. However, many practical problems, such as MPP, travelling salesman, and N-queens are combinatorial optimization problems that involve optimizing discrete functions. The work in [16] presented a discrete binary version of PSO (DPSO) for such problems. As in basic PSO, a particle has a location and velocity. However, in DPSO location is a vector of bits and every bit has a velocity that determines the probability of the bit being set to one or zero. In DPSO, higher velocity 2062 WAEL MUSTAFA increases the chances of bit to be set to one, while lower velocity increases the chance of the bit to be set to zero. Like the basic continuous PSO, the formula used to compute the velocity of a bit at the next iteration in DPSO is Where c1 and c2 are small constants. Local_best, global_best, and Xi are all vectors of bits. In [16], the authors suggest that velocity range to be between -6 and +6. After computing the velocity of a bit b in a particle, the value of b in the next iteration is determined as follows: where Sig is the sigmoid function, defined as Sig(x)= 1/(1+e -x ), and rand() is a random number between zero and one. For a bit with high velocity v, Sig(v) is closer to one and the bit will likely to be one in the next iteration. On the other hand, for a bit with low velocity v, Sig(v) is closer to zero and it is likely that the bit to be zero in the next iteration.

Simulated Annealing
The concept of annealing in combinatorial optimization was introduced in [17] and has been used in the optimization of various combinatorial problems [18][19][20][21][22][23]. This concept is based on a strong analogy with the physical annealing of metal objects. This process can be summarized by the following two steps: bring the solid metal object to a very high temperature until melting; then cool the object according to a specific temperature decreasing schedule to reach a solid state of a desired shape. When used in optimization, the algorithm usually starts from a random state representing a solution attempt and improves the quality of the current solution (state) by moving to a better neighboring state. When this process is repeated, the algorithm often results in highquality solutions. In the remainder of this paper, the two terms solution and state are used interchangeably.
A basic characteristic of SA algorithm is its ability to accept, with some computed probability, moves to less desired states. The probability of accepting such moves depends on e /temp , where e=2.178, temp is the current temperature, and  is a negative value representing the difference between current and successor state fitness. Higher temperature values increase the probability of 2063 MAXIMUM PARTITION PROBLEM accepting bad moves while higher || values decrease the probability of accepting bad moves.
In the early stages of SA, the temperature is usually set high. This increases chances of the SA algorithm to accept moves that worsen the current solution. Through accepting bad moves, SA algorithm often avoids local maximum's and explores the search space more thoroughly. As the temperature decreases while the algorithm executes, the algorithm tends to accept only moves that improve the current solution. Near the end of execution, the temperature becomes usually near zero and no move that results in a worse solution than the current solution is accepted. Fig. 2 contains the general framework of the SA algorithm.

PROBLEM FORMULATION
This section formulates the concepts and operations used in applying DPSO and SA to the MPP. This includes defining: state, particle, neighboring states, successor operation, and fitness function. In SA, the successor operation takes a partition represented by a tuple of bits and returns a neighboring partition by complementing one of the bits in the tuple. Hence, a partition represented by an n-tuple has n possible successors.
The fitness of either a partition, a state, or particle is the sum of the weights of directed edges that leave N0 to N1. For a partition p= (b1, b2, …, bn), the fitness is computing using the formula

THE HYBRID ALGORITHM
The proposed hybrid algorithm is shown in Fig. 3. The DPSO is implemented in lines 2-35. Lines 2-4 initialize the M particles (swarm) with N random bits in each particle, where N is the number of nodes in the graph. Lines 5-7 initialize the velocities of the bits in the particles to real numbers in the range -V_MAX to +V_MAX. Lines 8-14 initialize the local best for the particles. Line 15 initializes the global best particle to the particle with highest fitness in the initial random swarm.   Since the SA goal is to improve the fitness of the near-optimal state produced by DPSO, SA needs a maximum temperature that results in a low probability of accepting bad moves. Through experimentation with a large number of graphs of various size, this low probability is about 0.25. This low probability discourages SA from accepting bad moves and increases the chances of maintaining the current good partition or improving it further.
The probability of moving to a worse partition is implemented in SA using e /temp , where  is the difference in fitness between current partition and its successor, and temp is the current 2067 MAXIMUM PARTITION PROBLEM temperature. So, in order to have the probability of moving to a worse partition in the early stages of SA to be about 0.25, we need e /temp_max  0.25, which is equivalent to

RESULTS AND DISCUSSION
To compare the performance of conventional DPSO algorithm with the proposed hybrid DPSO-SA algorithm, the two algorithms were implemented as functions in a single program in visual C++ 2019. Conventional DPSO was implemented based on the parameters shown in Table   1 and the proposed hybrid DPSO-SA algorithm was implemented based on the parameters in Table   2. The resulting code was executed on an HP computer with an i7 CPU, running Windows 10; 2.2 GHz speed; and an eight GB of main memory. Each algorithm was applied to 25 directed graphs Gi, 1<=i<=25. Graph size starts at 100 nodes, increases by 100, until it reaches 500. The 25 graphs are distributed equally over the mentioned sizes; 5 graphs per each size. All of the graphs are complete; for every two different nodes x and y, there is a directed weighted edge from x to y and there is another directed weighted edge from y to x. For example, graph G25 has 500 nodes and 500*499 edges.  To ensure better randomness of the weights in the graphs and to obtain reproducible results, weights in each graph are based on a different seed; weights in graph Gi, 1<=i<=25, are obtained by first calling seed(i) C++ function, and then calling rand() function to generate the weights themselves. The range of random weights in the graph is restricted to be from 0 to 100 to avoid an extremely large sum of weights (fitness); a complete graph of 500 nodes has about 250,000 directed edges and the max fitness value is 25,000,000. Increasing the maximum weight limit results in fitness values that are too large to store using unsigned long long in C++. The

CONCLUSION AND FUTURE WORK
This paper presented a hybrid algorithm to solve the MPP. The hybridization is implemented by performing simulated annealing on the result of applying discrete particle swarm optimization to MPP. Experiments on random graphs with different size show that the proposed algorithm produces better partitions than conventional DPSO. Furthermore, the proposed algorithm converges faster to near optimal solutions than conventional DPSO.
Future work includes quantifying the relation between graph size and the most appropriate stagnation index value. Another future work, is to extend the proposed algorithm to deal with partitioning into more than two disjoint subsets, apply the resulting algorithm to data clustering and compare the quality of the resulting clusters against exiting methods.

APPENDIX A.
Results of applying conventional DPSO and hybrid DPSO-SA to 25 random graphs. On each graph, the hybrid DPSO-SA is performed three times using stagnation index values 10, 20, and 30.