# Adaptive MPC Based Real-Time Energy Management Strategy of the Electric Sanitation Vehicles
## 3 The Real-Time AMPC-Based EMS  
### The Prediction Method  
Since the vehicle was clean task-oriented, any optimal manipulations were radically decided by the garbage density ahead on the road surface. Considering the vehicle velocity was almost constantly under the working mode, the garbage density sequence in the spatial domain could be equivalently regarded as a time series. Therefore, on the spatial prediction horizon, the predictor could anticipate the garbage density series with the methods dealing with time series. To make the description uniform, the rest of this study discusses problems from the perspective of the spatial domain. Due to the high autocorrelation of the garbage density distribution, the future values could be forecasted using the past values in the same series by the predictor. The autoregressive relationship to be modeled can be formulated as  
\[\delta(k)=f(\delta(k-1),\delta(k-2),\dots,\delta(k-p))+\varepsilon_{t} \tag{10}\]  
where \(\delta(k)\) represents the value of the garbage density series at displacement \(k\); \(\delta(k-1)\), \(\delta(k-2),\dots\) represent the past values of the series; \(f(. )\) represents the unknown non-linear relationships to be approximated, \(p\) represents the number of past values, and \(\varepsilon_{t}\) stands for the error of the approximation. However, for the garbage density series, the relationships \(f(. )\) might have varied with different segments of the road, which made the predictors using a Markov chain [15] or ARIMA [11] suitable for nonstationary \"time\" series perform poorly. Hence, the non-linear autoregressive neural network (NARNN) was implemented, which deals effectively with \"time\" series characterized by frequent variations and high nonstationarity. The discrete, non-linear, autoregressive model build by NARNN can be precisely written as [26]:  
\[\delta(k)=\alpha_{0}+\sum_{j=1}^{m}\alpha_{j}\phi\left(\sum_{i=1}^{p}\beta_{ij }\delta(k-i)+\beta_{0j}\right)+\varepsilon_{t} \tag{11}\]  
where \(p\) represents the number of the past values (or delays) used as the input to predict; \(m\) represents the number of hidden layer neurons in NARNN with the activation function defined as \(\phi(. )\)--specifically, each neuron can approximate a unique relationship \(f(. )\); \(\beta_{ij}\) represents the parameter corresponding to the weight of the connection between the input neural cell \(i\) and the hidden cell \(j\); \(\alpha_{j}\) stands for the weight of the connection between the hidden cell \(j\) and the output cell; and \(\beta_{0j}\) and \(\alpha_{0}\) are the constants respectively corresponding to the hidden cell and the output cell. The general working principle of the predictor is shown in Figure 14.  
Figure 13: Garbage density distribution model. To guarantee the calculation efficiency, the learning rule of the NARNN uses the Levenberg-Marquardt backpropagation-type algorithm procedure (LMBP), which is regarded as the fastest of the category. Furthermore, the number of hidden layers and neurons per layer for NARNN is completely flexible and can be optimized through a trial-and-error procedure to get the best performance [27]. Increasing the number of neurons helps the NARNN simulate more complex relationships and improve the generalization ability, while decreasing that number alleviates the computation burden and contributes to the real-time requirement. Consequently, the NARNN was set to have 20 neurons in 1 hidden layer, which could well trace the variation tendency of the garbage density, and the delay of the spatial series was set to be 11 steps optimally. Established on the Matlab platform, the open-loop training process of the NARNN is shown in Figure 15.  
It is critical to bear in mind that the essence of ensuring the performance of a neural network is whether broad possible instances are covered in the training set. Since the garbage distribution model constituted segments involving all likely scenarios, the training set was generated from the former 75% of data in the established model (Figure 13).