A Compact Bat Algorithm for Unequal Clustering in Wireless Sensor Networks

: Everyday, a large number of complex scientiﬁc and industrial problems involve ﬁnding an optimal solution in a large solution space. A challenging task for several optimizations is not only the combinatorial operation but also the constraints of available devices. This paper proposes a novel optimization algorithm, namely the compact bat algorithm (cBA), to use for the class of optimization problems involving devices which have limited hardware resources. A real-valued prototype vector is used for the probabilistic operations to generate each candidate for the solution of the optimization of the cBA. The proposed cBA is extensively evaluated on several continuous multimodal functions as well as the unequal clustering of wireless sensor network (uWSN) problems. Experimental results demonstrate that the proposed algorithm achieves an e ﬀ ective way to use limited memory devices and provides competitive results. Experimental results demonstrate that the proposed algorithm achieves the e ﬀ ective way of using limited memory devices, and provides competitive results.


Introduction
The metaheuristic algorithms have emerged as a potential tool for solving complex optimization problems. The bat algorithm (BA) is a novel metaheuristic search algorithm [1,2], which simulates the behavior of the bat species for searching prey. Preliminary studies show that it is very promising and could outperform existing algorithms [3]. The BA utilizes a population of bats to represent candidate solutions in a search space and optimizes the problem by iteration to move these agents to the best solutions about a given measure of quality. The general steps of this algorithm are described in the next section.
The original BA is able to solve problems with continuous search space, and in addition, several versions of the algorithm are also proposed in the literature to solve problems with continuous and discrete search spaces. The evolved bat algorithm (EBA) is used for numerical optimization and the economic load dispatch problem [4,5]. A hybrid between the BA and the artificial bee colony (ABC) is used for solving numerical optimization problems [6]. Several discrete BAs have been proposed in the literature, in addition to the continuous BAs. A binary BA (BBA) was proposed to solve the feature selection problem [7], and its solution is restricted to a vector of binary positions using a sigmoid function. The BBA algorithm uses a V-shaped transfer function to map velocity values to probability values in order to update the positions [8]. This BBA has been used in several tasks, e.g., it was adopted data to the BS. This disrupts the network connectivity, and the clusters close to the BS cause coverage issues that are called hot spot problems. The unequal clustering technique is one of the most efficient ways to deal with hot spot problems because it can be used for load balancing among the CHs [30].
The purpose of the unequal clustering method is the same as the equal clustering approach with adding functions. The clustered nodes are in WSN for different meanings based on the application demand. Energy saving and preventing hot spot problems are the major objectives. Unequal clustering arranges the clusters according to size with the size reduced closer to the BS. This means that the cluster size is directly proportional to the distance of the CHs from the BS. A smaller cluster near the BS indicates a smaller number of cluster members and less intra-cluster traffic. Therefore, the smaller clusters can concentrate more on inter-cluster traffic, and the cluster head does not drain out of energy as quickly. The more the distance to the BS increases, the more the cluster size increases. If the groups hold a more significant number of member nodes, they will spend more energy on intra-cluster traffic. As the clusters become farther from the BS, they have less inter-cluster traffic and do not need to expend more energy for inter-cluster routing. Unequal clustering forces all the CHs to spend the same amount of energy consumption, and therefore the CHs near the BS and the CHs farther from the BS consume an equal amount of energy.
Additionally, the cluster formation process may generate a two-level hierarchy with higher and lower levels [31,32]. The CH nodes form the upper-level cluster, and the member nodes create the lower level. The sensor nodes periodically transmit their data to the corresponding CH. The CHs aggregate the data and transmit them to the BS either directly or through the intermediate CH nodes. The CH performs data aggregation of all data received from its cluster members and forwards the aggregated data to the BS via a single hop or a multi-hop. The CH contains the information of its cluster members such as node id, location, and energy level. When a node dies or moves to another cluster, the changes are registered immediately and the CH informs the BS and reclustering occurs to maintain the network topology effectively. The number of transmissions and also the total load of the network are significantly reduced.

