## 3 Benchmark Solutions: ECMS and DP with a Priori Knowledge of the Driving Cycle
The [PERSON]'s principle of optimality states that: \"An optimal policy has the property that whatever the initial state and initial decisions are, the remaining decisions must constitute an optimal policy with regard to the state resulting from the first decisions\" [34], whichinformally states that any partial trajectory inside the optimal one is also optimal between its initial and final states and leads to the Hamilton-Jacobi-Bellman (HJB) equation:  
\[\mathcal{J}^{*}(x(t),t)=min_{u}\bigg{\{}\int_{t}^{t+\delta t}L(x(\tau),u(\tau), \tau)d\tau+\mathcal{J}^{*}(x(t+\delta t),t+\delta t)\bigg{\}} \tag{16}\]  
where the optimal cost-to-go \(\mathcal{J}^{*}\) from any arbitrary state \(x(t)\) at time \(t\) (\(t_{0}\leq t\leq t_{f}\)) can be calculated as the cost of a differential problem with length \(\delta t\) plus the optimal cost-to-go from the resulting state at \(t+\delta t\) to the end. Dynamic programming is an algorithm exploiting the Bellman principle of optimality and the HJB equation to numerically solve an optimal control problem. The method is based on the discretization of the time span of the problem in \(n\) time-steps, so for any state value in a given time-step (\(k\)), the [PERSON]'s principle of optimality implies that:  
\[\mathcal{J}^{*}(x,k)=min_{u}\{L(x,u)+\mathcal{J}^{*}(x,k+1)\} \tag{17}\]  
Among other methods, the \(x\) and \(u\) spaces can be discretized and the problem numerically solved, starting from the last time-step \(k=n-1\) (so \(\mathcal{J}^{*}(x,n)=\psi(x(n))\)) and proceeding backwards accumulating the cost-to-go for the whole \(x\) space until obtaining a resulting space of cost-to-go values for the optimal solution at the initial time-step as a function of the initial state \(\mathcal{J}^{*}(x,1)\). Note that storing \(\mathcal{J}^{*}(x,k)\) allows to reproduce not only the optimal solution from the initial state, but from any point in the \((x,k)\) space, which makes DP a powerful tool for the optimization of dynamic systems. Of course, this potential does not come for free and DP suffers from the so-called curse of dimensionality: the number of combinations to test during the problem solution and the number of elements that must be stored in memory rapidly increase with the problem length, number of states and actuators and their discretization. According to Section 2, there are only two states in the case at hand, i.e., the energy stored in the battery (see Equation (11)) and the state of the ICE (on or off, see (7)), and one control (the motor power), so the problem is still affordable by DP. On the other side, solving the optimal control problem requires perfect knowledge of the disturbances, in the case at hand the vehicle speed profile. Since future driving conditions cannot be perfectly known, DP cannot be used for online control purposes, but its result can be used as a benchmark for the performance of other strategies. In this sense, assuming that the complete driving cycle consisting of all the loops covered by the bus in the two days of testing is known, the optimal solution can be found by DP and then be used as a reference for comparison of the control strategy proposed in this paper. Figure 3 shows the results obtained after solving by DP for the complete driving cycle. The upper plot and medium plots show the fuel consumption in the considered loops and in the complete cycle. An average value of 36.5 kg/100 km in the fuel consumption during the loops and a standard deviation of 1.5 kg/100 km points out that there are non-negligible differences between the driving cycles due to the driving conditions but also due to the SoE at the end of every loop. The lower plot shows the evolution of the SoE despite the different evolutions during the cycles; a clear pattern can be observed in most of them, consisting on an initial battery charging during the first part of the loop, then some discharging below the initial SoE and finally a recovery phase to reach similar values as the initial SoE.