Competitive Swarm Optimizer Based Gateway Deployment Algorithm in Cyber-Physical Systems

Wireless sensor network topology optimization is a highly important issue, and topology control through node selection can improve the efficiency of data forwarding, while saving energy and prolonging lifetime of the network. To address the problem of connecting a wireless sensor network to the Internet in cyber-physical systems, here we propose a geometric gateway deployment based on a competitive swarm optimizer algorithm. The particle swarm optimization (PSO) algorithm has a continuous search feature in the solution space, which makes it suitable for finding the geometric center of gateway deployment; however, its search mechanism is limited to the individual optimum (pbest) and the population optimum (gbest); thus, it easily falls into local optima. In order to improve the particle search mechanism and enhance the search efficiency of the algorithm, we introduce a new competitive swarm optimizer (CSO) algorithm. The CSO search algorithm is based on an inter-particle competition mechanism and can effectively avoid trapping of the population falling into a local optimum. With the improvement of an adaptive opposition-based search and its ability to dynamically parameter adjustments, this algorithm can maintain the diversity of the entire swarm to solve geometric K-center gateway deployment problems. The simulation results show that this CSO algorithm has a good global explorative ability as well as convergence speed and can improve the network quality of service (QoS) level of cyber-physical systems by obtaining a minimum network coverage radius. We also find that the CSO algorithm is more stable, robust and effective in solving the problem of geometric gateway deployment as compared to the PSO or Kmedoids algorithms.


Introduction
Cyber-Physical Systems (CPSs) have great influence on the way we observe and change the world. Deploying cyber-physical systems (CPS) have emerged as a new trend in the development of industrial informatization and has attracted the attention of both academia and industry [1,2]. In a CPS, information regarding the monitoring area within a local area is acquired using a large number of micro-sensor nodes and a multi-hop, self-organizing wireless sensor network is created through wireless communication, and transport delay, data security are important topics [3][4][5]. When evaluating CPS performance, the gateway is typically the bottleneck because the majority of the network traffic converges at this point. A non-uniform service quality exists among the notes, in which the nodes that are closer to the gateway receive better service, while the nodes that are farther away receive lower-quality service. Thus, the deployment of the gateway has a great impact on the real-time performance and reliability of CPS information transmission.
The PSO algorithm is a classic intelligent optimization algorithm. Its implementation is simple and easy, as it does not require gradient information and only requires a few parameters. The characteristics of real number coding are suitable for solving continuous optimization and other problems. However, PSO is prone to trapping in a local optimum and many strategies have been proposed in order to improve this, including addressing the inertia weight, an asynchronous time-varying learning factor, and the development of a PSO with a contraction learning factor and domain topology [21,22]. These improvements shown, however, have not been particularly satisfactory. In the study described in reference [23], the individual optimum pbest and population optimum gbest in the PSO algorithm were eliminated, and a competition mechanism was introduced into the particle swarm, which essentially changed the particle search mechanism: in short, a competition-based CSO (competitive swarm optimizer) algorithm was proposed in an effort to effectively avoid precocious particles and local optimum trapping, as well as to lower the computation cost. This paper adopts a novel CSO algorithm in order to solve the problem of WMN gateway deployment.

CPS WMN Gateway Deployment Model
CPS obtains the information of the physical world through many sensors and impacts the environment by actuators. Wireless networks have been widely used in cyber-physical systems (CPS) for data transmission. A CPS usually contains lots of sensors, and these sensors generate massive data. A number of special nodes must be utilized as the network gateway, collecting information acquired by the wireless sensory network and gaining access to the Internet, in order to achieve cross-region information acquisition, and WMN is a feasible wireless network architecture. Figure 1 shows a gateway deployment diagram that includes the entire network transmission model, consisting of sensor nodes, routing nodes and gateway nodes. The sensor nodes are used to sense environmental information, the routing nodes are used to forward information sent between nodes, and the gateway nodes are used to access the Internet. The network characteristic is that most of the traffic converges on the gateways. The service quality is better for nodes closer to the gateway node; however, for nodes far from the gateway node, the quality of service is poor. In other words, the quality of service is not equally distributed between nodes. Therefore, the gateway nodes often become the bottleneck of network performance, and whether the deployment of the gateway nodes is reasonable has a large impact on network performance.