Energy Consumption in WSNs Model
Unequal clustering in a WSN with hundreds or thousands of sensor nodes is an efficient way to organize such a vast number of nodes, uniformly distribute load, and prevent hot spot problems [33]. However, the equal clustering approach often has cluster size which is the same throughout the network. Admittedly, in unequal clustering, the cluster size is determined based on the distance to the BS. The cluster size is smaller when the distance to the BS is shorter, and the size increases as the distance to the BS increases.
The wireless radio transceiver in a WSN depends on the various parameters, e.g., distance and energy consumption. The definition is related to the power consumption and the ranges of the nodes referred to in [16]. The distance between the transmitter and receiver obeyed on the attenuated trans-receiving power decreases exponentially with increasing distance. A threshold separates the free space model and the multipath model.
where ε f s , ε mp are power loss for free space and multipath models, respectively, and d 0 is a threshold of space model. The transmitting l bits for dissipated energy over distance d is formulated as: Appl. Sci. 2019, 9, 1973 4 of 18 where E is the power consumption of the node, Tx is for transmitting subscript elec, amp indicate electronic, and amplify for digital coding, modulating, filtering, and spreading signal. The energy consumption for receiving the messages can be expressed as: WSN assumed implemented N nodes in the two-dimensional area of M 2 with k clusters. Let d be the distance member node to the CH, and D be the distance of the CHs to the BS. The consumed energy of a cluster for a data frame is modelled as: where N/k − 1 is the averaged member nodes in a cluster. E CH and E members are the dissipated energy for CH and members. The calculated energy consumptions for cluster members and CHs are as follows: The total consumed energy for a WSN could be formulated from the energy process and power transceiver as: where E p is the power consumption of the microcontroller. It does not affect the optimizing processes. Thus, the power consumption of E f rame optimized is based on only the distance for clustering optimization.

Compact Bat Algorithm
The compact approach reproduces the operations of the population-based algorithms by building a probabilistic model for a population solution. The optimal process considers the actual population as a virtual community by encoding its probabilistic representation. The compact BA is constructed based on the framework of the BA. Before analyzing and designing the compact for BA, we review the bat-inspired algorithm in the following subsection.

Bat-Inspired Algorithm
A recent new population-based algorithm, BA [1] has drawn inspiration from the bat's echolocation of the species called the microbats for searching prey. The updated solutions of BA are constructed based on three primary characteristics including echolocation, frequency, and loudness. Bats use echolocation to locate the prey, background frequency to send out the variable wavelength, and loudness to search the victim. Solutions for the BA are generated by adjusting parameters, e.g., frequencies, loudness, and pulse emission rates of the bats, according to the evaluation of the objective function. Formulas for updating the positions and velocities of BA in d-dimensional search space are as follows: where f i is the frequency for adjusting velocity change, f min and f max the minimum and maximum frequency of the bats emitting the pulse, respectively, and β is a generated vector randomly based on the distributed Gaussian ∈ [0, 1]. A frequency assigned initially for each bat in a uniform range ∈ [ f min , f max ]. BA updates the vectors of the bat locations and velocity x, and v in search space of d-dimensional.
Appl. Sci. 2019, 9,1973 5 of 18 where the superscript of t is the current iteration, and x best is the global best solution. Generating new location of the bats in exploiting phase strategy is formulated as: where ε is a random variable in the range ∈ [−1, 1], and indicates the weight for the loudness of the bats at the current generation. The loudness of bats A is defined as: where α is a variable constant. The symbol denotes the rate of the pulse emission r and ∈ [0, 1]. The pulse emission rate is calculated as: where γ is the constant variable. In the process, this rate r is considered as the control to switch the global and local search. If a random number is greater than r, a local search with a random walk is triggered.

