# A Modified Shuffled Frog Leaping Algorithm for the Topology Optimization of Electromagnet Devices
## 2 The Modified Shuffled SFLA  
The SFLA was proposed by [PERSON] and [PERSON] in 2006 [13]. Similar to the other algorithms in the memetic family, the evolution process in SFLA also contains both local exploitation mechanism and global exploration mechanism. An initial population is randomly generated, evaluated, and sorted. Based on the objective function values, the individuals in the initial population are partitioned into different subgroups of equal size named memeplexes. Within each memeplex, individuals will evolve via moving towards either the local best or the global best in the memeplex. After certain iterations of local evolvement, the entire population will be re-shuffled for the spreading of the memes. These steps will be repeated until the stopping criteria are met [16]. In the ordinary SFLA algorithm, in each iteration, the best candidate, i.e., frog, of each memeplex will not update its position. As each candidate will always remain at the same position, especially for the best frog in the entire population, it is easy for the algorithm to be trapped in some local optima found at the early stage of the optimization process and hence ending prematurely. To avoid this problem, a local search process for the best frog in each memeplex is added to the algorithm to help it escape from false best solutions. The flowchart of the proposed SFLA is given in Figure 1. For an optimization problem with \(n\) control parameters, each frog in the algorithm is an \(n\) dimension vector, \(X_{i}=[x_{i,1},x_{i,2},x_{i,3},\ldots,x_{i,n}]\). At the beginning of the optimization, \(N\) frogs are generated using the Latin-hypercube sampling method to ensure the entire design space can be well explored. Based on the objective value of each individual frog, the initial population is then sorted, and evenly partitioned into \(m\) memeplexes \(S_{1},S_{2},\ldots,S_{m}\), with each memeplex containing \(p\) frogs, where \(N=m\times p\). For instance, if \(m=p=3\), then \(S_{1}\) contains \(X_{1},X_{4},X_{7}\), \(S_{2}\) contains \(X_{2},X_{5},X_{8}\), and \(S_{3}\) contains \(X_{3},X_{6},X_{9}\), given all \(X_{i}\) have been sorted. The number of frogs in each memeplex is set to be \(n+1\) based on the Nelder-Mead method [17]. Following the partition process, a local search is conducted in memeplexes. A random vector with 1/10 upper and lower bound is added firstly to the best frog in the memeplex, \(X_{b,k}\):  
\[X_{b,k}^{\prime}=X_{b,k}+\frac{1}{10}[\text{rand}\left(lb,ub\right),\ldots, \text{rand}\left(lb,ub\right)] \tag{1}\]  
Figure 1: Flowchart of the shuffled frog leaping algorithm (SFLA). The objective function value of the new frog is evaluated. If it is better than the original frog, then \(X_{b,k}\) is replaced by \(X^{\prime}_{b,k}\). After the update of the best frog in the \(k^{\text{th}}\) memeplex \(S_{k}\), a small portion of frogs are selected to form a sub-memeplex. The selection probability of each frog in the memeplex is derived based on their objective value ranking in the memeplex using the triangular probability function [11]:  
\[P_{i,k}=2(p+1-i)/p(p+1),i=1,2,3,\ldots,p \tag{2}\]  
where \(P_{i,k}\) is the frog selection probability in the \(k^{\text{th}}\) memeplex and \(i\) is the ranking of the frog. Inside the sub-memeplex, the frog with the best objective value, \(X_{b,k}\), and the frog with the worst objective value, \(X_{w,k}\), are identified. To imitate the process of sharing information, the worst frog will learn from both the best frog in the sub-memeplex and from the global best in the entire population, which is a process similar to the PSO algorithm [13]. Mathematically, the position of the worst frog is updated by:  
\[ \begin{split} v=S\times[w\times(X_{b,k}-X_{w,k})+(1-w)\times(X_{ b,\text{overall}}-X_{w,k})]\\ X^{\prime}_{w,k}=X_{w,k}+v\end{split}  \tag{3}\]  
where \(S\) is the predefined step size, and \(w\) is the random weight between [0,1]. If the new position \(X^{\prime}_{w,k}\) is within the design space, its objective value is evaluated.