# Adaptive MPC Based Real-Time Energy Management Strategy of the Electric Sanitation Vehicles
## 3 The Real-Time AMPC-Based EMS
### The Framework of AMPC-Based EMS  
Endowed with the prediction ability by the NARNN predictor proposed above, an AMPC based EMS can be established to optimize the power distribution and ensure clean tasks. Therefore, a control-oriented system can be expressed as  
\[y=f\left(\overset{\rightarrow}{x},\overset{\rightarrow}{u},d\right) \tag{12}\]  
In the formulation, the vehicle acceleration \(a_{v}\) (m/s\({}^{2}\)) and the rotating speed of the working motor \(n_{wm}\) (rpm) are considered the control variables, noted as a vector \(\overset{\rightarrow}{u}=[a_{v},n_{wm}]\); the SoC of the battery, vehicle velocity \(v\) (km/h), and working time \(t\) (s) are regarded as state variables, noted as a vector \(\overset{\rightarrow}{x}=[SoC,v,t]\); and the garbage density \(\delta\) (g/m\({}^{2}\)) is considered a disturbance variable, noted as \(d=\delta_{predict}\), which is predicted by the NARNN predictor. With the spatial step (\(\Delta x\)) set to 1 m, for each spatial step, the discrete cost-to-go function \(J_{n}\) is written as Equation (13):  
\[J_{n}=\sum_{n=k}^{k+L}\left(P_{wm}(n)+P_{dm}(n)\right)\cdot\frac{\Delta x}{10 00v(n)} \tag{13}\]  
where \(J_{n}\) (kW-h) represents the cost function on the prediction zone at the \(n\) step, which minimizes the electricity consumption of the sanitation vehicle represented by that of the working motor and the driving motor; \(L\) represents the length (m) of the prediction zone; \(v(n)\) represents the velocity (km/h) per spatial step; and the \(P_{wm}(n)\) and the \(P_{dm}(n)\) represent the electric power (kW) consumed by the working motor and the driving motor per spatial step, respectively. As mentioned before, the former can be calculated by Equations (3) and (6), whereas the latter one can be obtained by Equation (2). Figure 21: Prediction RMSE of the NARNN. Since the solution to this problem is a multistage process requiring a sequence of interrelated decisions, a local DP solver was implemented on the prediction zone to obtain optimal control series [30; 31]. Based on the power requirement model (Equations (6) and (7)) and the predicted garbage, the DP optimized the cost function through relationships expressed as  
\[v(k+1)=3.6\cdot\sqrt{2a(k)\Delta x+\left(v(k)/3.6\right)^{2}} \tag{14}\]  
\[SoC(k+1)=-I_{bnt}\frac{3.6\Delta x}{v(k)C_{bnt}}+SoC(k) \tag{15}\]  
additionally, the parameters in the optimization process should be subject to the following constraints:  
\[ \begin{array}{l}n_{dmt\_lb}\leq n_{dmt}\leq n_{dmt\_ub}\\ n_{wm\_lb}\leq n_{wm}\leq n_{wm\_ub}\\ T_{dmt\_lb}\leq T_{dmt}\leq T_{dmt\_ub}\\ T_{wm\_lb}\leq T_{wm}\leq T_{wm\_ub}\\ I_{bnt\_lb}\leq I_{bnt}\leq I_{bnt\_ub}\\ V_{bnt}^{2}<4 Rp_{de\_bnt}\\ \psi_{res}\leq\psi_{de\_res}\end{array}  \tag{16}\]  
where vectors \(v(k)\), \(SoC(k)\), and \(a(k)\) represent vehicle velocity, km/h, battery \(SoC\), As, and vehicle acceleration, m/s\({}^{2}\) at spatial step \(k\), respectively; \(T_{dmt\_lb}\), \(T_{dmt\_ub}\), \(T_{wm\_lb}\), and \(T_{wm\_ub}\) represent the lower and upper bound torque of the driving motor and the working motor, N-m, respectively; \(n_{dmt\_lb}\), \(n_{dmt\_ub}\), \(n_{wm\_lb}\), and \(n_{wm\_ub}\) represent the lower and upper bound rotating speed of the driving motor and the working motor, rpm, respectively; \(I_{bnt}\) and \(V_{bnt}\) represent the current and voltage of the battery; and \(\psi_{res}\) and \(\psi_{de\_res}\) represent the residue and required residue of the garbage density, which was set to 13 g/m\({}^{2}\) referring to governmental regulations. Setting the initial 11 spatial delays, the predictor continues the prediction process by updating the past 11 values with the detected real values. After having the first one of the acquired optimal control sequences performed, the vehicle updates state variables and repeats the whole process as moving to the next spatial step. The working principle of the AMPC-based EMS is illustrated in Figure 22.  
Figure 22: The AMPC based EMS.