## 4 Algorithm Implementation
### Results  
Table 1 illustrates a comparative analysis between using Bellman-Ford, which obtains the real minimum energy needed, and the ANN approach to estimate the electrical consumption between nodes. The results are obtained from 50 random instances of size-10 nodes to visit each. We can appreciate that the final performance of the TSP is almost identical while requiring 88.78% less time than using the ANN approach.  
\begin{table}
\begin{tabular}{l c c c} \hline \hline  & **Bellman–Ford** & **ANN** & **Difference** \\ \hline Average energy consumption (kWh) & 10.966 & 10.969 & 0.0205\% \\ Average execution time (s) & 19.25 & 2.25 & \(-\)88.28\% \\ \hline \hline \end{tabular}
\end{table}
Table 1: Comparison between node filtering with Bellman–Ford and the ANN model.  
Figure 8: Prediction vs. actual energy consumption.  
The proposed algorithm has an average execution time of 5-9 s for instances of 20 stops, 12-14 s for instances of 30 stops, and 19-26 s for instances of 40 stops when run on a laptop with an AMD Ryzen 5 4680U processor and 8 GB of RAM. These execution times are sufficiently fast for real-time routing applications, given that the single-core performance of this processor is readily available in modern smartphones on the market.  
Figure 9 offers a visual representation of how the algorithm optimizes the routes compared to the shortest path solution. The graph includes the elevation profile for both routes. It shows that the energy-minimizing route is longer but has a lower gradient than the distance-minimizing route. The distance-minimizing route consumes the most energy when it takes high-step roads, whereas the energy-minimizing route avoids steep inclines, resulting in a smoother and less energy-intensive path. The incline of roadways, as mentioned earlier, is a significant yet not sole determinant impacting energy consumption. This aspect holds particular significance since EVs can solely recuperate a portion of energy when traversing downhill gradients.  
To evaluate the effectiveness of our approach, we compared the results of our proposed algorithm to the traditional approach of minimizing the distance for EVs. We conducted experiments using real-world scenarios. Table 2 compares two methods of solving the TSP: minimizing distance and the proposed approach. To evaluate the performance of each method, we generated 25 STSP instances of varying sizes (5, 10, and 15) using the graph of Madrid. The traffic state used is 10 October 2022 at 14 h. Each group of instances is named Madrid5, Madrid10, and Madrid15 and is available at [24]. The distance-based approach minimizes distance instead of electric consumption and was solved using the Dijkstra algorithm to generate the subgraph and reconstruct the route. On average, our proposed approach resulted in STSP routes that consumed 17.34% less energy while only requiring 7.52% more distance compared to minimizing the distance approach. The efficiency of our proposed approach was similar across all instances of varying sizes. It is worth to mention that speeds are 18.9% (size 5), 17% (size 10), and 16.44% (size 15) higher when minimizing the distance, which result in 35 to 40% more air-resistance forces. The consumption rates are higher by 22.61% (size 5), 20.63% (size 10), and 20.53% (size 15) due in part to the difference in heights and in average speeds.  
Figure 9: Example of a comparative analysis of electricity consumption and elevation during a vehicle trip. The dashed lines represent how the elevation changes along the distance. The solid line represents the cumulative consumption values.