# Prediction Model for Compaction Quality of Earth-Rock Dams Based on IFA-RF Model
## 2 Materials and Methods
### Improving Firefly Optimization Algorithm
#### 2.4.6 Algorithm Performance Comparison  
To validate the effectiveness, superiority, and efficiency of the proposed algorithm, the FA and the IFA were tested using benchmark functions. The four benchmark functions used in this study are the Sphere function (\(f_{1}\)), Rastrigin function (\(f_{2}\)), Ackley function (\(f_{3}\)), and Griewank function (\(f_{4}\)). These functions can be accessed at [[http://www.sfu.ca/~ssurjano/index.html](http://www.sfu.ca/~ssurjano/index.html)]([http://www.sfu.ca/~ssurjano/index.html](http://www.sfu.ca/~ssurjano/index.html)), (accessed on 9 October 2024).  
\[f_{1}=\sum_{i=1}^{m}x_{i}^{2} \tag{6}\]\[f_{2}=10n+\sum_{i=1}^{n}\left(x_{i}^{2}-10\cos(2\pi x_{i})\right. \tag{7}\]  
\[f_{3}=1+\frac{1}{4000}{\sum_{i=1}^{n}\left(x_{i}^{2}\right)}-{\prod_{i=1}^{n} \cos(\frac{x_{i}}{\sqrt{i}})} \tag{8}\]  
\[f_{4}=-20\exp(-0.2\sqrt{\frac{1}{n}{\sum_{i=1}^{n}\left(x_{i}^{2}\right)}})- \exp(\frac{1}{n}{\sum_{i=1}^{n}\cos(2\pi x_{i})})+20+\exp(1) \tag{9}\]  
For both the FA and IFA algorithms, the following parameters were set: number of fireflies: 50, maximum iterations (Max_iteration): 300, search space boundaries: \(\pm 5\), and dimension (dim): 5. The optimization results for the FA and IFA on these benchmark functions are presented in Table 1. It can be observed that, compared to the FA, the IFA--by incorporating dynamic adjustment factors, inertia weight, and differential evolution strategies--demonstrates an improved ability to escape local optima and enhance the global search capability. For benchmark functions \(f_{1}\) to \(f_{3}\), the optimization results for IFA are significantly better than those for FA. For the \(f_{4}\) benchmark function, the IFA's results are slightly better than the FA's, though the improvement is not as pronounced. The IFA exhibits a slight increase in computation time compared to the standard FA. However, it achieves a significant enhancement in optimization performance. Given the practical requirements of hydraulic engineering construction sites, obtaining more precise results is of paramount importance. In light of the substantial improvement in optimization effectiveness, the marginal increase in computation time is entirely justified and worthwhile. In conclusion, the proposed IFA demonstrates excellent accuracy, effectiveness, and superiority in optimization performance. Therefore, this algorithm is employed to optimize the parameters of RF.  
Compression Quality Evaluation Model Based on an Improved Firefly Algorithm Optimizing Random Forest  
To enhance the precision and reliability of the compaction quality evaluation for earth-rock dams, this study proposes a model that integrates swarm intelligence optimization algorithms with machine learning. The compaction process involves multiple operational parameters (e.g., compaction cycles, moisture content, and compaction thickness), which exhibit high nonlinearity and complex interrelationships. Therefore, to effectively evaluate the compaction quality of earth-rock dams, the IFA is employed to adaptively optimize the parameters of the RF model, thereby enhancing its predictive capabilities.