# An Improved Shuffled Frog Leaping Algorithm for Electrical Resistivity Tomography Inversion
## 3 Inversion of ERT Based on the Shuffled Frog Leaping Algorithm  
In the inverse framework of the SFLA, the fitness function directly represents the evaluation criterion of the solution's quality, which essentially is the objective function to be optimized (typically the root means square error (RMSE) or residual norm). The algorithm's search process is fitness-driven: during each iteration, individual position updates are guided by both the subgroup-best and global-best solutions, whose selection is entirely determined by fitness ranking (solutions with optimal goodness-of-fit dictate the search direction). Specifically, the fitness function or inversion objective function \(\Phi_{i}\) is constructed as  
\[\Phi_{i}=\sqrt{\sum_{i=1}^{N}{(\rho_{i}^{obs}-\rho_{i}^{cat})^{2}}},\ i=1,\ 2, \ldots,N \tag{1a}\] \[S=\Phi_{i}+\lambda\ \|\ \Delta^{2}m_{i}\ \ \|_{2}^{2} \tag{1b}\]  
In the equation, \(\rho_{i}^{obs}\) represents the observed value of the \(i\)-th block, \(\rho_{i}^{cal}\) represents the forward calculated value of the \(i\)-th block, \(N\) is the total number of measurement points, \(\mathcal{R}(i)\) is the regularization term, and \(\lambda\) is the weight coefficient (typically taken as 0.001 based on empirical values), \(\|\Delta^{2}m_{i}\|^{2}\) is the second-order smoothness constraint applied to the model parameters, and \(\|\_{2}\) represents the L2 norm. Additionally, to avoid negative values for apparent resistivity and resistivity due to the large range of resistivity variations in the inversion process, the natural logarithm of the model resistivity is taken, i.e., \(\ln\rho\), which reduces the resistivity range and improves the inversion stability. For the division of subgroups, to maintain the diversity of frogs within each subgroup, the frogs are sorted by their fitness values from best to worst. As per Equation (2), the sorting is performed such that the first frog enters the first group, the second frog enters the second group, and so on. The \(m\)-th frog enters the \(M\)-th group, and the \(m+1\)-th frog goes back to the first group, continuing in this manner. Thus, the total number of frogs, \(M\)\(\times\)\(N\), is divided into \(M\) subgroups, each containing \(N\) frogs. \[M_{j}=\Big{\{}\Phi_{j+(n-1)\times M}\Big{|}1\leq n\leq N\Big{\}};\ 1\leq j\leq M \tag{2}\]  
In addition, during the renewal of frog individuals, the position of the block represented by the frog individual remains unchanged, and its resistivity value is updated. Within each subgroup, let \(X_{b}\) and \(X_{w}\) represent the frog individuals with the best and worst fitness values in the current subgroup, respectively, and \(X_{g}\) represents the frog individual with the best fitness value in the entire population. During evolution, the frog individual with the worst fitness, \(X_{w}\), jumps towards the frog individual with the best fitness in the subgroup, \(X_{b}\). \[\Delta_{w}(t+1)=rand(0,1)\times\left[(X_{b}(t)-X_{w}(t))\right] \tag{3a}\] \[X_{w}(t+1)=X_{w}(t)+\Delta_{w}(t+1)\] (3b) \[R_{min}\leq\Delta_{w}(t)\leq R_{max} \tag{3c}\]  
In the above equation, \(rand(0,\ 1)\) represents a random number between 0 and 1, \(\Delta_{w}(t)\) represents the jump step (random weight), and \(\Delta_{w}(t)\in\left[R_{min},R_{max}\right]\), where \(R_{max}\) is the maximum allowed step size. In the above procedure, if the fitness of the new solution is better than that of the old solution, the new solution replaces the old solution. If no improvement is made to \(X_{w}\), then the population's global best solution \(X_{g}\) is used to replace \(X_{b}\) and recompute; i.e., Equation (4) replaces Equation (3a). \[\Delta_{w}(t+1)=rand(0,1)\times\left[\big{(}X_{g}(t)-X_{w}(t)\big{)}\right] \tag{4}\]If the new solution still fails to improve \(X_{w}\), a new solution is randomly generated to replace \(X_{w}\). At this point, after completing the local search within each subgroup, all individuals from the subgroups are merged back into a complete population.