This section formulates the energy-optimal braking problem and proposes a double-layer EOBS to improve regeneration energy while ensuring braking comfort and safety. In the upper-layer, the energy-optimal braking trajectory is planned by solving the optimal control problem. In the lower-layer, a tracking controller is used to track the optimized trajectory accurately while ensuring braking comfort and safety. Figure 2 shows the scheme of the proposed double-layer EOBS.

### 3.1 Energy-optimal Braking Trajectory Planning

The energy-optimal braking trajectory is planned by the DP algorithm. Since the DP has been widely used in the energy optimization problem [19], which divides the optimal control problem into simpler sub-problems and calculates recursively based on the Bellman optimality principle [26].

#### 3.1.1 Optimization Problem Formulation

Figure 3 shows the scenario of braking, where *D* is the distance to the destination (can be a stop line of the signalized intersection or a stopped preceding vehicle), *V*_{s} and *V*_{e} are the initial and desired terminal velocity, respectively. We assume the *D* and *V*_{e} are accessed by V2X communication, the *V*_{s} is obtained by using on-board sensors.

In this paper, the braking distance *D* is fixed, thus the whole problem is discretized in distance-domain by distance step Δ*d*. The total number of distance step *N*_{D} is determined by the *D* and Δ*d*, i.e., *N*_{D} = *D*/Δ*d* + 1. The velocity is selected as the state variable, i.e., *x*_{D} = *v*, and the braking deceleration *a* is selected as the control variable, i.e., *u*_{D} = *a*. Since the distance step is small, the braking deceleration of each sub-problem is assumed to be constant. Thus, the energy-optimal braking problem is expressed in Eq. (14) indexed by *k*:

$$\mathop {{\text{Minimum}}}\limits_{{u_{D} \in U}} \;J_{D} \left( {x_{D} \left( k \right),u_{D} \left( k \right)} \right) = \sum\limits_{k = 1}^{{k = N_{D} }} {P_{b} } \left( k \right)\Delta t_{D} \left( k \right) + \alpha \left( {v\left( {N_{D} } \right) - V_{e} } \right)^{2},$$

(14)

s.t.,

\(x_{D} \left( 0 \right) = V_{s}\),

\(x_{D} \left( {N_{D} } \right) = V_{e}\),

\(v\left( k \right) \in \left[ {v_{\min } ,\,v_{\max } } \right]\),

\(u_{D} \left( k \right) \in \left[ {a_{\min } ,\,a_{\max } } \right]\), where *v*_{min} and *v*_{max} are the minimum velocity for efficient traffic and the maximum velocity for road limitation, respectively. *a*_{min} and *a*_{max} are the deceleration depend on braking comfort and vehicle resistance, respectively. Δ*t*_{D} is the time interval. Note that the terminal condition of the velocity has been relaxed by converting them to soft constraints and merged into the objective function as Eq. (14), with weighting factor *α* for the latter term.

Besides, the state transfer of vehicle velocity and time interval in *k* step are calculated by Eqs. (15) and (16), respectively.