Compact Bat Algorithm
The intention of the compact algorithm is to mimic the operations of the based-population algorithm of BA in a version with a much smaller stored variable memory. The actual population of solutions of the BA is transformed into the compact algorithm by constructing a distributed data structure, namely the perturbation vector (PV). PV is the probabilistic model for a population of solutions.
where δ and µ are two parameters of standard deviation and mean of vector PV, and t is the current time. The values of δ and µ are arranged within the probability density functions (PDF) [34] and are truncated in [−1, 1]. The amplitude of PDF is normalized by keeping its area equal to 1 because by obtaining approximately sufficient in well it is the uniform distribution with a full shape. A real-valued prototype vector is used to maintain sampling probabilistic for randomly generating components of a candidate solution. This vector operation is distributed-based on the estimated distribution algorithm (EDA) [35]. Because a few new generating candidates are stored in the memory, it is not all of the population of solutions stored in memory. The likelihood is that the estimated distribution would trend, driving new candidate forward to the fitness function. Candidate solutions are generated probabilistically from the vector, and the components in the better solution are used to make small changes to the probabilities within the vector. A candidate solution x i corresponding to the location of the virtual bats is generated by PV(µ i , δ i ).
where P(x) is the probability distribution of PV that formulated a truncated Gaussian PDF associated with the µ and δ. A new candidate solution is generated by being iteratively biased toward a promising area of an optimal solution. We can obtain each component of the probability vector by learning the previous generations. The er f is the error function found in [36]. PDF corresponds to the cumulative distribution function (CDF) by constructing Chebyshev polynomials [37]. The codomain of CDF is arranged from 0 to 1. The CDF can describe the real-valued random variable x with a given probability distribution, and the obtained value can be less than or equal to x i . CDFs also can specify the distribution of multivariate random variables. Thus, the relationship of PDF and CDF can be defined as CDF = 1 0 P(x)dx. PV performs the sampling design variable x i by generating a random number in a range of (0, 1). This corresponds to obtaining this variable by computing the inverse function of x i set to inverse (CDF).
To find the better individual in the process of the compact algorithm, a comparison of the two design variables is conducted. The two variable agents of the bats are two sampled individuals who performed from PV. The "winner" indicates the vector with the fitness scores that are higher than other members, and the "loser" is shown according to the individual lower fitness evaluation. The two returned variables, winner and loser, are from objective function evaluation that compare a new candidate with the previous global best. For updating PV, µ and δ are considered based on the following rules. If the mean value of µ is regarded to 1, the update rule for each of its elements is as given in the equation below: where N p denotes virtual population. With respect to δ values, the update rule of each element is given as: In general, a probabilistic model for compact BA is employed to represent the bat solution set where neither the location nor the velocities are stored, however, a newly generated candidate is stored. Thus, modest memory space is required, and it is well suited for the limited hardware resources in WSNs.
A parameter ω is used as a weight to control the probability of sampling of µ i in PDF as Equation The extended version Equation (15) of PDF for sampling approach is applied in this paper. The generating new candidates of the bats are employed by sampling from PV such as when r < ω then it generates the coefficient x i ∈ [1, 0] for P L (x), otherwise x i ∈ [1, 0] for P R (x). The details for compact BA are as follows: Step 1 Initialization: µ and δ of the probabilistic model vector PV.
Step 2 Initialize parameters: the pulse rate r i , the loudness A i , and β are set to random; search range definition of pulse frequency f min , and f max .
Step 3 Generate the global best solution x best by means of perturbation vector PV; assign F min to fitness (x best ).
Step 4 Generate the local best solution x t from PV.
Step 5 Update velocities v t and locations x t according to updating rule of the standard BA algorithm, Equations (8)-(10); if (β > r i ), select a local solution x t+1 around selected best solution as Equation (11); assign the function value F new to fitness x t+1 .
Step 6 Compare x t+1 and x best , let one be the winner, and the other one is the loser according to Equation (16).
Step 8 A new solution is accepted if the solution improves (F new less than F min ), and not too loud (β less than A) then update global best x best to x t+1 and assign function F min to F new .
Step 9 If the termination condition is not met, go to step 4.
Step 10 Output the global best solution x best .

Experiments with Numerical Problems
To validate the quality performance of the proposed algorithm, we select ten optimal numerical problems [38] to prove the accuracy and rate of the cBA. The cBA measurements are compared with the original bat algorithm (oBA) with respect to solution quality. The two techniques used to verify the performance of the proposed cBA include similarity measure and time complexity analysis. The similarity measure uses a probability cosine with an adopted Pearson's correlation coefficient that considers the measured ratio (r) for two result solutions. The time complexity analysis uses the number of related variables employed in the optimization process. All the selected test functions for the outcomes of the experiment averaged over 25 runs. Minimized outcomes of optimization are calculated for all functions. Let X = {x 1 , x 2 , . . . , x n } be the n-population size real-value vector. The related initial data of test functions, i.e., range boundaries, max iteration, and dimension are listed in Table 1. Table 1. Ten selected benchmark functions of testing.

