# A Compact Bat Algorithm for Unequal Clustering in Wireless Sensor Networks
## 3 Compact Bat Algorithm
### 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. \[PV^{t}=\ \left[\mu^{t},\delta^{t}\right], \tag{14}\]  
where \(\delta\) and \(\mu\) are two parameters of standard deviation and mean of vector \(PV\), and \(t\) is the current time. The values of \(\delta\) and \(\mu\) 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(\mu_{i},\delta_{i})\). \[P(\mathrm{x})=\frac{exp^{\frac{(x-\mu_{i})^{2}}{2\delta_{i}^{2}}}}{\delta_{i} \left(\mathrm{erf}\left(\frac{\mu_{i}+1}{\sqrt{2}\delta_{i}}\right)-\mathrm{ erf}\left(\frac{\mu_{i}+1}{\sqrt{2}\delta_{i}}\right)\right)} \tag{15}\]  
where \(P(\mathrm{x})\) is the probability distribution of \(PV\) that formulated a truncated Gaussian _PDF_ associated with the \(\mu\) and \(\delta\). 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 \(erf\) 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=\int_{0}^{1}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\), \(\mu\) and \(\delta\) are considered based on the following rules. If the mean value of \(\mu\) is regarded to 1, the update rule for each of its elements is \(\mu_{i}^{t},\delta_{i}^{t}\) set forward to \(\mu_{i}^{t+1},\delta_{i}^{t+1}\) as given in the equation below:  
\[\mu_{i}^{t+1}=\mu_{i}^{t}+\frac{1}{N_{p}}(winner_{i}-\mathit{loser}_{i}) \tag{16}\]  
where \(N_{p}\) denotes virtual population.