# Optimization-Based Input-Shaping Swing Control of Overhead Cranes
## 3 Design of Input Shaper
### Optimization of Shaper Based on PSO Algorithm  
The shaper parameters obtained using the above analytical method may not be optimal based on (9), and this is because the system (9) is a simplified model of a practical crane. In order to achieve better swing suppression, these parameters need to be optimized. Herein, the PSO algorithm is used to optimize these parameters, and the ZVD shaper is taken as an example to illustrate the optimization process. There are five parameters (\(A_{1}\), \(A_{2}\), \(A_{3}\), \(t_{2}\), and \(t_{3}\)) that need to be optimized, corresponding to the components in the position vector \(\mathbf{P}_{i}\) and the velocity vector \(\mathbf{V}_{i}\) of a particle, i.e.,  
\[\mathbf{P}_{i}=\left(p_{i1},p_{i2},p_{i3},p_{i4},p_{i5}\right)\,\ i=1,2,\cdots,n \tag{10}\]  
\[\mathbf{V}_{i}=\left(v_{i1},v_{i2},v_{i3},v_{i4},v_{i5}\right)\,\ i=1,2,\cdots,n \tag{11}\]  
where \(n\) is the number of particles. Suppose that the optimal parameters searched by the \(i\)th particle so far are defined as individual optimal values, and the optimal parameters searched by the whole particle swarm so far are global optimal values, denoted by (12) and (13), respectively. \[\mathbf{P}_{best_{i}}=\left(p_{bi1},p_{bi2},p_{bi3},p_{bi4},p_{i5}\right)\,\ i=1,2, \cdots,n \tag{12}\]  
\[g_{best}=\left(g_{1},g_{2},g_{3},g_{4},g_{5}\right) \tag{13}\]  
Based on [16], the updates for \(\mathbf{P}_{i}\) and \(\mathbf{V}_{i}\) are carried out according to (14) and (15), respectively. The right side of (14) consists of three parts: \(\omega\mathbf{V}_{i}^{k}\) is the \"inertial\" part, representing the trend of particles to maintain their previous changes; \(c_{1}r_{1}\left(\mathbf{P}_{best_{i}}^{k}-\mathbf{P}_{i}^{k}\right)\) is the \"cognition\" part, representing the trend of particles to approach the optimal parameter values searched in their own history; and \(c_{2}r_{2}\left(\mathbf{g}_{best}^{k}-\mathbf{P}_{i}^{k}\right)\) is the \"social\" part, representing the trend of particles to approach the optimal parameter values searched via the group history. \[\Psi_{i}^{k+1}=\omega\;\Psi_{i}^{k}+c_{1}r_{1}\Big{(}\mathbf{P}_{best_{i}}^{k}-\mathbf{P} _{i}^{k}\Big{)}+c_{2}r_{2}\Big{(}\mathbf{g}_{best}^{k}-\mathbf{P}_{i}^{k}\Big{)} \tag{14}\]  
\[\mathbf{P}_{i}^{k+1}=\mathbf{P}_{i}^{k}+\mathbf{V}_{i}^{k+1} \tag{15}\]  
where \(\omega\) is the inertia weighting coefficient, and \(c_{1}\) and \(c_{2}\) are the learning factors of the individual and group, respectively. These two factors represent the influence of the optimal position on the current speed. Additionally, \(r_{1}\) and \(r_{2}\) are variables with a uniform distribution on the interval of \([0,1]\). It is worth noting that the inertia weighting coefficient \(\omega\) has a great influence on the search ability [24]. Increasing the \(\omega\) helps to enhance the global search ability, while decreasing the \(\omega\) helps to enhance the local search ability. In general, the \(\omega\) takes a large, fixed value, which makes the later stage of the multi-parameter optimization have problems such as large fluctuations, a long duration, and inaccuracy. To this end, a cosine adjustment method is proposed for the weighting coefficient, as shown in (16). And the PSO with (16) is named as improved weighting coefficient PSO (IWCPSO). It can be seen from (16) that the coefficient value is larger, and the change rate is slower in the early stage, and the value is smaller, and the change rate is faster in the later stage. \[\omega(k)=0.1r_{3}\omega_{\min}(1-\cos(h_{1}))+\omega_{\max}\cos(h_{1}) \tag{16}\]  
where \(\omega_{\max}\) and \(\omega_{\min}\) are the maximum and minimum inertia weighting coefficients, respectively. \(r_{3}\) is a variable with a uniform distribution on the interval of [0, 1], and \(h_{1}\) is the adjustment variable expressed as \(0.5\pi k/k_{\max}\) (\(k_{\max}\) is the maximum number of iterations). The complete PSO optimization process includes initialization, the calculation of the fitness function, position and speed update, and so on.