Name Test Functions Range Dimension Iteration
Rosenbrock 30 5000 Quadric Ackley 30 5000 Rastrigin 12 30 5000 Griewangk 30 5000 Spherical Quartic Noisy 28 30 5000 Schwefel 30 5000 Langermann 12 30 5000 Shubert 30 5000 Initial setting of parameters for the two algorithms of cBA and oBA are set such as loudness of A is set to 0.25, pulse rate r 0 i is set to 0.5, virtual population size N is set to 40, dimension is set to 30, minimum/maximum frequency ( f min, f max) are set to initial boundaries of the lowest and highest of range functions, maxiteration is set to 5000, and the number runs is set to 25. The final result is obtained by taking the average of the outcomes from all runs. The obtained results of cBA are compared with the oBA.
A comparison of the quality of performance and running time for the optimization problems of the cBA with oBA methods are shown in Table 2. Data in the oBA and the cBA columns in Table 2 represents the averaged outcomes of 25 runs for the original bat algorithm and the compact bat algorithm, respectively. Rate deviation (RD) is a rated deviation that represents the percentage of the deviation on the primary bat algorithm outcomes for the cBA, respectively. Clearly, almost all cases of benchmark functions for optimizing in both cBA and oBC have a small percentage of deviation. It shows that the accuracy of the cBA is as good as that of the oBA. The average percentage of deviation for ten test-function evaluations is only 3%. However, the average time consumption of cBA is 24% faster than that of oBA.   Figure 1 shows the curves of cBA and oBA with the average obtained minimum for four first test functions. It should be noted that all of these cases of test benchmark functions for cBA (red lines) are equal to or faster than oBA in convergence.   Figure 1 shows the curves of cBA and oBA with the average obtained minimum for four first test functions. It should be noted that all of these cases of test benchmark functions for cBA (red lines) are equal to or faster than oBA in convergence. To verify the effect of population sizes on the performance of the algorithms, we used variety N for testing. Figure 2 compares the performance quality of running with different population sizes for test functions between cBA and oBA. Doubtless, most cases for testing functions in the cBA are faster than and uniform in convergence that applied for BA. The convergence of most cases of test functions for employing in cBA is not affected very much by the variety population size. Because it is a virtual population the mean value of results did not fluctuate and was more stable than that of oBA. To verify the effect of population sizes on the performance of the algorithms, we used variety N for testing. Figure 2 compares the performance quality of running with different population sizes for test functions between cBA and oBA. Doubtless, most cases for testing functions in the cBA are faster than and uniform in convergence that applied for BA. The convergence of most cases of test functions Appl. Sci. 2019, 9, 1973 9 of 18 for employing in cBA is not affected very much by the variety population size. Because it is a virtual population the mean value of results did not fluctuate and was more stable than that of oBA.  Table 3 shows the comparison of the proposed cBA with the oBA in terms of the occupied memory variables for implementing computations in running optimization. The number of variables of the two algorithms is counted for through the number of the equations used in operations optimization. Observations from Table 3 would clearly show that the number of variables of cBA use is smaller than the oBA with the same condition of computation, e.g., iterations. There are four number equations for oBA, e.g., (8)- (11) and eight equations for cBA, e.g., (8)- (11), and (15)- (18).
However, the real population or population size of oBA is N, whereas, cBA is only one. With the same number of iterations and the running time T, the stored slots of variables for oBA and cBA are 4 × T × N × iteration, and 8 × T × iteration, respectively, where T and N are the counting run time and the number of population, respectively. It is observed that the number of occupied slots in oBA is higher (N/2 times) than in cBA.
, (16), (17),(18) Figure 3 illustrates a comparison of executing times of the cBA with oBA over 25 runs for ten benchmark functions. Clearly, all cases of testing duties of cBA are smaller than those obtained for oBA. The average consuming time of cBA for tests is 24% faster than oBA. The reason for the rapid result is that some of the memory-stored parameters for cBA are smaller than oBA.  Table 3 shows the comparison of the proposed cBA with the oBA in terms of the occupied memory variables for implementing computations in running optimization. The number of variables of the two algorithms is counted for through the number of the equations used in operations optimization. Observations from Table 3 would clearly show that the number of variables of cBA use is smaller than the oBA with the same condition of computation, e.g., iterations. There are four number equations for oBA, e.g., (8)- (11) and eight equations for cBA, e.g., (8)- (11), and (15)- (18). However, the real population or population size of oBA is N, whereas, cBA is only one. With the same number of iterations and the running time T, the stored slots of variables for oBA and cBA are 4 × T × N × iteration, and 8 × T × iteration, respectively, where T and N are the counting run time and the number of population, respectively. It is observed that the number of occupied slots in oBA is higher (N/2 times) than in cBA. Figure 3 illustrates a comparison of executing times of the cBA with oBA over 25 runs for ten benchmark functions. Clearly, all cases of testing duties of cBA are smaller than those obtained for oBA. The average consuming time of cBA for tests is 24% faster than oBA. The reason for the rapid result is that some of the memory-stored parameters for cBA are smaller than oBA.   Table 4 depicts the comparison the outcomes of the proposed algorithm with the other compact algorithms such as compact Particle swarm optimization (cPSO) [39], compact Differential evolution (cDE) [40], and real compact Genetic algorithm (rcGA) [41] for 10 test functions. Apparently, cBA outperforms its competitors regarding convergence. The best results among them for each function is highlighted in rows. The performance of the compared ratio r is set for each pair of comparisons of cBA with the cPSO, cDE, and rcGA, respectively. The symbols of "+", "−" and "~" represent "better", "worse", and "approximation" of the deviation of the outcomes, respectively. If the averaged outcomes obtained for 25 runs of the optimized function of cBA is better than the cPSO, cDE, and rcGA, then r is the set symbol "+". The same method with the symbols "~" and "−" for the worse and approximation are applied to the cases, respectively. It would be seen that most of the highlighted cases of testing functions belong to the proposed cBA. Table 4 shows that the proposed approach outperforms the other methods. According to Figure 4, the curve of the cBA displays comparatively better convergence behavior on the selected test functions.  Table 4 depicts the comparison the outcomes of the proposed algorithm with the other compact algorithms such as compact Particle swarm optimization (cPSO) [39], compact Differential evolution (cDE) [40], and real compact Genetic algorithm (rcGA) [41] for 10 test functions. Apparently, cBA outperforms its competitors regarding convergence. The best results among them for each function is highlighted in rows. The performance of the compared ratio r is set for each pair of comparisons of cBA with the cPSO, cDE, and rcGA, respectively. The symbols of "+", "−" and "~" represent "better", "worse", and "approximation" of the deviation of the outcomes, respectively. If the averaged outcomes obtained for 25 runs of the optimized function of cBA is better than the cPSO, cDE, and rcGA, then r is the set symbol "+". The same method with the symbols "~" and "−" for the worse and approximation are applied to the cases, respectively. It would be seen that most of the highlighted cases of testing functions belong to the proposed cBA. Table 4 shows that the proposed approach outperforms the other methods. According to Figure 4, the curve of the cBA displays comparatively better convergence behavior on the selected test functions. Table 4. Comparison of the outcomes of the proposed method with the other compact algorithms such as rcGA [39], cDE [40], and cPSO [39]

