## 4 Controller Design of AEBS
### Solve the Nonlinear Constrained Predictive Optimal Control  
In this section, the Sequence Quadratic Program (SQP) algorithm is adapted to solve the nonlinear constrained predictive optimize control problem denoted in Equation (9).  
For convenience, we have changed the upper and lower bounds in Equation (9) to the following form:  
\[A_{c}x\geq b_{c} \tag{11}\]  
\[A_{c}=[I,-I]^{T},b_{c}=[x_{\text{Lim},\text{min}},x_{\text{Lim},i}]^{T}, \tag{12}\]  
where \(I\) is a 4 by 4 identity matrix.  
Then, the constrained optimization problem in Equation (9) can be transformed into the following with the Lagrange method:  
\[L(x,\varphi)=PI(x)-\sum_{i\in\varphi}\varphi_{i}(\alpha_{i}x-b_{i}), \tag{13}\]  
where \(i\in\psi\) are inequality constraints.  
SQP can be expressed as:  
\[A_{a}(x)=\{i\in\psi|A_{c}x\geq b_{c}\}. \tag{14}\]  
Assume the quadratic programming equation defined at \(\Big{(}x^{(k)},\varphi^{(k)}\Big{)}\) is denoted as  
\[\text{min}\ q(p)=\
abla PI_{k}^{T}p+\frac{1}{2}p^{T}W_{k}p \tag{15}\]  
\[s.t.\ A_{k}^{T}p+A_{c}(x_{k})-b_{c}\geq 0, \tag{16}\]  
then the inequality problem can be rewritten as an equality problem within \(I^{(k)}\):  
\[\text{min}\ \
abla PI_{k}^{T}p+\frac{1}{2}p^{T}W_{k}p \tag{17}\]  
Let \(\delta=p-p^{(k)}\), hence  
\[q\Big{(}\delta+p^{(k)}\Big{)}=\
abla PI_{k}^{T}\delta+\frac{1}{2}\delta^{T}W_ {k}\delta+q\Big{(}p^{(k)}\Big{)}. \tag{18}\]  
Removing \(q\Big{(}p^{(k)}\Big{)}\) has no influence on the results, and the solution at \(kth\) is equivalent to that of the following optimization problem:  
\[\text{min}\ \
abla PI_{k}^{T}\delta+\frac{1}{2}\delta^{T}W_{k}\delta \tag{19}\]  
\[s.t.\ a^{i}\delta=0,i\in I^{(k)}. \tag{20}\]  
Assuming the solution to optimization Equation (19), \(\delta_{k}\), to be nonzero, the step length needs to be determined within \(p_{k}+\delta_{k}\) in the constraints:  
\[p_{k+1}=p_{k}+\delta_{k}. \tag{21}\]  
Otherwise, set:  
\[p_{k+1}=p_{k}+\alpha_{k}\delta_{k}. \tag{22}\]In order to get the biggest descent gradient of \(q\), \(\alpha_{k}\) needs to be as large as possible in [0, 1], hence we define \(\alpha_{k}\) as  
\[\alpha_{k}\stackrel{{ def}}{{=}}\min\left(1,\min_{i\
otin I^{(k)},i \
otin k<0}\frac{b_{c,i}-a_{c,i}^{T}p_{k}}{a_{c,i}^{T}\delta_{k}}\right). \tag{23}\]  
Any SQP optimization problem can be quasi-static convergence dependent on Lagrangian Hessian approximation \(W_{k}\); however, for convenience, quasi-Newton \(B_{k}\) is often adapted rather than \(W_{k}\):  
\[s_{k} =x_{k+1}-x_{k} \tag{24}\] \[y_{k} =\
abla_{x}L(x_{k+1},x_{k+1})-\
abla_{x}L(x_{k},x_{k})\] (25) \[B_{k+1} =B_{k}-\frac{B_{k}s_{k}s_{k}^{T}B_{k}}{s_{k}^{T}B_{k}s_{k}}+\frac {y_{k}y_{k}^{T}}{s_{k}^{T}y_{k}}. \tag{26}\]  
However, this replacement is only feasible when \(\
abla_{xx}^{2}L\) is positive, and it can have poor performance otherwise. This issue can be fixed with a modification to the above algorithm. First, let  
\[r_{k}=\theta_{k}y_{k}-(1-\theta_{k})B_{k}s_{k}, \tag{27}\]  
where  
\[\theta_{k}=\left\{\begin{array}{ll}1,&if\;\;s_{k}^{T}y_{k}\geq 02s_{k}^{T}B_{ k}s_{k}\\ \frac{0.8s_{k}^{T}B_{k}s_{k}}{s_{k}^{T}B_{k}s_{k}-s_{k}^{T}y_{k}},&if\;\;s_{k}^ {T}y_{k}<0.2s_{k}^{T}B_{k}s_{k}\end{array}\right.. \tag{28}\]  
Upgrading \(B_{k}\) to be \(B_{k+1}\) according to Equation (28) can guarantee that \(B_{k+1}\) will be positive, and hence a fast convergence can be obtained.  
\[B_{k+1}=B_{k}-\frac{B_{k}s_{k}s_{k}^{T}B_{k}}{s_{k}^{T}B_{k}s_{k}}+\frac{r_{k} r_{k}^{T}}{s_{k}^{T}r_{k}} \tag{29}\]  
With any initial state, the optimized \(u_{Con}^{*}\) can be obtained to get the optimized control target for AEBS with the algorithm described above.