$$v\left( {k + 1} \right) = \left\{ {\begin{array}{*{20}c} {\sqrt {v^{2} \left( k \right) + 2a\left( k \right)\Delta d}, \;\;v^{2} \left( k \right) + 2a\left( k \right)\Delta d\; > 0,} \\ {0,\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;v^{2} \left( k \right) + 2a\left( k \right)\Delta d\; \le 0,} \\ \end{array} } \right.\;$$

(15)

$$\Delta t_{D} \left( k \right) = \frac{{v\left( {k + 1} \right) - v(k)}}{a(k)}\;.$$

(16)

#### 3.1.2 DP Solving

Denote the transitional cost-to-go function from *k* step to *k*+1 step *W*(*x*_{D}(*k*), *u*_{D}(*k*)) and the penalty function for the terminal states *G*(*x*_{D}(*N*_{D})), i.e.,

$$W\left( {x_{D} \left( k \right),u_{D} \left( k \right)} \right) = P_{b} \left( k \right)\Delta t_{D} \left( k \right),$$

(17)

$$G\left( {x_{D} \left( {N_{D} } \right)} \right) = \alpha \left( {v\left( {N_{D} } \right) - V_{e} } \right)^{2}.$$

(18)

The formulated control problem is solved recursively by following the Bellman optimality principle [[26]]:

*N*_{D} − 1 step:

$$J_{{N_{D} { - }1}}^{*} \left( {x_{D} \left( {N_{D} { - 1}} \right)} \right)$$

(19)

$$\mathop {\min }\limits_{{u_{D} \in U}} \left\{ {W\left( {x_{D} \left( {N_{D} - 1} \right),u_{D} \left( {N_{D} - 1} \right)} \right) + G\left( {x_{D} \left( {N_{D} } \right)} \right)} \right\},$$

*k* step:

$$J_{k}^{*} \left( {x_{D} \left( k \right)} \right)\; = \mathop {\min }\limits_{{u_{D} \in U}} \left\{ {W\left( {x_{D} \left( k \right),u_{D} \left( k \right)} \right) + J_{k + 1}^{*} \left( {x_{D} \left( {k + {1}} \right)} \right)} \right\},$$

(20)

where *J*_{k}^{*}(*x*_{D}(*k*)) is the minimum cost-to-go value at the moment *k*. Then, the energy-optimal braking trajectory and control law can be obtained by backward calculation.

### 3.2 Tracking Controller

#### 3.2.1 Tracking Problem Formulation

The objective of the tracking controller is to minimize the tracking error between the actual and original optimal trajectory, while adapts to traffic conditions for braking comfort and safety. In this paper, the vehicle velocity and distance error and vehicle force increment are defined as soft constraints, thus, the tracking problem is shown in Eq. (21):

$$\mathop {{\text{Minimum}}}\limits_{{u_{M} \in U}} \;J_{M} \left( {u_{M} {|}k} \right) = \sum\limits_{i = 1}^{{N_{p} }} {\left\| {\tilde{x}\left( {k + i|k} \right)} \right\|_{Q}^{2} } + \;\sum\limits_{j = 1}^{{N_{{\text{c}}} - 1}} {\left\| {\Delta \, u\left( {k + j|k} \right)} \right\|_{R}^{2} + \beta \varepsilon^{2} },$$

(21)

s.t.,

\(u_{\min } \left( {k + j} \right) \le u_{M} \left( {k + j} \right)\),

\(D{ - }L \le d\left( {N_{M} } \right) \le D\),

\(V_{e} { - }\vartheta \le v\left( {N_{M} } \right) \le V_{e}\),

where \(\tilde{x}\) = [*d*−*d*_{ref}, *v*−*v*_{ref}] is the vehicle states error. *d*_{ref} and *v*_{ref} are the original distance and velocity in the upper-layer solution, respectively, which are derived from the upper-layer optimization. Δ*u* is the increment of the control variable, (*u*_{M}|*k*) represents the derived control variable of the controller at *k* moment. *Q*, *R*, and *β* are the weighing factor matrix, *ε* is the relaxation factor, *N*_{p} and *N*_{c} are the prediction horizon and control horizon, respectively. *N*_{M} is the tracking problem horizon, which is determined by the length of the original trajectory. *L* is the vehicle length, *ϑ* is the velocity slack.

In tracking problem Eq. (21), the constraints including twofold. First, the vehicle force is subject to physical limits *u*_{min}, which is determined by the maximum comfort braking force and road adhesion. Secondly, the virtual stop region that including distance and velocity is defined as a buffer space that relies on safety distance and minimum steady velocity of EVs, then the actual terminal braking distance and velocity are meet the second and third constraints.

#### 3.2.2 Linear Time-varying State Prediction Model

Since the vehicle dynamics in Eq. (1) is nonlinear, it greatly increases the computational burden of MPC. Therefore, we employ the approximate linearization method [27] to transform the nonlinear time-varying model Eq. (1) to a linear time-varying (LTV) system:

$$\dot{\tilde{x}}=\left[ \begin{matrix} 0 & 1 \\ 0 & -\frac{{{C}_{D}}{{A}_{r}}\rho {{v}_{ref}}}{\delta m} \\ \end{matrix} \right]\tilde{x}+\left[ \begin{matrix} 0 \\ \frac{1}{\delta m} \\ \end{matrix} \right]\text{ }\tilde{u}$$

(22)

where \(\tilde{x} = \left[ {\begin{array}{*{20}c} {d - d_{ref} } & {v - v_{ref} } \\ \end{array} } \right]^\text{T}\), \(\tilde{u} = \left[ {\begin{array}{*{20}c} {F - F_{ref} } \\ \end{array} } \right]^\text{T}\), *F*_{ref} is the original braking force, which calculated by Eq. (23):

$$F_{ref} = mgf\cos \theta + mg\sin \theta + 0.5C_{D} A_{r} \rho v_{ref}^{2} \left( k \right) + m\delta a_{ref} \left( k \right).$$

(23)

Since the MPC calculates the control law discretely, the LTV system in Eq. (22) is converted to the discrete-time system using the Euler method [28]:

$$\tilde{x}\left( k+1 \right)=\left[ \begin{matrix} 1 & \Delta {{t}_{M}} \\ 0 & 1-\frac{{{C}_{D}}{{A}_{r}}\rho {{v}_{ref}}\left( k \right)\Delta {{t}_{M}}}{\delta m} \\ \end{matrix} \right]\tilde{x}\left( k \right)+\left[ \begin{matrix} 0 \\ \frac{\Delta {{t}_{M}}}{\delta m} \\ \end{matrix} \right]\tilde{u}\left( k \right),$$

(24)

where Δ*t*_{M} is the time step.

Denote a state prediction matrix:

$$\varsigma \left( {i + 1|k} \right) = \left[ {\begin{array}{*{20}c} {\tilde{x}\left( {i|k} \right)} \\ {\tilde{u}\left( {i - 1|k} \right)} \\ \end{array} } \right],$$

(25)

where (*i*|*k*) represents the *i*-step-ahead predicted error at the *k*th step. Substituting Eq. (24) into Eq. (25), a new state-space model is derived:

$$\left\{ {\begin{array}{*{20}c} {\varsigma \left( {i + 1|k} \right) = A_{k,i} \varsigma \left( {i|k} \right) + B_{k,i} \Delta \tilde{u}\left( {i|k} \right)}, \\ {\upsilon \left( {i|k} \right) = C_{k,i} \varsigma \left( {i|k} \right)}, \\ \end{array} } \right.$$

(26)

with

\(A_{k,i} = \left[ {\begin{array}{*{20}c} 1 & {\Delta t_{M} } & 0 \\ 0 & {1 - \frac{{C_{D} A_{r} \rho v_{ref} \left( {i|k} \right)\Delta t_{M} }}{\delta m}} & {\frac{{\Delta t_{M} }}{\delta m}} \\ 0 & 0 & 1 \\ \end{array} } \right],\)

$$B_{k,i} = \left[ {\begin{array}{*{20}c} 0 & {\frac{{\Delta t_{M} }}{\delta m}} & 1 \\ \end{array} } \right]^\text{T},$$

$$C_{k,i} = \left[ {\begin{array}{*{20}c} 1 & 0 & 0 \\ 0 & 1 & 0 \\ \end{array} } \right].$$

Finally, the state prediction model is listed in Eq. (27) by converting Eq. (26):

$$\tilde{Y}\left( k \right) = \Gamma_{k} \varsigma \left( k \right) + \Xi_{k} \Delta \tilde{U}\left( k \right),$$

(27)

with

$$\tilde{Y}\left( k \right) = \left[ {\begin{array}{*{20}c} {\upsilon \left( {k + 1|k} \right)} & \cdots & {\upsilon \left( {k + N_{c} |k} \right)} & \cdots & {\upsilon \left( {k + N_{p} |k} \right)} \\ \end{array} } \right]_{{1 \times N_{p} }}^{{\text{T}}} ,$$

$$\Delta \tilde{U}\left( k \right) = \left[ {\begin{array}{*{20}c} {\Delta \tilde{u}\left( {k{|}k} \right)} & {\Delta \tilde{u}\left( {k + 1{|}k} \right)} & \cdots & {\Delta \tilde{u}\left( {k + N_{c} {|}k} \right)} \\ \end{array} } \right]_{{1 \times N_{{\text{c}}} }}^{{\text{T}}} ,$$

$$\Gamma_{k} = \left[ {\begin{array}{*{20}c} {C_{k,i} A_{k,i} } & \cdots & {C_{k,i} A_{k,i}^{{N_{c} }} } & \cdots & {C_{k,i} A_{k,i}^{{N_{p} }} } \\ \end{array} } \right]_{{1 \times N_{p} }} ,$$

$$\Xi_{k} = \left[ {\begin{array}{*{20}c} {C_{k,i} B_{k,i} } & 0 & \cdots & 0 \\ {C_{k,i} A_{k,i} B_{k,i} } & {C_{k,i} B_{k,i} } & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ {C_{k,i} A_{k,i}^{{N_{c} }} B_{k,i} } & {C_{k,i} A_{k,i}^{{N_{c} - 1}} B_{k,i} } & \cdots & {C_{k,i} A_{k,i} B_{k,i} } \\ \vdots & \vdots & \ddots & \vdots \\ {C_{k,i} A_{k,i}^{{N_{p} - 1}} B_{k,i} } & {C_{k,i} A_{k,i}^{{N_{p} - 2}} B_{k,i} } & \cdots & {C_{k,i} A_{k,i}^{{N_{p} - N_{c} - 1}} B_{k,i} } \\ \end{array} } \right]_{{N_{p} \times N_{c} }} ,$$

where \(\tilde{Y}\left( k \right)\) and \(\Delta \tilde{U}\left( k \right)\) are output and control increments of the prediction model, respectively. Noted that according to the principle of MPC, the *N*_{c} ≤ *N*_{p}, and the control input that beyond *N*_{c} is equal to the last control input of *N*_{c}.

#### 3.2.3 Quadratic Programming Solving

The tracking problem is solved using the quadratic programming (QP) algorithm. Then, the objective function and constraints in Eq. (21) are converted to standard QP form Ref. [29], i.e.,

$$\begin{gathered} J_{M} \left( {\Delta \tilde{U}{|}k} \right) = \;\frac{1}{2}\left[ {\begin{array}{*{20}c} {\Delta \tilde{U}\left( k \right)^{{\text{T}}} } \\ \varepsilon \\ \end{array} } \right]\left[ {\begin{array}{*{20}c} {2\left( {\Xi_{k}^{{\text{T}}} Q\Xi_{k} + R} \right)} & 0 \\ 0 & {2\beta } \\ \end{array} } \right]\left[ {\begin{array}{*{20}c} {\Delta \tilde{U}\left( k \right)^{{\text{T}}} } \\ \varepsilon \\ \end{array} } \right]^{{\text{T}}} \hfill \\ \qquad \qquad \quad + \left[ {\begin{array}{*{20}c} {2E_{k}^{{\text{T}}} Q\Xi_{k} } \\ 0 \\ \end{array} } \right]^{{\text{T}}} \left[ {\begin{array}{*{20}c} {\Delta \tilde{U}\left( k \right)^{{\text{T}}} } \\ \varepsilon \\ \end{array} } \right]^{{\text{T}}} \hfill \\ \end{gathered}$$

(28)

s.t.,

\(D{ - }L \le d\left( {N_{M} } \right) \le D\),

\(V_{e} { - }\vartheta \le v\left( {N_{M} } \right) \le V_{e}\),

\(U_{{{\text{min}}}} \le \left[ {\begin{array}{*{20}c} 1 & \cdots & 0 \\ \vdots & \ddots & \vdots \\ 1 & \cdots & 1 \\ \end{array} } \right]_{{N_{{c}} \times N_{{c}} }} \Delta \tilde{U}\left( k \right) + 1_{{N{c}}} \Delta \tilde{u}\left( {k - 1} \right)\),

where 1_{Nc} is the column vector with *N*_{c} rows, *U*_{min} is the minimum value set of control input

$$U_{{{\text{min}}}} = \left[ {\begin{array}{*{20}c} {u_{\min } \left( k \right)} & {u_{\min } \left( {k + 1} \right)} & \cdots & {u_{\min } \left( {k + N_{{c}} - 1} \right)} \\ \end{array} } \right]_{{1 \times N_{{c}} }}^{{\text{T}}}.$$

(29)

A series of control input increments \(\Delta \tilde{U}_{k}^{ * }\) in the control horizon can be obtained by solving the QP problem. The predicted control input \(\tilde{u}^{*} \left( k \right)\) is the first term of the control sequence plus the previous control input \(\tilde{u}\left( {k - 1} \right)\):

$$\tilde{u}^{*} \left( k \right) = \tilde{u}\left( {k - 1} \right) + \left[ {\begin{array}{*{20}c} {I_{{N_{c} }} \;} & 0 & \cdots & 0 \\ \end{array} } \right]_{{1 \times N_{{c}} }} \Delta \tilde{U}_{k}^{ * }.$$

(30)

Finally, the predicted vehicle braking force *u*^{*}(*k*) is

$$u^{*} \left( k \right) = \tilde{u}^{*} \left( k \right) + F_{ref} \left( k \right).$$

(31)