Sensor
Router Gateway A WMN is a self-organizing multi-hop mobile network in which the maximum communication coverage of an access point (AP) node is limited by the node's transmission power. Thus, it is a circle with a fixed radius. AP nodes within the coverage radius are connected with one hop, forming a multi-hop network topology. The distance between a gateway and its farthest AP node has a great impact on network communication quality. The main goal of WMN gateway deployment is to maximize a network's communication quality by adjusting the gateway location.
WMN topology can be represented by G(V, E), and all AP nodes in the network can be represented using a point set V(G). If the coordinates of a node v i are (x i , y i ), in which l ij = (x i − x j ) 2 + (y i − y j ) 2 , then when the distance between any two nodes is no greater than r, namely, when l ij ≤ r, v i and v j can be considered as adjacent nodes. The connection between any two adjacent nodes in the network is an undirected edge whose weight is set to 1. Adjacent nodes are thus said to be connected by one hop. All inter-node edges constitute the edge set, E(G), of graph G.
A WMN must establish a gateway in order to provide service for all of the AP nodes. The service gateway for each AP node is then chosen based on which gateway is the closest i.e., is the fewest number of hops away. If it is assumed that all of the k gateway nodes have been selected in a network (G) of size n, G's adjacency matrix is A = {e ij } n×n , where e ij ∈ E(G), and the shortest distance matrix is D = {d ij } n×n , in which d ij is the minimum number of hops from node v i to node v j . If d(v i , u j ) ≤ d(v i , u l ), j, l ≤ k, l = j, then the AP node v i will choose gateway u j as its service gateway. Therefore, the service set of gateways, u j , includes v i , namely, v i ∈ U j . Th maximum distance between u j and the nodes in its service set U j is max , which is referred to as the coverage radius of gateway u j . The maximum coverage radius of a gateway node, max , is called the coverage radius of the gateway set {u i } k , also known as the hop from the AP nodes to the gateway set.
The smaller the coverage radius of a gateway set is, the higher the quality of service the AP nodes will obtain. Therefore, the coverage radius of a gateway set is an important evaluation index for gateway deployment. The goal of WMN gateway deployment optimization is to minimize the coverage radius of a gateway set, that is, to minimize the path length. The model is as follows: where R 2 is the two-dimensional plane in which graph G is located.

Geometric K-Center Problem of WMN Gateway Deployment
There are two types of CPS WMN gateway deployment options: one is to choose the gateway from the K nodes in the existing network, which is referred to as the vertex K-center problem; the other option is to choose gateway nodes K positions from the plane in which the nodes are located, and these K gateway nodes are not necessarily existing network nodes, which is referred to as the geometric K-center problem. The former has a poor performance but is simple and easy to implement, while the latter performs better but is difficult to solve.
There are two types of CPS WMN gateway deployment: one is to choose K nodes from the existing network nodes to act as the gateways, called the vertex K-center problem. The other is to choose K positions from the plane in which the nodes are located to deploy gateway nodes, where these K gateway nodes are not necessarily existing network nodes, called the geometric K-center problem. The former is simple and easy to implement but results in poorer performance, while the latter performs better but is difficult to solve. Figure 2A is a 7-node network topology, in which the node degree is 2. The network forms a connected closed loop, and the node's maximum coverage is a circle with a fixed radius. The weight of any given edge is set to be the number of hops between the gateway and the node. Figure 2B shows the gateway deployment method based on the vertex K-center problem, in which an AP node is selected from V(G) as a gateway, and the global optimal coverage radius is 3. Figure 2C shows the gateway deployment method based on the geometric K-center problem, in which a suitable location on the plane is chosen to place the gateway, and the coverage radius drops to 2.

AP Node
Gateway Node The number of gateways deployed for the topology shown in Figure 2A is two. When the vertex K-center deployment approach is used, as shown in Figure 3A, the coverage radius for the network is two. When the geometric K-center deployment approach is used, as shown in Figure 3B, the gateway is deployed at the geometric center and the coverage radius drops to one.

