# Fuzzy Model Predictive Control for Unmanned Helicopter
## 3 Control Methodology
### Model Predictive Control Principles
\[\Delta\mathbf{x}(k+1)=\mathbf{F}\Delta\mathbf{x}(k)+\mathbf{G}\Delta\mathbf{u}(k) \tag{4}\]  
\[\mathbf{F}=e^{\mathbf{A}\Delta t}\qquad\mathbf{G}=\int_{0}^{\Delta t}e^{\mathbf{A}\eta}\mathbf{B}d\eta \tag{5}\]  
The state prediction scheme for the controlled object, using the discrete linear dynamics model, is presented using the equation system below (6). \[\begin{cases}\mathbf{x}(k+1|k)=&\mathbf{F}\mathbf{x}(k)+\mathbf{G}\Delta\mathbf{u}(k)\\ \mathbf{x}(k+2|k)=&\mathbf{F}^{2}\The system of equations presented above can be transformed into the matrix form represented by Formula (7). \[\mathbf{X}=\mathbf{W}x(k)+\mathbf{Z}\Delta\mathbf{U}\] (7) where \(\bullet\quad\mathbf{X}\in\mathbb{R}^{N\cdot m}\) is the vector storing the state prediction of the control plant in the way presented by Equation (8) below: \[\mathbf{X}= \begin{bmatrix}x(k+1|k)\\ x(k+2|k)\\ \vdots\\ x(k+N|k)\end{bmatrix} \] (8) \(\bullet\quad\Delta\mathbf{U}\in\mathbb{R}^{N_{\text{u}}\cdot m}\) is the vector storing the resulting future control signal increments. The construction of the vector is presented below (9). \[\Delta\mathbf{U}= \begin{bmatrix}\Delta u(k)\\ \Delta u(k+1)\\ \vdots\\ \Delta u(k+N_{\text{u}}-1)\end{bmatrix} \] (9) \(\bullet\quad\) Matrices \(\mathbf{W}\in\mathbb{R}^{N\cdot m\times m}\) and \(\mathbf{Z}\in\mathbb{R}^{N\cdot m\times N_{\text{u}}\cdot n}\) take the form presented by Equation (10): \[\mathbf{W}= \begin{bmatrix}F\\ F^{2}\\ \vdots\\ F^{N}\end{bmatrix} \mathbf{Z}= \begin{bmatrix}\mathbf{G}&0&\cdots&0\\ \mathbf{FG}&\mathbf{G}&\cdots&0\\ \vdots&\vdots&\ddots&\vdots\\ \mathbf{F}^{N-1}\mathbf{G}&\mathbf{F}^{N-2}\mathbf{G}&\cdots&F^{N-N_{\text{u}}}\mathbf{G}\end{bmatrix} \] (10)  
Applying these results to the general formula for the previously defined cost function (2) and scaling it by \(\frac{1}{2}\) leads to the formula describing the cost function for the Dynamic Matrix Control variant of MPC (11). \[J(\Delta\mathbf{U})=\frac{1}{2}(\mathbf{\bar{r}}_{p}-\mathbf{W}x(k)-\mathbf{Z}\Delta\mathbf{U})^{T }\bar{\mathbf{Q}}(\mathbf{\bar{r}}_{p}-\mathbf{W}x(k)-\mathbf{Z}\Delta\mathbf{U})+\frac{1}{2} \Delta\mathbf{U}^{T}\bar{\mathbf{R}}\mathbf{U} \tag{11}\]  
where  
\(\bullet\quad\mathbf{\bar{r}}_{p}\in\mathbb{R}^{N\cdot m}\) is the block vector \([\mathbf{r}_{p}^{T},...,\mathbf{r}_{p}^{T}]^{T}\). \(\bullet\quad\bar{\mathbf{Q}}\in\mathbb{R}^{N\cdot m\times N\cdot m}\) is the block diagonal matrix built from the \(\mathbf{Q}\) matrices from definition (2). \[\bar{\mathbf{R}}= \begin{bmatrix}\mathbf{R}&\mathbf{0}&\cdots&\mathbf{0}\\ \mathbf{0}&\mathbf{R}&\ddots&\vdots\\ \vdots&\ddots&\ddots&\mathbf{0}\\ \mathbf{0}&\cdots&\mathbf{0}&\mathbf{R}\end{bmatrix}  \tag{13}\]A necessary condition for the existence of a minimum of a multivariable function is that the gradient of the scalar cost function with respect to the vector of decision variables vanishes. In the considered case, the optimal control increment vector \(\Delta\mathbf{U}\) results from setting the first derivative of the scalar cost function \(J(\Delta\mathbf{U})\) with respect to the future control increments vector \(\Delta\mathbf{U}\) to zero. An analytical expression for the first derivative of cost function is presented below (14). \[\frac{\partial J}{\partial\Delta\mathbf{U}}=-\mathbf{Z}^{T}\bar{\mathbf{Q}}\big{(}\mathbf{r}_ {p}-\mathbf{W}x(k)-\mathbf{Z}\Delta\mathbf{U}\big{)}+\bar{\mathbf{R}}\Delta\mathbf{U}=\mathbf{0} \tag{14}\]  
For a minimization task, where no constraints are considered, there exists an analytical solution. The explicit formula for the future control vector \(\Delta\mathbf{U}\) is given by Equation (15) below:  
\[\Delta\mathbf{U}=\Big{[}\bar{\mathbf{R}}+\mathbf{Z}^{T}\bar{\mathbf{Q}}\mathbf{Z}\Big{]}^{-1}\mathbf{Z }^{T}\bar{\mathbf{Q}}\big{[}\mathbf{r}_{p}-\mathbf{W}\mathbf{x}(k)\big{]} \tag{15}\]  
A sufficient condition for the existence of a local minimum is that the Hessian matrix of the cost function, i.e., the matrix of second-order partial derivatives with respect to \(\Delta\mathbf{U}\), is positive definite at the stationary point.