# The Stock Index Prediction Based on SVR Model with Bat Optimization Algorithm
## 3 Materials and Methods  
### The Original Bat Algorithm  
The bat algorithm, as a method of swarm intelligence optimization algorithm, draws on the definition of bat algorithm by [PERSON] [19]. Here are the assumptions that the implementation of the bat algorithm satisfies. First, all bats rely on their own echolocation system to detect distances, and bats can accurately distinguish prey from obstacles and even distinguish what kind of prey it is. Second, each bat spontaneously adjusts the sonar rate and sonar loudness at any position to capture prey. Third, although the sonar loudness emitted by bats can be freely changed, for the sake of simplicity, it is assumed that there are maximum and minimum values of bat sonar.  
Based on these three ideal state assumptions, we can describe the process of bat algorithm seeking global optimal solution as follows. Before the operation of the bat algorithm starts, for bat \(i\), we need to determine the position of the bat \(x_{i}\), \(i=1,2,\ldots,n\), the bat's flight speed \(v_{i}\) the maximum and minimum sound wave frequency \(f_{max}\) and minimum \(f_{min}\), and the pulse rate \(r_{i}\) and set the initial value of impulse loudness \(A^{t}\). The bat algorithm seeks the optimal position through iterations under certain conditions. In other words, it is the optimized parameter. Suppose the number of iterations \(t<\mathit{maxgen}\), where \(\mathit{maxgen}\) is the maximum number of iterations, and \(t=0\) is the initial period. In each iteration of the bat algorithm, if the condition \(t<\mathit{maxgen}\) is satisfied, it can update its flight speed \(v_{i}\) and position \(x_{i}\) by adjusting the sound wave emission frequency \(f_{i}\). The update process is as follows:  
\[f_{i}=f_{min}+\mu\cdot(f_{max}-f_{min}) \tag{1}\]  
\[v_{i}^{t}=v_{i}^{t-1}+\left(x_{i}^{t}-x_{gbest}^{t}\right)\cdot f_{i} \tag{2}\]  
\[x_{i}^{t}=x_{i}^{t-1}+v_{i}^{t} \tag{3}\]  
where \(x_{gbest}^{t}\) refers to the global optimal position at the current moment, that is, the global optimal solution. It is equivalent to the position where bats can best catch their prey. Generally speaking, we set the initial value of \(x_{gbest}^{t}\) to 0.  
Based on Equations (1)-(3), \(i\) bats continuously iterate within a given maximum number of iterations to adjust the sound wave emission frequency \(f_{i}\), flight speed \(v_{i}\) and location \(x_{i}\). Next, we compare the pulse rate of \(i\) bats with the random value rand. If the pulse rate is less than the random value, first select the bat with the largest sound wave frequency among all the bats whose pulse rate is less than the random value, and then find the optimal position according to \(x_{new}=x_{old}+\varepsilon A^{t}\). Currently, if the random value is less than the impulse loudness \(A^{t}\) and the sound wave frequency is less than the local optimal sound wave frequency, then accept this solution, increase the pulse rate \(r_{i}\) and reduce the impulse loudness \(A^{t}\), the adjustment processes are as follows:  
\[r_{i}^{t+1}=r_{i}^{0}\big{[}1-e^{\gamma t}\big{]} \tag{4}\]  
\[A_{i}^{t+1}=\alpha\cdot A_{i}^{t} \tag{5}\]  
where \(\alpha\) is the loudness attenuation coefficient, and \(\gamma\) is the rate enhancement coefficient. We sort the selected n bats according to the sound wave frequency, and get the bats in the optimal position, that is, find the local optimal solution. Finally, when the number of iterations reaches the preset maximum number of iterations, the algorithm terminates and the global optimal solution is obtained.