## 3 NLP-Based ECMS Algorithm
### Nonlinear Programming  
The NLP-based ECMS algorithm calculated the reference SOC trajectory. NLP then calculated the solution for a nonlinear optimal control problem (NOCP) by using a solver. The NOCP was derived from the vehicle model and driving conditions. The IPOPT solver calculated the solution for the NOCP. The solution for the NOCP, the result of IPOPT, was the reference SOC trajectory. The more accurately and efficiently the NOCP was defined, the higher the quality of the solution provided by NLP derived from the solver [38; 39; 40; 41; 42]. The NOCP can be explained in three parts. The first part involves a nonlinear system dynamics model. The state vector, input vector, and known-disturbance vector of the HEV model is shown in Equation (8). The system dynamics equations of the components are represented by state space by using vectors, as shown in Equation (9). As part of the simplification work to accelerate the NLP computation, the speed of the EM was treated as a known disturbance. This is because the solution of the NLP, which was used indirectly in the form of the SOC, was determined to satisfy the required torque derived from the EM speed. We have  
\[x= \begin{bmatrix}T_{eng}\\ T_{mot}\\ SOC\end{bmatrix} ,\;u= \begin{bmatrix}T_{cmd,\;eng}\\ T_{cmd,\;mot}\end{bmatrix} ,\;\text{and}\;d=w_{mot}=w_{ref} \tag{8}\]  
\[\dot{x}= \begin{bmatrix}\dot{T}_{eng}\\ \dot{T}_{mot}\\ \dot{S}\dot{O}\end{bmatrix} = \begin{bmatrix}\frac{1}{\tau_{eng}}.\left(-T_{eng} +T_{cmd,\;eng}\right)\\ \frac{1}{\tau_{mot}}.\left(-T_{mot}+T_{cmd,mot}\right)\\ -\frac{1}{Q_{mot}}.\left(\frac{v_{ac}-\sqrt{\
u_{ac}{}^{2}-4\cdot R_{int}\cdot T _{mot}\cdot w_{mot}}}{2\cdot R_{int}}\right)\end{bmatrix} =f(x,u,d). \tag{9}\]  
The second part involves nonlinear constraints. The system model was used in NLP to predict how the HEV would behave within the time horizon. That is, the system model operated as a nonlinear constraint when the NLP calculated the solution. The NLP-based ECMS includes constraints of the time horizon by applying the system model to a fourth order Runge-Kutta method, which is a discretization method. The fourth-order Runge-Kutta method is shown in Equation (10). We have  
Figure 5: Gear shift rule. (**a**) Upshift map. (**b**) Downshift map. \[x[k+1]=x[k]+\frac{T_{step}}{6}.(k_{1}+2\cdot k_{2}+2\cdot k_{3}+k_{4}) \tag{10}\] \[k_{1}=f(x[k],\ u[k],\ d[k])\] \[k_{2}=f\big{(}x[k]+0.5\cdot T_{step}\cdot k_{1},\ u[k],\ d[k]\big{)}\] \[k_{3}=f\big{(}x[k]+0.5\cdot T_{step}\cdot k_{2},\ u[k],\ d[k]\big{)}\] \[k_{4}=f\big{(}x[k]+T_{step}\cdot k_{3},\ u[k],\ d[k]\big{)}.\]  
The Runge-Kutta method, which requires a relatively large amount of computation, was applied rather than the Euler method, which has a small amount of computation, because the step time (\(T_{step}\)) can be relatively large. A large step time can predict longer intervals using the same number of receiving horizons. Equation (10) can be reformulated to equality constraints, as shown in Equation (11). The first nonlinear constraint was derived from a system dynamics model. We have  
\[g_{1}(x)=x[k+1]-\bigg{\{}x[k]+\frac{T_{step}}{6}.(k_{1}+2\cdot k_{2}+2\cdot k_{ 3}+k_{4})\bigg{\}}=0. \tag{11}\]  
If the described Runge-Kutta method is used, the initial value of the state vector is important because it is accumulated from the initial value. That means the initial values of the state vector are also equality constraints. The initial values of engine torque, motor torque, and SOC were set as shown in Equation (12). Because the SOC must be situated within a certain range at the end of driving, the final value was also important for the SOC. The final value of the SOC was also set to an equality constraint as in Equation (13). We have  
\[\left\{ \begin{array}{l}g_{2}(x)=x_{1}(0)=T_{eng0}=0\\ g_{3}(x)=x_{2}(0)=T_{mot0}=0\\ g_{4}(x)=x_{3}(0)=SOC_{0}=0.6\end{array} \right. \tag{12}\]  
\[g_{5}(x)=x_{3}\Big{(}T_{fin}\Big{)}=SOC_{fin}. \tag{13}\]  
The maximum/minimum torque is determined by the speed (\(w_{ref}\)).