An integrated model of electric bus energy consumption and optimised depot charging

Flow diagram showing the connection between RouteZero’s bus energy consumption model and bus depot charging optimisation model, and how these are all dependent only on publicly available data.

Fig. 1: Overview of RouteZero model.

This section summarises the method of the bus energy consumption model and the bus depot charging optimisation. Detail on the software implementation and webapp use are provided in41.

Data-driven energy consumption model

A Bayesian linear regression model is fit to the modelling data. We choose a linear regression model because of its ease of interpretation, lower dependence on large amounts of data when compared to non-parametric models such as random forests and neural networks, and greater ability to extrapolate outside the training data. A Bayesian approach is used to fit the model as it quantifies the uncertainty in the parameter values. This allows a confidence interval to be placed on the predictions.

The linear regression model can be represented as

$$\begin{array}{l}{\text{ec}}/{\text{km}}={c}_{0}+{c}_{1}{\text{s}}/{\text{km}}+{c}_{2}g+{c}_{3}T+{c}_{4}v+{c}_{5}p+{c}_{6}{\text{SOC}}_{i}\\\qquad\qquad+\,{c}_{7}{I}_{> 97 \% }({\text{SOC}}_{i})+{c}_{8}{T}^{2}+e,\end{array}$$

(1)

where e is an error term that is approximated as zero-mean Gaussian and I>97% is an indicator function that indicates if a trip is started with a close to full battery:

