# Design of a Morphing Aircraft Based on Model Predictive Control
## 3 Controller Design
### Model Predictive Controller Design
\begin{array}{c}\mathbf{A}_{n\times n}\\ \mathbf{A}^{2}\\ \vdots\\ \mathbf{A}^{N_{p}}\end{array} \right]_{(nN_{p})\times n},\mathbf{\Gamma}=\left[ \begin{array} []{cccc}\mathbf{B}&\mathbf{0}&\cdots&\mathbf{0}\\ \mathbf{AB}&\mathbf{B}&\cdots&\mathbf{0}\\ \vdots&\vdots&\ddots&\vdots\\ \mathbf{A}^{N_{p}-1}\mathbf{B}&\mathbf{A}^{N_{p}-2}\mathbf{B}&\cdots&\mathbf{B}\end{array} \right]_ {(nN_{p})\times(pN_{p})} \tag{20}\]  
\(\mathbf{U}^{*}_{[k]}=\left[\mathbf{u}^{*}_{[k]i}\cdots\mathbf{u}^{*}_{[k+N_{p}-1]i}\right]\) is the input sequence. The design objective is to find the optimal control sequence \(\mathbf{U}^{*}_{[k]}\) that minimizes the performance index \(J\) in Equation (14). Let \(\mathbf{U}^{*}_{[k]}\) represent the performance index \(J\), which can be formulated in the standard quadratic programming form as follows:  
\[\underset{\mathbf{u}}{\min}J=\frac{1}{2}\mathbf{u}^{T}\mathbf{H}\mathbf{u}+\mathbf{u}^{T}\mathbf{g} \tag{21}\]  
At time step \(k\), when the prediction horizon is \(N_{p}\), Equation (14) can be rewritten as follows:  
\[J=\frac{1}{2}\mathbf{x}^{T}_{[k+N_{p}|k]}\mathbf{S}\mathbf{x}_{[k+N_{p}|k]}+\frac{1}{2} \sum_{i=0}^{N_{p}-1}[\mathbf{x}^{T}_{[k+|k]}\mathbf{Q}\mathbf{x}_{[k+i|k]}+\mathbf{u}^{T}_{[k+ i|k]}\mathbf{R}\mathbf{u}_{[k+i|k]}] \tag{22}\]  
Rewriting the summation in matrix multiplication form and substituting \(\mathbf{X}\) and \(\mathbf{U}\), considering that both \(\mathbf{Q}\) and \(\mathbf{R}\) are symmetric, yields the following:  
\[J=\frac{1}{2}\mathbf{x}^{T}_{[k]i}\mathbf{Q}\mathbf{x}_{[k|k]}+\frac{1}{2}\mathbf{X}^{T}_{[k] i}\mathbf{\Omega}\mathbf{X}_{[k]}+\frac{1}{2}\mathbf{U}^{T}_{[k]}\mathbf{\
abla}\mathbf{U}_{[k]} \tag{23}\]  
where \(\mathbf{\Omega}\) and \(\mathbf{\
abla}\) are given by the following:  
\[\mathbf{\Omega}\triangleq\left[ \begin{array}{ccc}\mathbf{Q}&\cdots&\mathbf{0}\\ \vdots&\mathbf{Q}&\vdots\\ \mathbf{0}&\cdots&\mathbf{S}\end{array} \right]_{(nN_{p})\times(nN_{p})}\mathbf{\
abla} \triangleq\left[ \begin{array}{ccc}\mathbf{R}&\cdots&\mathbf{0}\\ \vdots&\ddots&\vdots\\ \mathbf{0}&\cdots&\mathbf{R}\end{array} \right]_{(pN_{p})\times(pN_{p})} \tag{24}\]  
Further transforming the expression to express \(\mathbf{X}_{[k]}\) in terms of \(\mathbf{U}_{[k]}\), while ignoring the terms that are independent of \(\mathbf{U}_{[k]}\), results in the new performance index, expressed as follows:  
\[J=\mathbf{U}^{T}_{[k]}\mathbf{\Gamma}^{T}\mathbf{\Omega}\mathbf{\Phi}\mathbf{x}_{[k]}+\frac{1}{2} \mathbf{U}^{T}_{[k]}(\mathbf{\Gamma}^{T}\mathbf{\Omega}\mathbf{\Gamma}+\mathbf{\
abla})\mathbf{U}_{[k]} \tag{25}\]  
Redefining \(\mathbf{F}=\mathbf{\Gamma}^{T}\mathbf{\Omega}\mathbf{\Phi}\), \(\mathbf{H}=\mathbf{\Gamma}^{T}\mathbf{\Omega}\mathbf{\Phi}+\mathbf{\Psi}\), results in the following:  
\[J=\mathbf{U}^{T}_{[k]}\mathbf{F}\mathbf{x}_{[k]}+\frac{1}{2}\mathbf{U}^{T}_{[k]}\mathbf{H}\mathbf{U}_ {[k]} \tag{26}\]  
After substituting the various weight matrices, the optimal solution \(\mathbf{U}^{*}_{[k]}\) is obtained. By applying only the first element of the predicted sequence to the system, MPC receding horizon control is achieved. Next  
straints, Equation (27) must be converted into the standard constraint form expressed in terms of \(\mathbf{U}_{k}\). The constraint conditions in (27) can be expressed as follows:  
\[ \begin{split}&\mathbf{\mathcal{M}}_{[k]}\mathbf{x}_{[k|k]}+\mathbf{\mathcal{F}}_ {[k]}\mathbf{u}_{[k|k]}\leq\mathbf{\beta}_{[k]}\\ &\mathbf{\mathcal{M}}_{[k+1]}\mathbf{x}_{[k+1|k]}+\mathbf{\mathcal{F}}_{[k+1 ]}\mathbf{u}_{[k+1|k]}\leq\mathbf{\beta}_{[k+1]}\\ &\vdots\\ &\mathbf{M}_{[k+N_{p}-1]}\mathbf{x}_{[k+N_{p}-1|k]}+\mathbf{F}_{[k+N_{p}-1 ]}\mathbf{u}_{[k+N_{p}-1|k]}\leq\mathbf{\beta}_{[k+N_{p}-1]}\\ &\mathbf{M}_{N_{p}}\mathbf{x}_{[k+N_{p}]}\leq\mathbf{\beta}_{N_{p}}\end{split}  \tag{29}\]  
By rewriting Equation (29) into a compact matrix form, the following expression can be obtained:  
\[