# Quadrotor Formation Strategies Based on Distributed Consensus and Model Predictive Controls
## 3 Dynamic Model of a Quadrotor
### Model Predictive Control
#### 4.2.2 Unconstrained Quadratic Programming Problem  
The quadratic programming problem deals with the quadratic cost function that is subject to linear equality and/or inequality constraints on the variables in the cost function. A quadratic programming problem can be stated as follows:  
\[ \begin{array}{rcl}minimize&J_{QP}&=&\dfrac{1}{2}\mathbf{\xi}^{T}Q_{c}\mathbf{\xi}+ \mathbf{c}^{T}\mathbf{\xi},\\ subject\ to&A_{c}\mathbf{\xi}&\leq&\mathbf{b},\\ &E\mathbf{\xi}&=&\mathbf{d},\end{array}  \tag{20}\]  
where \(J_{QP}\) denotes the cost function of the quadratic programming problem. \(\mathbf{\xi}\in\mathbb{R}^{n}\) is a column vector that contains \(n\) variables to be optimized. \(Q_{c}\in\mathbb{R}^{n\times n}\) is a real symmetric matrix. \(\mathbf{c}\in\mathbb{R}^{n}\) is a real-valued column vector. \(A_{c}\in\mathbb{R}^{m\times n}\) and \(\mathbf{b}\in\mathbb{R}^{m}\) describe the inequality constraints of the variables. Similarly, \(E\in\mathbb{R}^{m\times n}\) and \(\mathbf{d}\in\mathbb{R}^{m}\) describe the equality constraints of the variables. To find an analytical solution to a constrained quadratic programming problem is difficult, if not impossible. However, it can still be solved by methods such as interior-point, active-set, or gradient-projection. On the contrary, the optimized solution to the unconstrained quadratic programming problem can be found simply by solving the linear equations of the partial derivative of the modified cost function with respect to each variable and set to zero. In formation control, our objective is to find the control input that tracks the reference trajectory. By rewriting the LQT into a quadratic programming problem, the variables to be optimized become the control input sequence. That is, we can obtain the optimal control sequence by solving linear equations directly. To rewrite the cost function, we start from rearranging the discrete state-space model (16). Expanding the discrete state-space model with respect to time step \(k\) (\(k=0,1,...,N_{p}-1\)):  
\[\mathbf{x}_{1} = Ax_{0}+Bu_{0},\] \[\mathbf{x}_{2} = Ax_{1}+Bu_{1}=A\left(Ax_{0}+B_{0}\right)+B\mathbf{u}_{1}=A^{2}\mathbf{x} _{0}+ABu_{0}+Bu_{1},\] \[\mathbf{x}_{3} = Ax_{2}+Bu_{2}=A\left(A^{2}\mathbf{x}_{0}+AB\mathbf{u}_{0}+B\mathbf{u}_{1} \right)+B\mathbf{u}_{2}=A^{3}\mathbf{x}_{0}+A^{2}Bu_{0}+AB\mathbf{u}_{1}+Bu_{2},\] \[\vdots\] \[\mathbf{x}_{N_{p}} = Ax_{N_{p}-1}+Bu_{N_{p}-1}=A^{N_{p}}\mathbf{x}_{0}+A^{N_{p}-1}Bu_{0}+ \cdots+Bu_{N_{p}-1},\]and defining the following vectors:  
\[ \begin{array}{rcl}\widetilde{\mathbf{x}}&=&\left[\begin{array}{cccc}\mathbf{x}_{1}^{T} &\mathbf{x}_{2}^{T}&\cdots&\mathbf{x}_{N_{p}}^{T}\end{array}\right]^{T},\\ \widetilde{\mathbf{u}}&=&\left[\begin{array}{cccc}\mathbf{u}_{0}^{T}&\mathbf{u}_{1}^{T}& \cdots&\mathbf{u}_{N_{p}-1}^{T}\end{array}\right]^{T},\end{array}  \tag{22}\]  
where \(\widetilde{\mathbf{x}}\in\mathbb{R}^{nN_{p}\times 1}\) and \(\widetilde{\mathbf{u}}\in\mathbb{R}^{mN_{p}\times 1}\). Equation (21) can be rewritten into the matrix form expressed by the initial condition and the vectors in Equation (22) as follows:  
\[ \begin{array}{rcl}\widetilde{\mathbf{x}}&=&\left[\begin{array}{cccc}A\\ A^{2}\\ A^{3}\\ \vdots\\ A^{Np}\end{array}\right]\mathbf{x}_{0}+\left[\begin{array}{cccc}B&0_{n\times m }&\cdots&0_{n\times m}\\ AB&B&\cdots&\vdots\\ \vdots&\vdots&\ddots&0_{n\times m}\\ A^{N_{p}-1}B&A^{N_{p}-2}B&\cdots&B\end{array}\right]\widetilde{\mathbf{u}}\\ &=&\widetilde{A}\mathbf{x}_{0}+\widetilde{B}\widetilde{\mathbf{u}},\end{array}  \tag{23}\]  
where \(\widetilde{A}\in\mathbb{R}^{nN_{p}\times n}\) and \(\widetilde{B}\in\mathbb{R}^{nN_{p}\times mN_{p}}\). Before substituting Equation (23) into the cost function (17), substitute the output function in Equation (16) into cost function (17) and expand the cost function:  
\[