Experiments for Clustering in WSNs Problem
In designing and deploying sensor networks, a core demand is prolonging the lifetime of the network. A crucial factor for extending WSN lifetime is reduction of the energy consumption of the entire network. The power consumption of WSNs is affected directly by the clustering criterion problem. Furthermore, the cause of the hot spot problem in a WSN with multi-hop communications is unbalanced energy consumption. The higher energy consumption nodes are closer to the base station (BS) because of the heavy traffic flows. In this section, cBA is applied to optimize the design of the WSN by balancing the load between the CHs. We utilize adjustable parameter of loudness of BA for supporting and preventing unbalanced energy consumption. The loudness Ai of the BA can vary and alter responds to distances in clustering criterion for unequal clustering in WSN. The optimized total communication distances from the cluster members to the CHs and the CHs to the BS in the WSNs can provide the energy savings [42]. The sequence of experimental steps consists of modeling objective function, setting up a mapping solution model, describing proper agent representation, optimizing CHs, and comparing results.

Objective Function
The objective function is modelled with not only minimizing the optimized total communication distances from the cluster members to the CHs and the CHs to the BS but also by balancing energy consumption between the CHs and group members. Referring to Equation (3), the CHs is selected based on energy residual.
In Equation (6), we use only the optimizable component that was independent of parameters related to the microcontroller and the supply voltage distances. Consequently, Eframe is the most affected factor of the energy loss depending on the distance of the clustering in WSN. Therefore, the

