# Research on Temperature Compensation Method in Crankshaft Online Measurement System
## 3 Compensation Method for LVDT Based on IDA-BP Neural Network
### Dragonfly Algorithm  
#### 3.2.1 Fundamental Theory of Dragonfly Algorithm  
DA is a new type of swarm intelligence optimization algorithm proposed by [PERSON] in 2015 [15]. Then [PERSON] [20] made a detailed summary of the dragonfly algorithm, including improved methods and applicable occasions. Five basic principles are utilized to model the swarm behaviors of dragonflies. In the following equations, \(P\) shows the position of the current individual, \(P_{j}\) represents the position \(j\)-th neighboring individual, and \(N\) is the number of neighboring individuals.  
1. Separation represents the static collision avoidance that individuals follow to avoid collision with other individuals in the neighborhood; its mathematical model is as follows: \[S_{i}=-\sum_{j=1}^{N}P-P_{j}\] (9)
2. Alignment means the individual's velocity matching between other neighboring individuals in the same group. The alignment is expressed as follows: \[A_{i}=\frac{\sum_{j=1}^{N}V_{j}}{N}\] (10) where \(V_{j}\) shows the velocity of the \(j\)-th neighboring individual.
3. Cohesion indicates the tendency of individuals toward the center of the swarms' group. It is defined as follows: \[C_{i}=\frac{\sum_{j=1}^{N}P_{j}}{N}-P\] (11)
4. Attraction towards food source is calculated by: \[F_{i}=P^{+}-P\] (12) where \(Fi\) represents the food source of the \(i\)-th individual and \(P^{+}\) shows the position of the food source.
5. Distraction outwards the enemies is modeled mathematically by: \[E_{i}=P^{-}+P\] (13) where \(Ei\) denotes the position of the enemy of the \(i\)-th individual and \(P^{-}\) shows the position of the enemy.  
Positions of dragonflies inside the search space are updated considering the step vector \(\Delta P\) and the position vector \(P\). It is defined and updated as follows:  
\[\Delta P_{i}^{t+1}=(sS_{i}+aA_{i}+cC_{i}+fF_{i}+eE_{i})+\omega\Delta P_{i}^{t} \tag{14}\]  
where \(s\) shows the separation weight, \(S_{i}\) indicates the separation of the \(i\)-th individual, \(a\) represents the alignment weight, \(A_{i}\) denotes the alignment of the \(i\)-th individual, \(c\) is the cohesion weight, \(C_{i}\) is the cohesion of the \(i\)-th individual, \(f\) is the food factor, \(F_{i}\) is the food source of the \(i\)-th individual, \(e\) represents the enemy factor, \(E_{i}\) is the enemy position of the \(i\)-th individual, \(\omega\) is the inertia weight, and \(t\) is the iteration number. Then, the position of the \(i\)-th dragonfly at \(t+1\) is calculated as follows:  
\[P_{i}^{t+1}=P_{i}^{t}+\Delta P_{i}^{t+1} \tag{15}\]  
Exploration is ensured by using high alignment and low cohesion weights; however, exploitation is guaranteed by using low alignment and high cohesion weights [21]. The convergence rate of DA can be controlled by adaptively adjusting the weights \(s\), \(a\), \(c\), \(f\), \(e\), and \(\omega\). To enhance the exploration, randomness, and exploitation of the artificial dragonflies, random walk (Levy flight) is introduced when there are no neighboring solutions. Therefore, the position of the \(i\)-th dragonfly at iteration \(t+1\) is updated as follows:  
\[P_{i}^{t+1}=P_{i}^{t}+\text{Levy}(d)\times P_{i}^{t} \tag{16}\]  
where \(d\) is the dimension of the position vectors. Levy flight is calculated by [22]:  
\[\text{Levy}(d)=0.01\times\frac{r_{1}\times\sigma}{|r_{2}|^{\frac{1}{\beta}}} \tag{17}\]  
where \(r_{1}\), \(r_{2}\) are two random vectors uniformly distributed in [0,1], \(\beta\) is a constant, and \(\sigma\) is calculated as follows:  
\[\sigma=\left(\frac{\Gamma(1+\beta)\times\sin\left(\frac{1\beta}{2}\right)}{ \Gamma\times 2^{(\frac{\beta-1}{2})}\times\beta\times\left(\frac{1+\beta}{2} \right)}\right)^{\frac{1}{\beta}} \tag{18}\]