AP Node
Gateway Node According to the above analysis, the vertex K-center problem, which is simple and easy to implement, involves deploying each gateway at a WMN node; the geometric K-center problem involves deploying each gateway anywhere in the network plane, the flexibility in terms of gateway location can thus, theoretically, be used to achieve a global optimum.

CSO-Based Geometric K-Center Gateway Deployment in CPS
The PSO algorithm is a stochastic search and intelligence heuristic algorithm, which can search extremums in continuous high dimensional space, and has a balanced spatial and local search ability, which is fast and not easy to fall into the local optimal solution, so it is very suitable to use when solving the problem of WMN gateway deployment. However, because its search mechanism involves constant updates regarding the particles' position and speed according to the individual optimum (pbest) as well as the population optimum (gbest), it is computationally expensive and is prone to falling into local optima and premature convergence. In order to address this issue, a competition mechanism can be used in order to update the particles instead of using the individual or population optimum [6]. Therefore, in this study, a competition-based CSO algorithm is adopted in order to solve the geometric K-center gateway deployment problem in a WMN.

Search Mechanism of the CSO Algorithm
A swarm of n particles flying in an m-dimensional space and searching for an optimum can be randomly divided into n 2 pairs, assuming that n is an even number, at any point in time. Subsequently, competition exists between the two particles in the same pair and the particle that is fitter wins. The winner maintains its state and directly enters the next moment; the loser learns from the winner, updating both its position and speed, and then moves on to the next moment. In summary, at any point in time, each particle participates in the competition once, and n 2 particles will update their position and speed. The CSO algorithm, as compared to the PSO algorithm, reduces the computational cost. A schematic of the algorithm's search mechanism is shown in Figure 4.  calculate the fitness of all particles in P(t); 4: L = P(t), P(t + 1) = ∅;//L denotes a set of particles that have not yet participated in a competition. 5: while L = ∅ do 6: randomly choose two particles X 1 (t), X 2 (t) 7: if f (X 1 (t)) ≤ f (X 2 (t)) then// f (X 1 (t)) is the fitness function for X 1 (t) 8: X w (t) = X 1 (t), X l (t) = X 2 (t); // X w (t) is the winner particle in generation t, and X l (t) is the loser particle in generation t 9: else 10: X w (t) = X 2 (t), X l (t) = X 1 (t); 11: end if 12: add X w (t) into P(t + 1); 13: update X l (t) using (1) and (2) 14: add the updated X l (t) into P(t + 1); 15: remove X 1 (t), X 2 (t) from L 16: end while 17: end for

Encoding of the CSO Algorithm
The position of the ith particle in the CSO algorithm can be written as X i = (x i1 , x i2 , . . . , x im ). When solving a geometric K-center problem, the position of a particle in the CSO algorithm represents a set of solutions to the WMN gateway deployment problem, coded as the combination of the coordinates of K gateways' in plane R 2 . The positions of the gateways' are as follows: (a 1 , b 1 ), (a 2 , b 2 ), . . . , (a j , b j ), · · · , (a K , b K ), in which a j = x 2j−1 , b j = x 2j and m = 2K. The flying speed of the ith particle is S i = (s i1 , s i2 , · · · , s im ).

Dynamic Equations of the CSO Algorithm
In each iteration of the CSO algorithm, the particles' speeds and positions are updated to search for a better solution using a competition mechanism. The position of the winner of the gth pair at time t is X w,g (t), and its speed is S w,g (t), where g = 1, 2, . . . , n 2 . The loser's position and speed are X l,g (t) and S l,g (t), respectively. For the gth pair at time t, the position of the loser is updated according to Equation (1), and its speed is updated according to Equation (2), in which r 1 , r 2 , and r 3 are random numbers in [0, 1] m . X(t) is calculated as follows: X l,g (t + 1) = X l,g (t) + S l,g (t + 1).
(2) X(t) is the average position of the population at a given time, and ξ is used as a parameter to control X(t) and to increase the diversity of the population. The position of the particles that have lost the competitions adjusted towards the position of the particles that won, so that each particle reaches an optimal position. The particles that have won the competition maintain their positions and speed and directly enter the next stage.