Experiments for Clustering in WSNs Problem
In designing and deploying sensor networks, a core demand is prolonging the lifetime of the network. A crucial factor for extending WSN lifetime is reduction of the energy consumption of the entire network. The power consumption of WSNs is affected directly by the clustering criterion problem. Furthermore, the cause of the hot spot problem in a WSN with multi-hop communications is unbalanced energy consumption. The higher energy consumption nodes are closer to the base station (BS) because of the heavy traffic flows. In this section, cBA is applied to optimize the design of the WSN by balancing the load between the CHs. We utilize adjustable parameter of loudness of BA for supporting and preventing unbalanced energy consumption. The loudness Ai of the BA can vary and alter responds to distances in clustering criterion for unequal clustering in WSN. The optimized total communication distances from the cluster members to the CHs and the CHs to the BS in the WSNs can provide the energy savings [42]. The sequence of experimental steps consists of modeling objective function, setting up a mapping solution model, describing proper agent representation, optimizing CHs, and comparing results.

Objective Function
The objective function is modelled with not only minimizing the optimized total communication distances from the cluster members to the CHs and the CHs to the BS but also by balancing energy consumption between the CHs and group members. Referring to Equation (3), the CHs is selected based on energy residual.
In Equation (6), we use only the optimizable component that was independent of parameters related to the microcontroller and the supply voltage distances. Consequently, E frame is the most affected factor of the energy loss depending on the distance of the clustering in WSN. Therefore, the consuming energy of the network is based on the distances in the clusters. Sensor nodes are clustered by using entire distances, namely E distance , where k is the given clusters.
Another factor that affected the fitness function is calculated as follows: where k j=1 n j + k = N is the number of nodes in a network, d and D are the distances of member nodes to the CH and the CHs to the BS, respectively.
Modelling for objective function suggests dense clusters with set of nodes which have sufficient energy to perform the CH tasks. The objective function for equal clustering in WSN is defined as follows: where θ is weight of the objective function. The vector of bats x is represented by mapping from the distances of d ij with the indexed D j . Both types of distances are considered the intra-cluster distance and the distance between the CHs and the BS. The intra-cluster distances are distances of member nodes and its CH.

Model Solution Representation
A WSN is assumed to be a graph G with n nodes randomly distributed in the desired area. There are N nodes (N is set to 100, 200, . . . ) in a network spread out in a distributed two-dimensional space of (0 : M, 0 : M), where M equals 100, 200. The nodes of the WSN circulate in a two-dimensional area and are deployed as follows: (1) a model solution is constructed with spatial coordinates of nodes that can obtain distances to the BS and attribute links between the nodes, (2) clusters are figured out randomly with k clusters, and (3) the distance of the cluster member to the CH and the CHs to the BS are calculated for optimization of the network layout. Table 5 shows an example of the position of randomly distributed nodes in two-dimensional coordinates of a network zone. Each node can communicate with others by r transmission ranging. Node i can receive the signal of node j if node i is in the transmission range r of node j. Table 6 indicates the attribution of the existing CHs in the sensor networks.  Table 6. The attribution of existing cluster heads (CHs) if flag = 1 and node is set to cluster head (CH). Otherwise node is set to member node (SN). In the following experiment, we consider two scenarios of equal clustering and unequal clustering in a WSN to create an optimization network. The equal clustering has cluster radii which are the same size. However, the group size of unequal clustering close to the BS is smaller than those that are farther from the BS. The uneven cluster sizes occur because the traffic relay load of the CHs near the base station is heavier than the CHs farther away from the BS.