$${I}_{> 97 \% }({\text{SOC}}_{i})=\left\{\begin{array}{ll}1\quad &{\text{SOC}}_{i} \,> \,97 \% ,\\ 0\quad &\,\text{otherwise}\,.\end{array}\right.$$

(2)

These are summarised in Table 1, which also presents their values as fit to the trial data.

Several variable transforms have been included: temperature squared, and a battery close to full indicator. These account for the following patterns.

Energy consumption by auxiliary systems (air conditioning and battery management) has an approximately quadratic relationship with the external temperature23. ec/km as a function of SOCi has a clear negative trend—batteries are more efficient at higher capacity—with the exception that at close to 100% initial state of charge the trips have a much higher energy consumption. This is explained by ref. 23 as a result of less ability to regeneratively brake if the battery is already close to full. To model this the indicator function, I>97% is used.

The data set was split 80/20 into training and validation sets. The model parameters were fit to the training data using Bayesian linear regression28. Briefly, given output \({\bf{y}}\in {{\mathbb{R}}}^{n}\), inputs \({\bf{X}}\in {{\mathbb{R}}}^{n\times p}\), model parameters \({\boldsymbol{\theta }}\in {{\mathbb{R}}}^{p}\) with a zero-mean Gaussian prior such that

$${\bf{y}}={\bf{X}}{\boldsymbol{\theta }}+e,$$

(3)

where e is zero-mean Gaussian with covariance Σ, then the parameters will have posterior mean and variance given by

$$\begin{array}{l}{\mathbb{E}}[{\boldsymbol{\theta }}| {\bf{y}}]={({{\bf{X}}}^{\top }{{\boldsymbol{\Sigma }}}^{-1}{\bf{X}}+{{\boldsymbol{\Sigma }}}_{p}^{-1})}^{-1}{{\bf{X}}}^{\top }{\bf{y}},\\ {\mathbb{V}}[{\boldsymbol{\theta }}| {\bf{y}}]={({{\bf{X}}}^{\top }{{\boldsymbol{\Sigma }}}^{-1}{\bf{X}}+{{\boldsymbol{\Sigma }}}_{p}^{-1})}^{-1},\end{array}$$

(4)

where Σp is the prior covariance of the parameters.

This was used to fit our linear regression model with a large prior covariance placed on the parameters to represent no prior knowledge and the measurement variances.

To develop a data-driven predictive model for electric bus energy consumption a training dataset of bus trips was required. Where for each trip the input (independent) and output (dependent) parameters wishing to be modelled are recorded. The required data was collated from several sources: Zenobe, Transport for NSW, and publicly available temperature and weather data. The collected data corresponds to the battery electric bus trial at the Leichhardt bus depot in Sydney’s inner west as part of the Next Generation Electric Bus Depot Project27. The data from these sources were cleaned, combined, and processed to give the following information about each trip undertaken by a bus on a route:

  • average gradient (%),

  • average number of passengers,

  • number of stops per kilometre,

  • average speed (km/hour),

  • starting battery state of charge (%),

  • temperature (degrees Celsius),

  • energy consumption per kilometre (kWh/km),

  • distance (km),

This final data set contains no information about road condition, and driver aggressiveness, and all vehicles in the trial have the same mass. As such, these variables were excluded from the modelling. Road condition was excluded as all the modelling data was collected in Sydney’s inner west and so a range of different road conditions would not be present.

After processing, the final dataset spanned the time-frame from 6th of of January 2022 till the 31st of August 2022 and consisted of 10459 trips on 42 different routes by 33 different buses. Table 2 summarises the variables contained in the dataset and the distribution of the variables in the dataset is shown in Fig. 11.

Both the dependent (output) and independent (input) variables are shown. Also shown is the distribution of the percent state of charge used on trips and trip distance from which the energy consumption per kilometre is calculated.

figure 11
Fig. 11: Distributions of the dataset variables.

It can be seen that several of the input variables cover only a limited range. The majority of trips have:

  • a moderate temperature between 7 °C and 26 °C,

  • a relatively flat average gradient between −1.8% and 1.8%,

  • a higher stop per kilometre ratio > 2,

  • a lower average speed < 30 km h−1.

These limited ranges are in line with the time of year the data was collected and the location and types of routes it corresponds to Sydney’s inner west.

The fit parameter means and 95% confidence intervals are given in Table 1. The model was validated by making predictions on the validation set and calculating the prediction error, which had a weighted mean of 5.34 × 10−3 kW h km−1 and a standard deviation of 0.278 kW h km−1.

Given that the error introduced by recording the state of charge in integers has an average standard deviation of approximately 0.279 kW h km−1, we can be confident that the trained model is the best that can be achieved given the dataset.

Static General Transit Feed Specification (GTFS) files are used as the primary source of data when producing outputs for an end-user. Files containing information about a large number of routes within Australia are freely available online for each state and territory. A summary of the contained data relevant to the modelling is given below. A detailed description of the data in the online reference documentation25.

For each bus route the GTFS files give the following information:

  • the trips schedule on this route,

  • a list of stops belonging to the route and their locations,

  • the arrival and departure time of each bus stop on a trip,

  • the stops along the route and their locations,

  • a GPS path for the route.

Added to this is temperature and elevation information obtained from public sources and passenger information provided by the end-user.

From this, the inputs required for the electric bus energy consumption model (see the Data-driven energy consumption model Section) are calculated allowing predictions of energy consumption to be made. A schedule of trips for a selection of routes can also be extracted which is used in the depot charging optimisation model (see the Depot charging optimisation model Section).

Depot charging optimisation model

The objective is to find the charging profile that minimises the required grid connection power and a number of chargers while ensuring that the buses are sufficiently charged to service the route timetable. Care has been taken when formulating the objective and the constraints to ensure the problem is formulated as a linear programme that can be solved efficiently in polynomial time42.

Let G be the grid connection power limit, and Nc be the number of chargers. For a given time window t, the amount of charging done is xt, the depot battery power is bt, and rt is an auxiliary variable introduced to minimise changes in power. Additionally, sf, and sr are slack variables included to ensure a feasible solution. With these defined the linear programme that we wish to optimise is

$$\begin{array}{l}{\theta }^{* }=\mathop{{\rm{argmin}}}\limits_{\theta }\,\,{p}_{0}G+{p}_{1}{N}_{c}+{p}_{2}\mathop{\sum }\limits_{t=1}^{T}({x}_{t}+{b}_{t})+Q{s}_{f}+Q{s}_{r}+{p}_{2}\mathop{\sum }\limits_{t=1}^{T-1}{r}_{t},\\\qquad\qquad\qquad {s.t.\,(6)-(17)}\end{array}$$

(5)

where θ = {G, Nc, xt, bt, rt, sf, sr∣ ∀ t = 1, . . , T} is the set of all optimisation variables, which are outlined in Table 3. Q is a large cost placed on the slack variables to ensure the constraints will be satisfied if feasible, p0 is a cost used to minimise the required grid connection capacity, p1 is a smaller cost placed on the number of chargers.

The inclusion of xt + bt and rt in the objective acts similarly to regularising the charging power (i.e. similar to placing a quadratic cost on power) while maintaining the linear nature of the problem. In essence, p2 is a small cost placed on charging power to prevent unnecessary charging, and the auxiliary variable rt is included to minimise large changes in the charging power. This is done by including a constraint to ensure it is greater than the absolute difference in charging between two consecutive time steps:

$$\begin{array}{l}{r}_{t}\ge {x}_{t+1}-{x}_{t},\qquad \forall t=1,\ldots T-1\\ {r}_{t}\ge -{x}_{t+1}+{x}_{t}\qquad \forall t=1,\ldots T-1,\end{array}$$

(6)

The following constraint is used to limit the amount of bus charging done based on the number of buses at the depot, Nt, and the number of chargers:

$$\begin{array}{l}{x}_{t}{a}_{t}\le {N}_{t}{U}_{x}\qquad t=1,\ldots T,\\ {x}_{t}\le {a}_{t}{U}_{x}{N}_{c}\qquad t=1,\ldots T,\end{array}$$

(7)

where at is a binary variable indicating whether the user has allowed charging during this time period, Ux is the lesser of the maximum charger power rating or the maximum bus charging power. The grid connection constraint is enforced by

$${x}_{t}+{b}_{t}\le G\qquad t=1,\ldots T.$$

(8)

Enforcing that the cumulative charging done is less than the cumulative energy used by buses that have returned to the depot plus the gap between the starting capacity and max capacity. That is, ensuring the state of charge is less than the maximum:

$${\eta }_{x}\alpha \mathop{\sum }\limits_{i=1}^{t}{x}_{i}\le (1-{C}_{s})MBL+\mathop{\sum }\limits_{i=1}^{t-1}{E}_{r,i}\qquad \forall t=1,\ldots T.$$

(9)

where α is the constant converting from kW to kWh, Cs ∈ (0, 1] is the starting charge ratio, M is the number of buses, B is the bus battery capacity, L ∈ (0, 1] is the end of life battery battery capacity as a ratio of rated battery capacity, ηx is the bus charging efficiency, and Er,t is the energy used on trips returning in time period t. The end of life battery capacity needs to be considered as battery health degrades over time resulting in decreased energy capacity and this should be considered when determining if the capacity is sufficient.

Enforcing that the cumulative charging done is greater than the cumulative energy required by buses that have departed the depot minus the difference between the start state of charge and the reserve. That is, ensuring that the state of charge is above the reserve:

$$L{C}_{s}MB+{\eta }_{x}\alpha \mathop{\sum }\limits_{i=1}^{t-1}{x}_{t}-\mathop{\sum }\limits_{i=1}^{t}{E}_{d,t}+{s}_{r}\ge R\qquad \forall t=1,\ldots T,$$

(10)

where R is the required reserve capacity, Ed,t is the energy required by trips departing in time period t, and the slack variable sr ≥ 0 is included to ensure an optimisation solution is reached even if the reserve cannot be achieved.

Enforcing the desired final state of charge is achieved:

$$L{C}_{s}MB+\alpha {\eta }_{x}\mathop{\sum }\limits_{t=1}^{T}({x}_{t}-{E}_{d,t})+{s}_{f}\ge L{C}_{f}MB,$$

(11)

where Cf ∈ (0, 1] is the required final charge ratio, the slack variable sf ≥ 0 has been included to ensure that a solution is reached even if the desired final state of charge cannot be achieved.

Minimum plugin time constraint, i.e. enforces that during the specified number of time windows a single charger cannot charge more than the battery capacity of a bus:

$$\alpha {\eta }_{x}\mathop{\sum }\limits_{t-w}^{t}{x}_{t}\le {N}_{c}B$$

(12)

Note, that this only approximates the desired constraint as we cannot know how much capacity each bus has used.

For the on-site depot battery we define ηb as the charge and discharge efficiency, and D as the capacity. This allows the on-site depot battery minimum, maximum and final state of charge constraints to be formulated as follows.

Battery charging and discharging efficiency introduce a piecewise linear function of the form

$$f({b}_{t})=\left\{\begin{array}{ll}{\eta }_{b}{b}_{t}\quad &\,\text{if}\,\,{b}_{t}\ge 0\\ \frac{1}{{\eta }_{b}}{b}_{t}\quad &\,\text{otherwise}\,\end{array}\right.$$

(13)

A standard implementation of this might involve the introduction of binary variables resulting in a mixed integer programme and drastically increasing the computational complexity. To avoid this, we follow a standard reformulation of piecewise linear problems as a linear problem43 introducing the auxiliary variable vt:

$${v}_{t}\le {\eta }_{b}{b}_{t}\qquad \forall t=1,\ldots T,$$

(14)

$${v}_{t}\le \frac{1}{{\eta }_{b}}{b}_{t}\qquad \forall t=1,\ldots T,$$

(15)

This auxiliary variable can be thought of as the power applied to the battery after the effects of efficiency have been considered. Here, inequality constraints can be used in the reformulation as the objective function ensures that the solution for vt will lie on the constraint boundary.

The battery minimum, maximum, and final state of charge can now be enforced by

$${C}_{s}D+\alpha \mathop{\sum }\limits_{i=1}^{t}{v}_{i}\ge 0,\qquad \forall t=1,\ldots T,$$

(16)

$${C}_{s}D+\alpha \mathop{\sum }\limits_{i=1}^{t}{v}_{i}\le D,\qquad \forall t=1,\ldots T,$$

(17)

$${C}_{s}D+\alpha \mathop{\sum }\limits_{t=1}^{T}{v}_{i}\ge {C}_{f}D.$$

The complete optimisation model describes a linear programme that can be solved efficiently using the open source CBC library from COIN-OR44.

all articles