# An Improved Particle-Swarm-Optimization Algorithm for a Prediction Model of Steel Slab Temperature
## 3 Improved Particle-Swarm-Optimization Algorithm
### Improvement Strategies of the XPSO Algorithm
The update formula is given as follows: \[w= \begin{cases}\frac{r\sin(w_{s},r)}{4},&f(g)\gg Fitness3\\ w_{s}-(w_{s}-w_{e})\sqrt{\frac{K}{G}},&f(g)<\text{\it Fitness3}\end{cases} \] (9) where \(r\in[0,4)\) is a uniformly distributed random number; and \(w_{s}\) and \(w_{e}\) are the initial and final values of the range \([w_{s},w_{e}]\) of the inertia weight, respectively. \(\text{\it Fitness3}\) is the autonomous set value, \(k\) is the current iteration and G is the maximum iterations. * The strategy of jumping out local optimum is proposed. A slope parameter \(tr\) is given to judge whether the particle swarm has fallen in the local optimum. Here, \(tr\) is the count of the condition when \(Slope\) is less than the value \(\varepsilon\) in five iterations. The slope is calculated as follows: \[Slope=\frac{\left(f_{k}(g)-f_{(k-5)}(g)\right)}{5}\] (10) If the value of \(tr\) equals the value of \(s\), which is an autonomous set value, the particle swarm is trapped in a local optimum. Then, the particle swarm will perform a \"jumping out local optimum\" operation, which is done to change its position. The specific formula of a particle jumping out of a local optimum is given as follows:  
\[x_{ij}(k)=x_{ij}(k)-r_{1}c_{1}\big{(}g-x_{ij}(k)\big{)}+r_{2}c_{2}\big{(}bad-x_{ ij}(k)\big{)} \tag{11}\]  
where \(bad\) represents the information of the global worst position. The core of this strategy is that the particle swarm should be nearest to the global worst position while staying away from the local optimum. Finally, the pseudo-code of the XPSO algorithm is demonstrated in Algorithm 1. ```
1:Initialize the parameters: (N, G, D, \(O_{max}\),\(O_{min}\), \(V_{max}\), \(V_{min}\), t, s, \(\varepsilon\))
2:Combine uniform and random distribution to initialize position matrix \(X_{N\times D}\)
3:Generate the initial velocity \(V_{i}\) of each particle randomly
4:Evaluate the fitness value of each particle
5:Set \(p_{i}\) with a copy of \(X_{i}\)
6:Initialize g and \(\mathrm{bad}\) with the best and worst fitness value among population
7:While \(k<G\)
8:If \(k\geq 6\)
9:Update the slope of the fitness function curve
10:Slope = \((f(g)_{k}-f(g)_{k-5})/5\)
11:If\(Slope\leq\varepsilon\)
12:t = t + 1
13:End If
14:End If
15:Update inertia weight \(\omega\) by Equations (8) and (9)
16:For\(i=1:N\)
17:Update the velocity \(V_{i}\)
18:\(v_{ij}(k+1)=wv_{ij}(k)+r_{1}c_{1}\big{(}p_{i}-x_{ij}(k)\big{)}+r_{2}c_{2} \big{(}g-x_{ij}(k)\big{)}\)
19:Update the velocity \(X_{i}\)
20:If\(t=s\)
21:For\(m=1:50\)
22:\(x_{ij}(k)=x_{ij}(k)-r_{1}c_{1}\big{(}g-x_{ij}(k)\big{)}+r_{2}c_{2}\big{(}bad-x_ {ij}(k)\big{)}\)
23:End For
24:Else
25:\(x_{ij}(k+1)=x_{ij}(k)+v_{ij}(k+1)\)
26:End If
27:Calculate the fitness values of the new particle \(X_{i}\)
28:Execute position mutation
29:\(x_{ij}^{*}(k)=x_{ij}(k)-wv_{ij}(k)-w(g-p_{i})\)
30:Calculate the fitness values of the new particle \(X^{*}\)
31:If\(X_{i}\) or \(X^{*}\) is better than \(p_{i}\)
32:Update \(p_{i}\)
33:End If
34:If\(X_{i}\) or \(X^{*}\) is better than g
35:Update g
36:End If
37:If\(X_{i}\) or \(X^{*}\) is worse than \(bad\)
38:Update bad
39:End If
40:End For
41:k = k + 1
42:End While
```  
**Algorithm 1**The pseudo-code of the XPSO algorithm