Equal Clustering Formation
The optimization problem is dealt with by minimizing the objective function in Equation (22). The initial setting for the oBA and the cBA is the same condition in the WSN (denoted as oBA-WSN and cBA-WSN), e.g., a maximum iteration is set to 2000, the number of runs is set to 25. (Readers refer to parameters setting of the loudness, frequencies, and virtual population in Section 4). The initial energy parameters of the sensor net are flowing: l = 1024 bit, E j = 0:5 J, E mp = 0:0013 pJ/bit/m 4 , E fs = 10 pJ/bit/m 2 , E DA = 5 nJ/bit/signal, E elec = 50 nJ/bit [31]. The experimental results of the proposed cBA are compared with the cases of PSO: the time-varying inertia weight (PSO-TVIW), and time-varying acceleration coefficients (PSO-TVAC) in [43] and the oBA [44] with respect to solution quality and time running. The result averages the outcomes from all runs. Table 7 compares the performance quality and running time for optimizing the clustering formation in WSNs for four methods of the cBA − WSN, PSOTVAC − WSN, PSOTVIW − WSN, and the oBA − WSN. Clearly, the average value of cBA for the objective function are faster than those obtained by other approaches of PSO. The applied cBA for optimizing the clustering formation is not as different as convergence using oBA. But, the total time consumption of the cBA method is fastest at only 2.445 min taken because the working variable memory is smallest.

Equal Clustering Formation
The optimization problem is dealt with by minimizing the objective function in Equation (22). The initial setting for the oBA and the cBA is the same condition in the WSN (denoted as oBA-WSN and cBA-WSN), e.g., a maximum iteration is set to 2000, the number of runs is set to 25. (Readers refer to parameters setting of the loudness, frequencies, and virtual population in Section 4). The initial energy parameters of the sensor net are flowing: l = 1024 bit, Ej = 0:5 J, Emp = 0:0013 pJ/bit/m 4 , Efs = 10 pJ/bit/m 2 , EDA = 5 nJ/bit/signal, Eelec = 50 nJ/bit [31]. The experimental results of the proposed cBA are compared with the cases of PSO: the time-varying inertia weight (PSO-TVIW), and time-varying acceleration coefficients (PSO-TVAC) in [43] and the oBA [44] with respect to solution quality and time running. The result averages the outcomes from all runs. Table 7. The comparison of averaged outcomes and computation time of cBA-WSN with other methods, e.g., oBA-WSN [44], PSO-TVAC [43] and PSO-TVIW [43] for equal clustering formation.  Table 7 compares the performance quality and running time for optimizing the clustering formation in WSNs for four methods of the cBA − WSN, PSOTVAC − WSN, PSOTVIW − WSN, and the oBA − WSN. Clearly, the average value of cBA for the objective function are faster than those obtained by other approaches of PSO. The applied cBA for optimizing the clustering formation is not as different as convergence using oBA. But, the total time consumption of the cBA method is fastest at only 2.445 minus taken because the working variable memory is smallest.