Fitness Function Design in the CSO Algorithm
In the geometric K-center WMN gateway deployment problem, a decreased fitness value is indicative of better particles, and the fitness is determined by the coverage radius of the particle. A particle in the CSO algorithm is a combination of the position coordinates of K gateways. Considering that the particles can be placed in any position of the plane, calculating the distance from the particle to the AP node is difficult; the following method can be used.
The position of the kth gateway, u k , of the particle is (a k , b k ), where k = 1, 2, · · ·, K. Nodes with a distance of u k less than the communication distance (r) form a set, referred to as the adjacent node set, The coverage radius of a particle, i.e., the fitness of the particle, is F = max 1≤i≤n min 1≤k≤K (d(v i , ADJ k )) + 1.

Solving the Gateway Location Problem Using the CSO Algorithm
In the CSO algorithm, particles are randomly generated at the beginning, with the coverage radius of the particle representing its fitness. The fitness of the particles is evaluated after each iteration, and the particles are then randomly paired for competition. The position of the particles that lose the competition is adjusted towards the position of the winning particles by changes made to their flying speeds and positions. Neither the position nor the speed changes for any of the winning particles and they directly enter the next iteration. When a fixed number of iterations have been completed, the algorithm will stop. The steps to solve the WMN gateway deployment problem using the CSO algorithm are as follows: Step 1. A particle swarm of size n, including the positions X i and speeds S i , is randomly generated within the effective area of the network graph in order to determine the value of ξ. Step 2. Calculate the fitness of each particle, i.e., the coverage radius R.
Step 3. Randomly divide particles into n 2 groups. Two particles then compete against each other in each group, and the fitness of each particle is taken as the criterion for the outcome of the competition. The fitter particle is deemed the winner, while the other is the loser.
Step 4. Update the position and speed of the particles that lost the competition according to Equations (1) and (2). The winners retain their position and speed.
Step 5. Decide whether the termination condition of the algorithm is satisfied. If it is satisfied, stop the iteration and output the optimal solution. Otherwise, return to Step 2. The termination condition of the algorithm is to reach the maximum number of iterations.

Simulation Analyses
The platform used for the simulation in this section of the experiment was Matlab2012 running on a quad-core computer with 4 GB of memory and a 3.4 GHz CPU. Four random networks (50, 200, 600 and 1000 nodes) were used to simulate a WMN. All the random networks were connected, and the node degree of the networks was between 1 and 11. The experiment aimed to minimize the coverage radius using the CSO, PSO and Kmedoids algorithms at different network scales. Twenty independent experiments were conducted for each simulation, and the best, worst, mean and standard deviation of the coverage radius were recorded for each experiment. The stability of each algorithm was also analyzed. The maximum degree of the graph is set to 11, and the minimum degree is 1. Each graph is connected. These four graphs span a large size range and are good data sets for testing the algorithms. In this paper, these four datasets were used to test the optimization performance of the CSO, PSO and Kmedoids algorithms.

