# Speed Advisor for Fuel Consumption Minimisation Under Real Driving Conditions
## 5 Vehicle Speed Advisor Implementation  
The first result of the optimization described in the previous section is the optimal sequence in the states of the problem (particularly on the velocity) depending on the position of the vehicle (\(v^{*}(s)\)). This information would be enough to minimise the fuel consumption if the driver is able to perfectly follow it during the route. In this case, a direct interpolation in the \(v^{*}(s)\) curve of the actual position of the vehicle (\(s_{k}\)) would be enough to display the actual and reference vehicle speeds. However, it is not possible for a standard driver to perfectly follow a prescribed speed profile due to both disturbances that may appear during the route (e.g. traffic) and the limited driver skills. Another important reason to not perfectly follow the advised vehicle speed may be drivability. As this criteria has not been taken into account in the optimization process the driver may feel uncomfortable following the advised speed profile in any part of the route. Note that any deviation from the optimal speed profile harms the optimality of the rest of the trip, if the driver continues following the advised speed trajectory after a deviation, in the best case the time constraint will not be fulfilled. In this sense, some kind of feedback is necessary to keep optimality. To this aim, instead of using the optimal trajectory from the DP, the optimal control signal map (\(U^{*}\)) has been used, which specifies the optimal control \(u^{*}\) at each step \(k\) and at each state \(x_{k}\in X\). In the case at hand:  
\[U^{*}=u^{*}(s_{k},v_{k},t_{k}) \tag{20}\]  
The optimal control signal map is combined with the vehicle model to obtain an optimal speed map, which provides the optimal velocity in the next step \(k+1\) and depending on the current state \(x_{k}\in X\) to be used as a set point for the driver:  
\[v_{k+1}^{sp}=v_{k+1}^{*}(s_{k},v_{k},t_{k}) \tag{21}\] \begin{table}
\begin{tabular}{l c c} \hline
**Variable** & **Range** & **Element Size** \\ \hline Distance (\(s\)) & \([0,60]\) km & 50 m \\ Speed (\(v=x_{1}\)) & \([30,120]\) km/h & 1 km/h \\ Time (\(t=x_{2}\)) & \([0,\tau]\) & 2 s \\ Brake/Throttle (\(u\)) & \([-100,100]\%\) & 2\% \\ \hline \end{tabular}
\end{table} 
Table 1: Discretisation employed in the optimisation algorithm DP. Depending on the position of the vehicle (\(s\)) there is a map showing what is the optimal velocity in the next step depending on the actual speed and time. A feasible region can be identified in any map, this region is bounded by:  
* Maximum speed depending on the speed constraint, which depends on the vehicle position
* Maximum time: if the vehicle passes through this point in the route latter than this maximum time, it will not be able to fulfil the time constraint, even driving from this moment at the maximum allowed speed. * Minimum time: if the vehicle passes through this point in the route earlier than this minimum time, it will not be able to fulfil the time constraint, even driving from this moment at the minimum speed used in the optimization (30 km/h). This limit does not have a practical purpose. Figure 4 shows an scheme of the algorithm proposed. As the current velocity, position and time consumed during the trip are available in the vehicle, the developed application uses them to interpolate what is the optimal velocity during a moving window of \(N\) seconds and displays it to the driver. The driver aims to follow the optimized trajectory by adjusting the pedal position and correct the speed profile to match the display command. Note that in order to display the next \(N\) seconds control actions the system should estimate the future positions of the vehicle by integrating the optimal velocity obtained every second. In the current work the algorithm is run every \(\Delta t\) seconds to update the optimal speed profile.