## 4 Validation of the Simulation Framework
### Tuning and Validation Methodology  
The tuning was performed by using optimization to directly determine the parameters' values of the powertrain module (e.g., EMS, CMS, BMS) that needs to be tuned, to \begin{table}
\begin{tabular}{c c c c} \hline \hline
**City, Bus Type and** & **Speed** & **Baseline Energy** & **Energy** \\
**Demo Number** & **(Mean and maximum)** & **Requirement** & **Savings** \\ \hline BCN 12 m, Demo 1 * & 2.68 m/s, 21.9 m/s & 1.47 kWh/km & 21.8\% \\ BCN 12 m, Demo 2 * & 4.08 m/s, 16.6 m/s & 1.52 kWh/km & 22.8\% \\ BCN 12 m, Demo 3 * & 7.28 m/s, 20.4 m/s & 1.57 kWh/km & 27.5\% \\ BCN 12 m, Demo 4 * & 3.48 m/s, 21.4 m/s & 1.50 kWh/km & 20.9\% \\ \hline BCN 18 m, Demo 1 * & 4.28 m/s, 20.0 m/s & 3.42 kWh/km & 39.5\% \\ \hline OSN 12 m, Demo 1 * & 3.37 m/s, 16.0 m/s & 1.50 kWh/km & 24.2\% \\ OSN 12 m, Demo 2 * & 3.44 m/s, 12.0 m/s & 1.20 kWh/km & 17.6\% \\ OSN 12 m, Demo 3 * & 2.95 m/s, 16.4 m/s & 1.56 kWh/km & 21.9\% \\ OSN 12 m, Demo 4 * & 3.13 m/s, 14.7 m/s & 1.42 kWh/km & 18.7\% \\ \hline OSN 18 m, Demo 1 * & 5.82 m/s, 18.7 m/s & 2.79 kWh/km & 47.4\% \\ \hline GOT 12 m, Demo 1 * & 3.50 m/s, 22.9 m/s & 1.83 kWh/km & 7.4\% \\ GOT 12 m, Demo 2 * & 2.22 m/s, 21.6 m/s & 1.75 kWh/km & 8.1\% \\ GOT 12 m, Demo 3 * & 3.30 m/s, 19.7 m/s & 2.11 kWh/km & 5.3\% \\ \hline \hline \end{tabular}  
* BCN: Barcelona, OSN: Osnabruck, GOT: Gothenburg; 12 m and 18 m refers to the bus length.  
\end{table} 
Table 4: Energy reduction possible due to ECO-driving. minimize the normalized root mean squared error (NRMSE) between the simulated and measured outputs. \[\text{C}_{\text{total}}=\frac{\sqrt{\frac{\text{h}_{\text{total}}(\text{SOC}_{ \text{SIM}}\text{ i}-\text{ SOC}_{\text{MEAS}}))^{2}}{\text{h}}}}{\text{max}(\text{SOC}_{\text{MEAS}})-\text{min}(\text{ SOC}_{\text{MEAS}})}+\text{constraint penalty} \tag{1}\]  
The cost function, \(\text{C}_{\text{total}}\), shown in (1), gives an estimate of the deviation between the simulated and measured SoC of the battery. The closer the value of the cost function is to zero, the closer the match between the two SoC signals. To achieve a minimum value of \(\text{C}_{\text{total}}\) in the optimization process, not only must the two SoC signals match as closely as possible, but the simulation must also not violate any of the constraints elaborated on in Section 4.2. The output score calculated by the NRMSE ranges from 0 (perfect match between simulated and measured signals) to 1 (implying the maximum mismatch between the two signals), thus any penalty applied has values greater than 1. The magnitude of the penalty depends on the extent of the violation of a given constraint. By the standard definition [16], the tuning methodology described in this study is an example of the offline tuning process because the tuning occurs in the simulation model using saved data, i.e., the measured input during the demonstration was not processed in real-time but cached for later processing and simulation. Instead, for this study, a different definition is used to differentiate between an offline and an online tuning process. The online tuning process is defined as the tuning that occurred while the simulation was still ongoing, whereas in offline tuning, the tuning occurred in an iterative process between separate simulations, after each simulation had finished running in its entirety. For the online tuning process, the total time duration of the simulation was split into several \"windows\"; the tuning occurred in between each time window, and its result was applied to the next window until no further improvement could be seen, i.e., it converged. If the convergence occurred before the end of the simulation, the tuning was considered completed; otherwise, the simulation was repeated with the latest tuned configuration as the starting condition. As expected, the online process is faster due to the small dataset involved in the tuning process, so the tuning completes quicker.