Unequal Clustering Formation
This unequal clustering scenario is studied to deal with the hot spot problem in WSN. The partitioned clusters in the network of uneven clustering have different sizes. The groups close to the BS are smaller than those clusters far from the BS. The clusters closer to the BS are the hotter clusters because the traffic relay load of the cluster heads near the BS is heavier than those CHs farther away from the BS [45]. To avoid this hot spot problem, we determine that the adjustable parameters are not only related to the objective function but also related to the optimization algorithm. For the objective function of constructing unequal clusters, each CH needs to adjust its equal cluster distances: where D j is the distance from node CH j to the BS, and R c is the ratio adjusting parameter. The calculation for R c is defined as follows: where d max and d min are the maximum and minimum distance of the CHs in the network to the BS, R max is the maximum value of competition radius, α is a weighted factor whose value is in (0, 1), and E r is the residual energy of CH j . Clustering optimized formation is done by performing the optimal objective function in Equation (22) with the assistant of different distances Equations (23) and (24). Figure 5b compares two performance qualities in two scenarios of equal clustering and hot spot problems. Visibly, the average fitness values of the cBA method with a hot spot issue in the case of adjusting cluster size for the unequal clustering formation is faster than the regular case in convergence.
For the optimization algorithm, we assigned the variable of loudness Ai for BA as in Equation (12) to correspond to the radius of the changing cluster size by bias iteration. We expressed mathematically the time-varying loudness of the BA as follows: where MaxIteration is the number of the maximum iteration; Iter is the current time steps, and A max , A min are constants set to 0.5 and 0.25, respectively. The time varying loudness is mathematically represented in Equation (25) for cBA with a hot spot problem in WSN. Figure 6 compares the performance qualities in two cases of the selected parameter of the loudness for cBA with an adjusted cluster size with no selected altered loudness setting. Visibly, the average fitness values for the cBA method in the case of adjusting Ai for the unequal clustering formation is better than the regular case in convergence to remove the hot spot problem. Figure 7 shows a comparison of the advanced cBA-WSN with other methods, e.g., PSO-TVAC, PSO-TVIW, the low-energy adaptive clustering hierarchy (LEACH) [22], and LEACH-centralized (LEACH-C) [23] approaches regarding the number of nodes alive. LEACH is a clustering protocol that selects sensor nodes randomly as CHs based on probability as a "threshold" parameter. LEACH-C is another version based on LEACH with a base station (BS) and uses a specific method to select the CH and divide the nodes to clusters which can offer more optimization, and therefore it means the lifetime of the network is longer than LEACH. On the basis of observations, it is clear that the number of alive nodes of the proposed cBA-WSN is the longest. This means that the results of the proposed cBA-WSN for the testing functions and clustering problem in WSN is better than the other methods in the comparisons.

,
are constants set to 0.5 and 0.25, respectively. The time varying loudness is mathematically represented in Equation (25) for cBA with a hot spot problem in WSN. Figure 6 compares the performance qualities in two cases of the selected parameter of the loudness for cBA with an adjusted cluster size with no selected altered loudness setting. Visibly, the average fitness values for the cBA method in the case of adjusting Ai for the unequal clustering formation is better than the regular case in convergence to remove the hot spot problem   Figure 7 shows a comparison of the advanced cBA-WSN with other methods, e.g., PSO-TVAC, PSO-TVIW, the low-energy adaptive clustering hierarchy (LEACH) [22], and LEACH-centralized (LEACH-C) [23] approaches regarding the number of nodes alive. LEACH is a clustering protocol that selects sensor nodes randomly as CHs based on probability as a "threshold" parameter. LEACH-C is another version based on LEACH with a base station (BS) and uses a specific method to select the CH and divide the nodes to clusters which can offer more optimization, and therefore it means the lifetime of the network is longer than LEACH. On the basis of observations, it is clear that the number of alive nodes of the proposed cBA-WSN is the longest. This means that the results of the proposed cBA-WSN for the testing functions and clustering problem in WSN is better than the other methods in the comparisons.

Conclusions
This paper presented a new optimization algorithm using the compact bat algorithm (cBA) for the uneven clustering problem in wireless sensor networks (WSN). A probabilistic model was used to generate a new candidate solution in space search using the cBA which has been promising so far.

Conclusions
This paper presented a new optimization algorithm using the compact bat algorithm (cBA) for the uneven clustering problem in wireless sensor networks (WSN). A probabilistic model was used to generate a new candidate solution in space search using the cBA which has been promising so far. The candidate solution was found by studying explicit probabilistic models of promising existing solutions and sampling the built models. The probability density functions (PDF) and cumulative distribution functions (CDF) thoroughly are used to construct the operations of selecting and optimizing behaviors. The probabilistic model is used as a valid alternative optimization strategy for available devices with even limited hardware sources. Experimental results demonstrate that the proposed algorithm achieves the effective way of using limited memory devices, and provides competitive results.