*4.1. HPSO Algorithm*

Because of the uncertainty and nonlinearity of the control system, adjusting parameters of the controller by manual experience is usually hard, thus optimization algorithms are applied to obtain the optimal or suboptimal solution. PSO is a typical swarm intelligence algorithm developed in 1995, stemming from research on the foraging behavior of birds [27]. Studies in [28] have shown that it lacks the capability to achieve sustainable development and the swarm becomes stagnant after a certain number of iterations. To improve this, the

term of local optimal particle is introduced in the HPSO algorithm and the velocity and position of particles are updated according to the following two equations:

$$V\_{l}^{K+1} = \omega \cdot V\_{l}^{K} + c\_1 rand(p\_l^K - X\_l^K) + c\_2 (q \cdot rand(S\_l^K - X\_l^K) + (1 - q) \cdot rand(p\_{lL}^K - X\_l^K)) \tag{10}$$

$$X\_i^{K+1} = X\_i^K + V\_i^{K+1} \cdot dt \tag{11}$$

where *K* is the current number of evolution and at the *K*-th evolution, *V<sup>K</sup> <sup>i</sup>* denotes the velocity of the *i*-th particle; *X<sup>K</sup> <sup>i</sup>* represents the position of the *<sup>i</sup>*-th particle; *<sup>p</sup><sup>K</sup> <sup>i</sup>* depicts the best position of *i*-th particle; *S<sup>K</sup> <sup>i</sup>* is the best position of the particle swarm; *<sup>p</sup><sup>K</sup> iL* is the position of the local optimal particle for the *i*-th particle, and the introduction of *p<sup>K</sup> iL* avoids falling into the local optimal region. *ω* is inertia weight, which decreases as evolution unfolds and aids in global search in the early stage and local optimization in the late stage. *c*<sup>1</sup> and *c*<sup>2</sup> are learning factors, *q* represents social factor, and *dt* denotes time interval coefficient.

Instead of single-object optimization, we consider multiple objects in our study, including the steady-state performance and transient performance of AUV motion control system. And the objective function is defined as follows:

$$F = \log\left(1 + \frac{p\_\text{-vibration}}{p\_\text{-vibration0}}\right) + \log\left(1 + \frac{q\_\text{-vibration}}{q\_\text{-vibration0}}\right) + \log\left(1 + \frac{r\_\text{-vibration}}{r\_\text{-vibration0}}\right) + \log\left(1 + \frac{p\_\text{-ts}}{p\_\text{-ts0}}\right)$$

$$+ \log\left(1 + \frac{q\_\text{-ts}}{q\_\text{-ts0}}\right) + \log\left(1 + \frac{r\_\text{-ts}}{r\_\text{-ts0}}\right) + \log\left(1 + \frac{z\_\text{-ITAE}}{z\_\text{-ITAE0}}\right) + \log\left(1 + \frac{\vartheta\_\text{-ITAE}}{\vartheta\_\text{-ITAE0}}\right)$$

where (·)\_*vibration* represents oscillation times of AUV angular velocity; (·)\_*ts* is the settling time in which the angular velocity is kept within a ±5% range of the steady state value; (·)\_*ITAE* describes the ITAE index of track error;*p*\_(*vibration*0) which denotes the expected value and is set artificially, all of the expected values are presented in Appendix A.

The flowchart of optimization is shown in Figure 9 and the implementation procedure of the HPSO algorithm is summarized as follows:

Step 1: Specify the population size and the maximum number of evolutions, as well as other coefficients that can be noted from Equations (10)–(12). Determine the value range of controller parameters and initialize a population of particles with random positions.

Step 2: Evaluate the fitness value of all particles according to Equation (12), let *p<sup>K</sup> <sup>i</sup>* of each particle equal to its current position and let *S<sup>K</sup> <sup>i</sup>* equal the position of the best initial particle. After that, the local optimal position of each particle, *p<sup>K</sup> iL*, is obtained in accordance with Appendix A.

Step 3: Update the particles' velocities and positions in terms of Equations (10) and (11). Compare the fitness value of each particle with its own best fitness value, if the current one is better, update the *p<sup>K</sup> <sup>i</sup>* . Similarly, compare the best fitness value of the new generation with the fitness value of the global best position *S<sup>K</sup> <sup>i</sup>* and decide whether it has to be updated. The local optimal position of each particle is also updated.

Step 4: The optimization is terminated when it reaches the maximum number of evolutions. Then the global best position is output, which is the target parameters of the controller. The convergence curve of optimal fitness value is also printed.

**Figure 9.** Flowchart of HPSO algorithm.
