## 2 Diversity Measures Utilised in Population Based Algorithms
### Swarm Diversity
#### 2.1.1 Sum of Distances  
The sum of distances (SD) measure finds the dissimilarity between candidates solutions, by calculating the square root of the sum of their distances from one another [4]. Equation (1) shows how this is computed:\[D_{\text{SD}}=\sqrt{\sum_{\begin{subarray}{c}\mathbf{x}_{i}\in S \end{subarray}}\sum_{\begin{subarray}{c}\mathbf{x}_{j}\in S\\ j\
eq i\end{subarray}}\left\|\mathbf{x}_{i}-\mathbf{x}_{j}\right\|_{2}} \tag{1}\]  
where \(S\) is the set of all candidate solutions at a given time, while \(\mathbf{x}_{i}\) and \(\mathbf{x}_{j}\) are different candidate solutions in \(S\).  
Over time, niching algorithms drive particles to cluster around optima (or niches). Thus, at convergence of a niching algorithm, particles will be clustered around a niche, with the best particle of a niche (i.e., the neighbourhood best) representing one of the found optima. Figure 0(a) illustrates the spread of particles during a search process, while Figure 0(b) illustrates the convergence of particles, in the form of niches, around positions of optima. Appendices A-C show progression of particles from initial (random) positions as well as their positions at different iterations during a typical run.  
The expected behaviour in niching algorithms is that, when candidate solutions start converging near their neighbourhood bests, intra-niche (distances between particles in the same niche) distances start to approach zero. This means that the swarm diversity at convergence should approach zero. For the case of the SD measure, the expected behaviour is that even at convergence, calculated SD values will be high, in particular if the inter-niche (distances between the best particles of the niches) distances are large. Thus, calculated SD values gives an incorrect impression of diversity at convergence. Figure 2 depicts how swarm diversity compares to inter- and intra-niche distances over time.  
Figure 1: Illustration of swarm diversity for niching algorithms. The crosses show the positions of optima. (**a**) particles during search process; (**b**) particles at convergence.  
In order to adapt the SD measure to correctly quantify spread for a niching algorithm, the SD measure should be computed for each identified candidate niche. The values of the SD measure for each of the candidate niches are then summed and averaged. The modification of Equation (1) to calculate diversity for a niching algorithm is then given by  
\[D_{n\text{SDN}}=\frac{1}{\mu}\sum_{k=1}^{\mu}\left(\sqrt{\sum_{\mathbf{x}_{i} \in N_{k}}\sum_{\begin{subarray}{c}\mathbf{x}_{j}\in N_{k}\\ j\
eq i\end{subarray}}\|\mathbf{x}_{i}-\mathbf{x}_{j}\|_{2}}\right) \tag{2}\]  
where \(\mu\) is the number of candidate niches, \(N_{k}\) is the set of particles in a candidate niche, \(k\), while \(\mathbf{x}_{i}\) and \(\mathbf{x}_{j}\) are different candidate solutions in \(N_{k}\).  
Computing the swarm diversity as an average of the candidate niches' diversity eliminates the inter-niche distances problem reported earlier. The illustration shown in Figure 2 depicts that, as niches converge, the average SD over all niches approaches zero. As shown, an averaged candidate niches' diversity (SD diversity per niche) corresponds to the intra-niche distances, which is the expected behaviour for a niching algorithm.