# Evapotranspiration Prediction Method Based on K-Means Clustering and QPSO-MKELM Model
## 2 Materials and Methods
### New Model
#### 2.4.3 Piecewise QPSO Improved by GA  
The traditional PSO algorithm updates the velocity and position of the particles in the next generation based on the particle's velocity inertia, individual best, and global best, which carries a significant risk of getting stuck in local optima. To address this issue, [PERSON] et al. introduced quantum theory into the Particle Swarm Optimization algorithm,resulting in the QPSO algorithm [27]. In the QPSO algorithm, the particle's position update formula is as follows:  
\[\mathrm{x_{i}(t+1)}= \begin{cases}\mathrm{\rho_{i}(t)+\alpha(t)|N_{best}(t)-x_{i}( t)|\cdot ln\left(\frac{1}{\mu}\right),\ 0.5\leq\ \varphi\leq 1\\ \mathrm{\rho_{i}(t)-\alpha(t)|N_{best}(t)-x_{i}(t)|\cdot ln\left(\frac{1}{\mu} \right),\ 0\leq x<0.5}\end{cases}  \tag{8}\]  
where \(\mathrm{\rho_{i}(t)}\) is the local attraction point for the i-th particle, and its formula is as follows:  
\[\mathrm{\rho_{i}(t)=\theta P_{i}(t)+(1-\theta)P_{g}(t)\theta\in[0,\ 1]} \tag{9}\]  
\(\mathrm{P_{i}}\) (t) is the individual best position of the i-th particle at the t-th iteration, and \(\mathrm{P_{g}(t)}\) is the global best position at the t-th iteration. \(\mathrm{\alpha(t)}\) is the shrinkage-expansion coefficient; \(\mathrm{N_{best}(t)}\) is the average position of all particles' individual best positions at the t-th iteration; \(\varphi\) and \(\mu\) are random numbers uniformly generated within the range \([0,1]\). The formula for calculating \(\mathrm{N_{best}(t)}\) is as follows:  
\[\mathrm{N_{best}(t)=\frac{1}{N}{\sum\limits_{i=1}^{N}P_{i}(t)}} \tag{10}\]  
The formula for calculating \(\mathrm{\alpha(t)}\) is as follows:  
\[\mathrm{\alpha(t)=\frac{(1-0.5)\cdot t}{T}+\ 0.5} \tag{11}\]  
where t is the current iteration number, and T is the maximum number of iterations. The local attraction point, \(\mathrm{\rho_{i}(t)}\), is important in the particle position update. It is a linear combination of the individual and global best positions. \(\theta\) is a random number in the range \([0,1]\). Although the particle can integrate individual and population information to update its position, the search lacks emphasis on different stages. This paper proposes a piecewise attraction point, which adjusts the emphasis on the dominance of individual and global best in different stages. The parameter \(\theta\) is bounded by a maximum value of \(\delta\) instead of 1. When \(\delta\) exceeds 0.5, \(\theta\) is a random number in the range \([0.5,8]\). Otherwise, it is in the range \([0,\delta]\). The formula for \(\delta\) is as follows:  
\[\delta=\frac{(0.9-0.3)\cdot(T-t)}{T}+0.3 \tag{12}\]  
At the early stages of the algorithm, \(\theta\) has a higher probability of selecting larger values, and the individual best dominates in the attraction point, improving the particle's global search ability and avoiding premature convergence to local optima. In the later stages, the probability of selecting smaller values for \(\theta\) increases, and the global best dominates in the attraction point. The improvement of the piecewise attraction point enhances the global search ability of the particle. However, there is still a possibility of getting stuck in local optima during the particle convergence phase. To address this, the idea of genetic algorithm mutation is introduced. A piecewise mutation strategy is proposed. A minimal mutation probability is applied in the early stages when the particles are still relatively dispersed. This ensures that the search and convergence of the particles are not affected. In the later stages, when the particles converge to a certain extent, and the population becomes highly similar, the mutation rate increases. At this point, increasing the mutation rate has little effect on the convergence trend of the population but greatly improves the ability of the population to escape from local optima, further enhancing the model's global search ability and stability,and reducing the risk of the model getting trapped in local optima.