Analysis of the Algorithms' Optimization Performance and Convergence
The optimization results of the CSO algorithm, PSO algorithm and the Kmedoids algorithm for random WMNs comprised of 50, 200, 600 and 1000 nodes are shown in Table 1. The number of gateways was fixed at 5. The maximum, minimum, mean and standard deviation of the coverage radii in 20 independent experiments using the three heuristic algorithms are provided.
According to the results in Table 1, the CSO algorithm was shown to achieve a better maximum, minimum, and mean value when compared to the results obtained using the PSO algorithm and the Kmedoids algorithm. The standard deviation of the CSO algorithm was small, and the algorithm was stable. The CSO algorithm and the PSO algorithm both use similar mechanisms: they both find the optimal solution by particle searching in a continuous space, while the Kmedoids algorithm searches for the optimal solution among existing network nodes. The optimization performance of the Kmedoids algorithm was shown to be inferior to that of the CSO algorithm and PSO algorithm.
There are some differences in the search mechanism between the CSO algorithm and the PSO algorithm. The PSO algorithm updates the position and speed of the particles using the individual optimum (pbest) and the population optimum (gbest). Thus, all of the particles will be updated and moved towards a more optimal position. However, the population is prone to premature convergence. In contrast, when using the CSO algorithm, the individual optimum and the population optimum are discarded, and a competition mechanism is used instead: the losing particles learn only from the winning particles, effectively preventing local optimum trapping and, when compared to the PSO algorithm, this method effectively reduces the computation cost by only updating half of the particles in each iteration. The average number of hops decreased as the number of iterations increased, as shown in Figure 6. After a certain number of iterations, the average number of hops tended to stabilize. When comparing the convergence of the three algorithms, the PSO algorithm and the Kmedoids algorithm were shown to converge prematurely and were prone to local optimum trapping. The CSO algorithm maintained the diversity of the population through the use of a competition mechanism, thus resulting in a longer convergence process that could effectively prevent local optimum trapping. Therefore, the CSO algorithm was shown to have a better performance in regards to solving the geometric K-center gateway deployment problem.
If the number of gateways is fixed, the gateway deployment performance graph does not show a significant improvement with an increasing network size. In the current study, networks comprised of 50 and 200 nodes were used to compare the performance of the algorithms. A total of five gateways were used. The first row in the figure represents the deployment performance of the three algorithms when the network size is 50 nodes; the second row represents the deployment performance when the network size is 200 nodes. The different colors in the figure represent different groups. The star symbol represents the gateway node, and the remaining symbols represent the AP nodes. Figure 6 shows that the average number of hops decreased as the number of iterations increased; however, beyond a certain number of iterations, the average number of hops tended to stabilize. This comparison of the convergence of the three algorithms indicates that the PSO algorithm and the Kmedoids algorithm converged prematurely and were prone to local optimum trapping. The CSO algorithm ensured the diversity of the population through the competition mechanism. Consequently, its convergence process lasted longer and effectively prevented the population from becoming trapped in a local optimum. Therefore, the CSO algorithm showed better performance in solving the geometric K-center gateway deployment problem.
When the number of gateways is fixed, the gateway deployment performance graph does not show significant improvement as the network size increases. This paper used networks of 50 and 200 nodes to compare the algorithms' performances with five gateways. The first row in Table 1 represents the deployment performance of the three algorithms with a 50-node network; the second row represents the deployment performance with a 200-node network. The different colors in the figure represent different groups. The star symbol represents gateway nodes, and the remaining symbols represent AP nodes.  Figure 7 shows that the Kmedoids algorithm set up the gateways at client nodes while the CSO and PSO algorithms set the gateways at R 2 , located in the geometric centers of the network diagram, and the number of AP nodes served by each gateway was relatively uniform, producing a relatively small coverage radius and balanced load among gateways.

Optimization Results of Algorithms with Different Numbers of Gateways
In this section, networks of 200 and 1000 nodes were taken as being representative of small-and large-scale networks. Figure 8 shows the performance of the CSO, PSO and Kmedoids algorithms when varying the number of gateways used for these two different random networks. Each experiment was independently run 20 times. The experimental results shown are the average of the 20 independent tests of each algorithm.  The above experimental results indicated that the coverage radius decreased as the number of gateways increased. For a fixed number of gateways, the coverage radius of the CSO algorithm was better than that of the PSO algorithm and Kmedoids algorithms. The CSO algorithm and PSO algorithm can be used to solve the geometric K-center gateway deployment problem, and their gateways are usually located at the center of multiple non-adjacent nodes, with a greater node degree. These two algorithms can shorten the routing distance between AP nodes and reduce the coverage radius of the network. The Kmedoids algorithm is suitable for solving the vertex K-center problem of WMN gateway deployment, where the gateway is selected from existing AP nodes. The analysis indicated that, from the perspective of coverage radius, the geometric K-center method performed better than the vertex K-center method in gateway deployment.

Conclusions
This study investigated the geometric K-center WMN gateway deployment problem in a CPS, or, more specifically, how to appropriately deploy gateways in a given geometric plane and reduce the routing distance from the AP nodes to the nearest gateway in order to improve the communication quality of the entire network. To address this problem, the target of optimization was the minimum coverage radius, which was solved using a new CSO algorithm. According to the experimental results, the CSO algorithm was shown to solve the geometric K-center problem of a WMN very well, providing a good solution to the geometric K-center gateway deployment.