# Cutting-Edge Trajectory Optimization through Quantum Annealing
## 3 Transcription Procedure
As a result, the cost function transforms into a summation of the square of the control for each time instant, and it can be expressed as follows:  
\[ \begin{split} J&=\sum_{i=0}^{d}\mathbf{u}(t_{i})^{T} \mathbf{u}(t_{i})=\sum_{i=0}^{d}(P_{i}\mathbf{\alpha}+R_{i})^{T}(P_{i}\mathbf{\alpha} +R_{i}),\\ &=\mathbf{\alpha}^{T}(\sum_{i=0}^{d}P_{i}^{T}P_{i})\mathbf{\alpha}+2(\sum_ {i=0}^{d}R_{i}^{T}P_{i})\mathbf{\alpha}+(\sum_{i=0}^{d}R_{i}^{T}R_{i}).\end{split}  \tag{14}\]  
Value \((\sum_{i=0}^{d}R_{i}^{T}R_{i})\) can be safely disregarded since it remains constant. Its presence in a cost function is, therefore, inconsequential, as adding or subtracting a constant value from a cost function has no impact on the result. Then, by substituting \(P_{tot}=(\sum_{i=0}^{d}P_{i}^{T}P_{i})\) and \(V_{tot}=(\sum_{i=0}^{d}R_{i}^{T}P_{i})\) in Equation (14), the cost function can be succinctly formulated as  
\[J=\mathbf{\alpha}^{T}P_{tot}\mathbf{\alpha}+2V_{tot}\mathbf{\alpha}. \tag{15}\]  
The next step to achieve the QUBO Formulation is to express each real variable in \(\mathbf{\alpha}\) by a number of \(n_{b}\) binary variables. In executing this, the fixed-point binary representation is sought such that the maximum and minimum real values it can represent correspond to the boundaries of \(\mathbf{\alpha}\). Indeed, referring to Equation (16), the real variable \(\mathbf{\alpha}\) is equal to \(\mathbf{\alpha}=\mathbf{\alpha}_{min}\) when every \(z_{k}=0\), and \(\mathbf{\alpha}=\mathbf{\alpha}_{max}\), every \(z_{k}=1\). \[\mathbf{\alpha}=\mathbf{\alpha}_{min}+G\mathbf{z}\quad\text{with }\mathbf{z}=\{0,1\}, \tag{16}\]\[G=\frac{1}{2^{n_{b}}-1} \begin{bmatrix}(\Delta a_{x}\cdot\mathbf{g})&0&\cdots&0&0&0& \cdots&0&0\\ 0&0&\cdots&0&(\Delta a_{y}\cdot\mathbf{g})&0&\cdots&0&0\\ 0&0&\cdots&0&0&0&\cdots&0&(\Delta a_{z}\cdot\mathbf{g})\end{bmatrix} , \tag{17}\]  
where \(\boldsymbol{\alpha}_{min}\) and \(\boldsymbol{\alpha}_{max}\) are the upper and lower boundaries, respectively, matrix \(G\) has the size of \(n_{real}\times n_{b}n_{real}\) (\(n_{real}=3\)), \(\mathbf{g}\) has the size of \(n_{b}\) and represents the binary vector used for the binary form representation of integers, defined as \(\mathbf{g}=(2^{0},2^{1},\ldots,2^{n_{b}-1})\). Additionally, \(\Delta a_{i}=a_{max_{i}}-a_{min_{i}}\) (where \(i=x,y,z\)) denotes the difference between the upper and lower limits of the coefficient for each respective component. By substituting Equation (16) into Equation (15), an expression of the cost function in terms of binary variables \(\mathbf{z}\) is achieved (Equation (18)), where \(L\) is the matrix of quadratic terms, \(\bar{m}\) is the vector of linear terms, and \(N\) is a constant. By exploiting the fact that, for binary variables, \(\mathbf{z}^{T}\mathbf{z}=\mathbf{z}\), the linear term is included into the quadratic matrix, leading to the formulation on the right hand side of Equation (18), with \(Q=\bar{Q}+\text{diag}(L)\); furthermore, constant \(N\) can be ignored for the purpose of optimization. \[ \begin{split} J&=\mathbf{z}^{T}\bar{Q}\mathbf{z}+L \mathbf{z}+N\quad\Rightarrow\quad J=\mathbf{z}^{T}Q\mathbf{z},\\ \begin{cases}\bar{Q}=G^{T}P_{i}G\\ L=2\big{(}\boldsymbol{\alpha}_{min}^{T}P_{tot}+V_{tot}\big{)}G\\ N=\boldsymbol{\alpha}_{min}^{T}P_{tot}\boldsymbol{\alpha}_{min}+2V_{tot} \boldsymbol{\alpha}_{min}\end{cases}.\end{split}  \tag{18}\]  
The above-described methodology allows to formulate a linearized trajectory optimization as a QUBO problem, with the objective of minimizing the control employed and including the dynamical and boundaries constraints. The proposed approach offers a versatile and comprehensive solution for addressing a wide spectrum of linear optimal control problems. By transcending specific case limitations, it introduces a unified strategy that is adaptable to diverse challenges.