# Optimization-Based Input-Shaping Swing Control of Overhead Cranes
## 3 Design of Input Shaper
### Optimization of Shaper Based on PSO Algorithm
The use of IWCPSO in ZVD parameter optimization is summarized below. Step 1: Initialization of particle swarm parameters. The related parameters are \(n=10\), \(k_{\max}=20\), \(IAE_{1i}=100\), and \(IAE_{g}=100\) (defined as (17), denoting the initial individual and group fitness values). In addition, the initial values of the position and velocity of each particle are uniformly distributed random values in the intervals of [0, 1] and [-0.05, 0.05], respectively. Step 2: Calculation of fitness function. Running the crane system under the action of the ZVD shaper, the fitness values of the pulse amplitude and time corresponding to the current dimension of each particle are calculated according to (17). \[IAE_{i}=\int_{0}^{T_{1}}|e_{i}(t)|dt=\sum_{j_{1}=0}^{T_{1}/T_{s}}|e_{i}(j_{1})| \tag{17}\]  
where \(e_{i}(t)=\theta_{i}(t)\), and \(T_{1}\) and \(T_{s}\) are the running time and sampling time of the system, respectively. Step 3: Update of parameters. The fitness values \(IAE_{i}\) and \(IAE_{1i}\) of each particle under the current and experienced optimal parameters are compared in turn. If \(IAE_{i}\leq IAE_{1i}\), it is updated as the optimal parameter of the corresponding individual, that is, \(\mathbf{P}_{best_{i}}=\mathbf{P}_{i}\). The current fitness value \(IAE_{i}\) of all particles and the fitness value \(IAE_{g}\) of the group under the optimal parameters are compared in turn. If \(IAE_{i}\leq IAE_{g}\), it is updated as the optimal parameter of the group, that is, \(g_{best}=\mathbf{p}_{i}\). Step 4: Update of the position and the velocity. According to (14)-(16), the velocity \(V_{i}\) and position \(P_{i}\) of each particle are updated. At the same time, the boundary conditions are treated based on (18):  
\[\left\{ \begin{array}{l}P_{ij}^{k+1}=1\;\;\;,\;\;\;if\;P_{ij}^{k+1}>1\\ P_{ij}^{k+1}=0\;\;\;,\;\;\;if\;P_{ij}^{k-1}<0\\ V_{ij}^{k+1}=0.05\;\;\;,\;\;if\;V_{i}^{k+1}>0.05\\ V_{ij}^{k+1}=-0.05\;\;,\;if\;V_{i}^{k+1}<-0.05\end{array} \right.\;\;\;\;j=1,2,3,4,5 \tag{18}\]  
Step 5: End judgment and output. Check whether the maximum number of iterations is reached. If it is not reached, return to Step 2; otherwise, the optimization ends, and the output is \(g_{best}\). \(g_{1}\), \(g_{2}\), \(g_{3}\), \(g_{4}\), and \(g_{5}\) in \(g_{best}\) are the optimal pulse amplitudes \(A_{1}\), \(A_{2}\), and \(A_{3}\) and the optimal pulse times \(t_{2}\) and \(t_{3}\) of the ZVD shaper, respectively. **Remark 1**. : _IAEs an important part of the PSO algorithm, which is used as the basis for parameter updating, and its value reflects the optimization performance. Herein, an initial value of 100 is taken to avoid the optimization termination caused by the fitness value obtained via the first iteration exceeding its initial value. The initial value can be adjusted according to the object and simulation results._  
Now, an overhead crane is used to test the effectiveness of the proposed scheme, and its dynamic parameters are \(m=0.25\) kg, \(l=0.10\) m, \(b=0.07\) Ns/rad, and \(\mu=0.2\). The relevant control parameters are \(\omega=0.9\), \(c_{1}=0.8\), and \(c_{2}=0.5\)(for the PSO algorithm), and \(\omega_{\text{max}}=0.9\), \(\omega_{\text{min}}=0.4\), \(c_{1}=0.8\), and \(c_{2}=0.5\) (for the IWCPSO algorithm). It should be noted that the selection of these control parameters should consider both the dynamic characteristics of the crane and the mechanism of these algorithms. The relationships between the global and local, and the individual and population, need to be balanced in order to achieve a better optimization performance. Additionally, the other parameters are \(T_{1}=6\) s and \(T_{s}=0.01\) s.  
In order to make the evaluation more comprehensive, the motion of the trolley is divided into three stages, acceleration, uniform speed, and deceleration, and the acceleration \(r_{a}(t)\) of the trolley is designated as the input of the swing system, given as \(r_{a}(t)\;=\;\left\{ \begin{array}{l}0.5,0\leq t<1\\ 0,1\leq t<2,3\leq t<6\\ -0.5,2\leq t<3\end{array}