## 4 The FO PI\({}^{\lambda}\)D\({}^{\mu}\) Controller of a Ship's Course
### Autotuning of the FO PI\({}^{\lambda}\)D\({}^{\mu}\) Controller Based on the IPSO Algorithm
The effect of the values of \(c_{1}\) and \(c_{2}\) on the search for an optimum is as follows:  
* If \(c_{1}\) and \(c_{2}\) are both set to 0, the particle flight velocity will remain constant, making it impossible to search the entire space;
* If \(c_{1}=0\), the particle loses its cognitive ability and easily falls into a local optimum solution;
* If \(c_{2}=0\), which leads to a lack of communication and cooperation between particles, the algorithm will fall into a local minimum, and the probability of obtaining an optimal solution will become smaller;
* Smaller values for both \(c_{1}\) and \(c_{2}\) result in particles flying away from the target area and oscillating in that area;
* With larger values for both \(c_{1}\) and \(c_{2}\), particles fly faster toward the target area, and this may also cause particles to fly away from the target area. In general, when using PSO algorithms to solve engineering optimization problems, the goal is to allow the particle in the swarm to perform optimization in the entire search space at the early stage to avoid the problem of lost local optima. In the later stages of the search, the goal is to increase the convergence accuracy and algorithm speed, which can lead to finding the global optimal solution quickly and efficiently. Therefore, the disadvantages of traditional methods can be overcome by introducing the dynamic accelerated learning factors \(c_{1}\) and \(c_{2}\) in the PSO algorithms. The maximum initial value of the learning factor is set to 2, while \(c_{1}\) and \(c_{2}\) are constructed as functions (i.e., monotonically decreasing and monotonically increasing functions, respectively) with the expressions shown in Equations (30) and (31):  
\[c_{1}(t)=2\Big{(}1-e^{(-t/t_{max})}\Big{)} \tag{30}\]  
\[c_{2}(t)=2e^{(t-t_{max})/t_{max}} \tag{31}\]  
Therefore, the particle swarm velocity update equation is  
\[\overline{v}_{i}(t+1)\ =\ \omega\overline{v}_{i}(t)\ +\ c_{1}(t)r_{1}( \overline{p}_{i}(t)\ -\ \overline{x}_{i}(t))+\ c_{2}(t)r_{2}\Big{(}\overline{p}_{g}(t)\ -\ \overline{x}_{i}(t)\Big{)} \tag{32}\]  
In the early stages of evolution, if \(c_{1}\) takes a larger value and \(c_{2}\) takes a smaller value, this will allow the particles to move throughout the search space. In the later stages, if \(c_{1}\) takes a smaller value and \(c_{2}\) takes a larger value, this will increase the convergence rate toward the optimal solution. In this paper, two classical benchmark functions (Griewank and Schaffer) are selected to conduct comparative simulations on the PSO algorithm [31] and the IPSO algorithm with the dynamic acceleration learning factor, which are used to verify the correctness and superiority of the IPSO algorithm. The Griewank function is as follows:  
\[minf(x_{i})\ =\sum_{i=1}^{N}\frac{x_{i}^{2}}{4000}-\prod_{i=1}^{N}cos\bigg{(} \frac{x_{i}}{\sqrt{i}}\bigg{)}\ +\ 1 \tag{33}\]  
where \(x_{i}\in[-600,600]\). The function has a local minimal value, the number of which is related to the dimensions of the problem, with a global minimum of 0, and \((x_{1},x_{2},\ldots,x_{n})\ =\ (0,0,\ldots,0)\) can be obtained. The function is typically a nonlinear multi-modal function with a wide search space and is often considered a complex multi-modal problem that is difficult for optimization algorithms to handle. The Schaffer function is as follows:  
\[ \begin{split} minf(x_{1},x_{2})=0.5+\frac{\left(sin\sqrt{x_{1+}^{2}x_ {2}^{2}}\right)^{2}-0.5}{\left[1+0.01\left(x_{1+}^{2}x_{2}^{2}\right)\right]^{2 }}\end{split}  \tag{34}\]  
where \(x_{1},x_{2}\in[-10,10]\). The function is a two-dimensional complex function with an infinite number of minimal value points, achieving a minimum value of 0 at (0,0). Since the function has a strongly oscillatory nature, it is difficult to find a globally optimal solution. The curves of the Griewank and Schaffer functions when their independent variables are two-dimensional are shown in Figure 5.  
In this paper, the Griewank and Schaffer functions are used to test the performance of the IPSO algorithm.