# Optimization-Based Input-Shaping Swing Control of Overhead Cranes
## 4 Design of Adaptive Input Shaper
### Adaptive Adjustment of Shaper Parameters
\begin{array}{l}\Big{(}I-\mathbf{U}_{N}\big{(}\mathbf{U}_{N}{}^{\rm T} \mathbf{U}_{N}\big{)}^{-1}\mathbf{U}_{N}{}^{\rm T}\Big{)}\mathbf{Z}_{r}=\Big{(} I-\mathbf{U}_{N}\big{(}\mathbf{U}_{N}{}^{\rm T}\mathbf{U}_{N}\big{)}^{-1} \mathbf{U}_{N}{}^{\rm T}\Big{)}\Big{(}\mathbf{Y}_{N}\boldsymbol{h}-\mathbf{U} _{N}\boldsymbol{f}^{\boldsymbol{\rho}}\Big{)}=\\ \Big{(}I-\mathbf{U}_{N}\big{(}\mathbf{U}_{N}{}^{\rm T}\mathbf{U}_{N}\big{)}^{ -1}\mathbf{U}_{N}{}^{\rm T}\Big{)}(\mathbf{Y}_{N}\boldsymbol{h})=\mathbf{Z}_{ r\epsilon}\end{array}  \tag{31}\]  
It can be seen that \(\mathbf{Z}_{r\epsilon}\) can be measured, so the following performance indicator function can be selected:  
\[J_{N}=\Big{(}\mathbf{Z}_{r\epsilon}{}^{\rm T}\Big{)}\mathbf{Z}_{r\epsilon}= \boldsymbol{h}^{\rm T}\bigg{(}\mathbf{Y}_{N}^{\rm T}\mathbf{Y}_{N}-\mathbf{Y} _{N}^{\rm T}\mathbf{U}_{N}\Big{(}\mathbf{U}_{N}{}^{\rm T}\mathbf{U}_{N}\Big{)} ^{-1}\mathbf{U}_{N}{}^{\rm T}\mathbf{Y}_{N}\bigg{)}\boldsymbol{h} \tag{32}\]  
Make \(\mathbf{W}_{N}=\mathbf{Y}_{N}{}^{\rm T}\mathbf{Y}_{N}\), \(\mathbf{B}_{N}=\mathbf{Y}_{N}{}^{\rm T}\mathbf{U}_{N}\), and \(\mathbf{C}_{N}=\big{(}\mathbf{U}_{N}{}^{\rm T}\mathbf{U}_{N}\big{)}^{-1}\), respectively. Then, (32) can be simplified to (33):  
\[J_{N}=\boldsymbol{h}^{\rm T}\Big{(}\mathbf{W}_{N}-B_{N}\mathbf{C}_{N}\mathbf{ B}_{N}{}^{\rm T}\Big{)}\boldsymbol{h} \tag{33}\]where \(\mathbf{W}_{N}\), \(\mathbf{B}_{N}\), and \(\mathbf{C}_{N}\) can be obtained via the following iterative calculations of (34)-(36) based on the control \(u\) and output \(y\) of the system. \[\mathbf{W}_{N}=\lambda\mathbf{W}_{N-1}+\widetilde{\mathbf{Y}_{N}^{\mathrm{T}}}\widetilde{ \mathbf{Y}_{N}} \tag{34}\]  
\[\mathbf{B}_{N}=\lambda\mathbf{B}_{N-1}+\widetilde{\mathbf{Y}_{N}^{\mathrm{T}}}\widetilde{ \mathbf{U}_{N}} \tag{35}\]  
\[\mathbf{C}_{N}=\lambda^{-1}\mathbf{C}_{N-1}-\frac{\lambda^{-1}\mathbf{C}_{N-1}\widetilde{ \mathbf{U}_{N}^{\mathrm{T}}}\widetilde{\mathbf{U}_{N}}\widetilde{\mathbf{C}_{N-1}}}{\lambda +\widetilde{\mathbf{U}_{N}^{\mathrm{T}}}\mathbf{C}_{N-1}\widetilde{\mathbf{U}_{N}}} \tag{36}\]  
where \(\widetilde{\mathbf{Y}_{N}}=[y(N)y(N-1)\cdots y(N-K)]\), \(\widetilde{\mathbf{U}_{N}}=[u(N)u(N-1)\cdots u(N-K)]\), and \(0<\lambda<1\) (a forgetting factor). So far, the parameter optimization of shaper \(H\) can be divided into the following two steps, where one is to solve the optimal pulse amplitude and the other is to solve the optimal pulse time. (i) Solving the optimal pulse amplitude  
Fix the occurrence time \(\mathbf{t}=\{t_{1},t_{2},\cdots,t_{\mathrm{D}}\}\), where \(D\) represents the nonzero pulses in \(\mathbf{h}\), which corresponds to the amplitude \(\mathbf{A}=[A_{1},A_{2},\cdots,A_{D}]^{\mathrm{T}}\). Denote \(\mathbf{F}_{N}=\mathbf{W}_{N}-\mathbf{B}_{N}\mathbf{C}_{N}\mathbf{B}_{N}\)\({}^{\mathrm{T}}\) and then (33) can be simplified to \(J_{N}=\mathbf{A}^{\mathrm{T}}\widetilde{\mathbf{F}_{N}}\mathbf{A}\), where the \(D\)-dimensional square matrix \(\widetilde{\mathbf{F}_{N}}\) is a submatrix of \(\mathbf{F}_{N}\), and the rows and columns correspond to the position \(\mathbf{t}\) of the nonzero pulses in \(\mathbf{h}\). The gradient descent method is introduced to solve the optimal pulse amplitude \(\mathbf{A}_{N}\), i.e., \(\
abla J_{N}=\mathbf{2}\mathbf{F}_{N}\mathbf{A}_{N}\). In order to make the adaptive shaper still satisfy the constraint condition of the sum of pulse amplitudes being one, the orthogonal vector \(\mathbf{\beta}=[11\cdots 1]^{\mathrm{T}}_{D\times 1}\) of \(-\
abla J_{N}\) is considered, and the iterative relation of the optimal pulse amplitude is expressed as (37). \[\mathbf{A}_{N}=\mathbf{A}_{N-1}-\alpha\Big{(}\mathbf{I}-\frac{1}{D}\mathbf{\beta}\mathbf{\beta}^{ \mathrm{T}}\Big{)}\widetilde{\mathbf{F}_{N}}\mathbf{A}_{N-1} \tag{37}\]  
where \(\alpha=\frac{1-\lambda}{0.\mathbf{\Gamma}D}\). (ii) Solving the optimal pulse time  
Due to the time constraint of the shaper, the first pulse time \(t_{1}=0\) remains unchanged, so only a total of \(D-1\) pulse time values of \(\{t_{2},\cdots,t_{D}\}\) need to be solved.