## 3 Predicting Missing Soil Heavy-Metal Values Based on SA-FOA-BP
### Adaptive Step-Size Fruit Fly Optimization Algorithm Based on Individual Differences
#### 3.1.2 FOA Combined with Simulated Annealing Algorithm  
Given the differences in position and search step size of individual flies during the optimization process, we adjusted the step size using the simulated annealing algorithm (SA) to make the fixed step-size adaptable to dynamically adjust to the conditions. The SA algorithm [18; 19] aims to simulate a global optimal solution in high-temperature solid-state annealing.  
According to the Metropolis criterion, the probability of a particle cooling down at temperature T is  
\[\mathrm{p}(\mathrm{dE})=\mathrm{exp}(-\frac{\Delta\mathrm{E}}{\mathrm{kT}}) \tag{1}\]  
where E is the internal energy of the particle at temperature T; \(\Delta\mathrm{E}\) represents the energy change, and k is Boltzmann's constant.  
The steps for implementing the SA algorithm are presented as follows.  
1. The objective function \(f(x)\), initial temperature \(t_{0}\), and minimum temperature \(t_{\mathrm{min}}\) are set.
2. Let the current temperature be \(t\) and the feasible solution be \(x\). The initial solution is randomly perturbed to generate a new solution. \[\mathrm{x}^{\prime}=\mathrm{x}+\Delta\mathrm{x}\] (2) The resulting energy difference is calculated as \[\Delta\mathrm{f}=\mathrm{f}\big{(}\mathrm{x}^{\prime}\big{)}-\mathrm{f}( \mathrm{x})\] (3)3. The energy difference is calculated. If \(\Delta t<0\), then accept the new solution and replace the old solution, and move to the next iteration; if \(\Delta f>0\), then decide whether to keep the new solution based on probability according to the Metropolis criterion.
4. Repeat steps 2-3, gradually reducing the temperature after a certain number of iterations. When \(t<t_{\text{min}}\), we iterate and output the optimal solution. The moving step-size formula in the FOA is \[\text{L}=\text{Random}*\text{Value}\] (4)  
_Random_ is a random number between [0, 1]; _Value_ is the initial step size, and is a constant value. Thus, the moving step size \(L\) is a random number in the range [0, _Value_]. However, the FOA has some drawbacks. In the early stage of fruit fly optimization, a small step-size leads to low optimization efficiency; in the later stage of optimization, a large step-size makes it easy to miss the optimal solution [20].  
To address these issues, the FOA uses a non-uniform mutation strategy to improve the moving step-size, as follows:  
\[\text{L}^{\prime}=\text{n}(1-\left(\frac{\text{g}-1}{\text{maxgen}}\right)^{ \lambda})\text{sgn}(\text{r}-0.5) \tag{5}\]  
where n is the initial step size; g is the current iteration number; maxgen is the maximum number of iterations; \(\lambda\) is the nonuniform mutation factor, set to 2 in this study; sgn is the sign function; and \(r\) is a random number between [0, 1]. Equation (5) shows that the improved moving step-size decreases with an increase in the iteration number, which improves the optimization efficiency in the early stage of the optimization process and enhances the local search capability of the algorithm in the later stage to avoid missing the optimal solution as a result of a large search step-size.  
Combining the FOA with the SA, the SA-FOA algorithm is proposed to increase the diversity of the search by probabilistically eliminating the worst solutions during the iteration process, ensuring that the algorithm can still start a new search from the worst solution as a new starting point when trapped in a local optimum, and improve the local search capability of the algorithm. The improved algorithm can effectively avoid step-size and local optimum problems in the FOA.