Smart and sustainable scheduling of charging events for electric buses

This paper presents a framework for the efficient management of renewable energies to charge a fleet of electric buses (eBuses). Our framework starts with the prediction of clean energy time windows, i.e., periods of time when the production of clean energy exceeds the demand of the country. Then, the optimization phase schedules charging events to reduce the use of non-clean energy to recharge eBuses while passengers are embarking or disembarking. The proposed framework is capable of overcoming the unstable and chaotic nature of wind power generation to operate the fleet without perturbing the quality of service. Our extensive empirical validation with real instances from Ireland suggests that our solutions can significantly reduce non-clean energy consumed on large data sets.


Introduction
The Irish transportation sector currently accounts for more than 30% of the energyrelated CO 2 emissions of the country. Therefore, in order to reach sustainable goals, the Irish government is working with multiple incentives to promote Electric Vehicles (EVs) to decarbonize the sector, e.g., free domestic charging points, toll reductions, € 5000 grants for electric car owners, and the implementation of electric Buses (eBuses) in the medium to long term. eBuses operate with rechargeable batteries with a capacity to store approximately 300 kWh (and up to 600 kWh), equivalent to around 7.9 gallons of diesel while reaching approx. 200 km. Lithium-ion batteries are nowadays the most popular technology in the market. This technology typically features reduced weight dimensions and a better lifetime with the same energy capacity than other technologies such as Nickel Metal Hydride and Lead acid (Farindon 2009). Furthermore, the price of Lithium-ion batteries fell 50% between 2014 and 2016, and it is expected that the price will further go down by 2025.
Several pilot projects are currently running worldwide to increase the use of public eBuses. Major Irish bus operators are running projects to phase out dieselonly buses in the main cities, and the Irish government is committed to no longer buying diesel-only buses for urban public services. Electric buses have also been successfully tested on certain routes in Spain, Germany, Poland, the Netherlands, Switzerland, and the United States. It is expected that more countries will test this technology in the near future.
Range anxiety is a major factor preventing the transition to eBuses. This has been shown to decrease as more people become familiar with this technology (Pevec et al. 2020). A key component in the development of a cost-effective and reliable green transportation network is the charging infrastructure. The two most popular charging technologies in the market today are as follows. Static or slow-charging: where the buses can only be charged at the depots when the buses are parked or scheduled to stop for a significant amount of time (e.g., overnight parking). A slow-charging unit will typically charge to full capacity in 3-7 h with a power rate ranging from 30 to 120 kW. Stationary or fast-charging: considerably reduces the charging time with a power rate ranging from 150 to 600 kW. This charging technology can top up the battery up to a certain limit of capacity in a few minutes. Manufacturers typically recommend avoiding fast charging for more than 80% of the capacity to reduce overheating and potential damages in the lifetime of the batteries.
Wind power is by far the most important source of clean energy in many countries, e.g., Ireland and the UK. However, wind power is intermittent and only available when the wind flows at certain speeds. Therefore, the national grid needs to prepare contingency plans to supply the demand in the absence of enough power from wind farms. Nowadays, wind power is highly predictable with advanced machine learning and statistical models for time series analysis. Short-term models with a time horizon of 6 h are typically better than those for larger horizons, e.g., 24 h periods (Giebel et al. 2003).
In this work, our objective is to provide a framework to schedule the charging events of a fleet of eBuses while minimizing the usage of non-clean energy. We start by building a deep learning model for wind power forecasting and present the application of two reactive approaches to deal with the chaotic nature of wind power forecasting. The effectiveness of our approach is demonstrated by experimenting with real data sets from Ireland, i.e., from the Irish national grid and a major bus operator in the country.
The paper is structured as follows. Section 2 discusses related work on this topic. Section 3 outlines the main components of our two reactive approaches. Section 4 describes the optimization models and variables used. Section 5 evaluates our models with real instances. Section 6 presents some conclusions and future work.

Related works
In recent years the topic of EVs and charging has gained increasing interest. In this section, we outline recent related work in the area.

Vehicle routing problems and variations
The Vehicle Routing Problem (VRP) is a well-known combinatorial optimization problem with applications ranging from logistics to planning and scheduling. This problem involves the creation of optimal routes (e.g., minimizing the traveled distance or the required time to complete certain tasks). These routes might represent supply chains where vehicles deliver goods from a set of depots to customers (Laporte and Nobert 1987). Research into the usage of EVs has spawned a variation of the VRP called the Electric Vehicle Routing Problem (EVRP). EVRP differs from traditional VRPs as the range of EVs is considerably shorter compared to traditional combustion vehicles. As pointed out above, the range of EVs varies depending on multiple factors, e.g., battery size, average speed, and ambient temperature. Furthermore, some form of charging must occur to complete the daily operations of the vehicles (in particular for variations of the problem with pick-ups and deliveries (Olgun et al. 2021)). The EVRP focuses on minimizing the total cost of routing strategies (Lin et al. 2016) and the placement of charging stations to minimize or even negate detours needed to charge (Funke et al. 2015(Funke et al. , 2016. The Vehicle Routing Problem with Time Windows (VRPTW) is a popular variation of the traditional VRP, where vehicles must visit a set of customers within certain predefined time periods (e.g., outlined by the customers or local governments). This adds additional complexity to VRPs as a vehicle arriving early to a destination might be required to wait, and a vehicle arriving late may invalidate the solution (Desrochers et al. 1992). This has also spawned additional variations such as Time Window Assignment Vehicle Routing Problem (TWAVRP) focusing on assigning time windows to deliveries before the demand is known (Spliet and Gabor 2015).
Variations of the VRPTW for EVs have also received significant attention recently. The Electric Vehicle Routing Problem with Time Windows (E-VRPTW) aims at creating optimal routes as the traditional VRPTW, however, the additional constraints of battery capacity and location on recharging stations are also taken into consideration (Schneider et al. 2014). Notably, the objective is to optimize the total amount of vehicles required to complete the service and the total traveled distance. A recent survey provides numerous additional variations of the EVRP (Erdelic and Caric 2019) such as: the Green VRP (GVRP), the Fixed Route Vehicle Charging Problem for EVs (FRVCP for EVs) (Froger et al. 2019), Electric Vehicle Scheduling Problem (EVSP), and the Hybrid Electric Vehicle -Traveling Salesman Problem (HEV-TSP). In the same vein as our work, the FRVCP for EVs aims at identifying suitable charging schedules, however, this variation of the EVRP assumes that the customers are served with an unlimited number of EVs.

Electric public transportation
We now switch our attention to the impact of different charging technologies on urban transit operations and planning (Häll et al. 2019). Overnight charging is a slow-rate charging technology that mainly takes place at depot stations. Continuous charging allows buses to constantly charge due to either a hybrid motor or overhead bus charging lines. Finally, in the same vein as this paper, quick charging allows a bus to recharge at high rates while eBuses wait at bus stops for the passengers to embark/disembark.
Generally speaking, the planning process can be split into four phases. The first one involves the network route and design, that is, the development of bus routes, stops, and identification of depot locations. This phase must take into account all the mentioned charging technologies, for instance, the placement of charging stations must be considered when creating bus stops; overnight charging needs to calculate the amount of time and energy needed for the buses to travel from a certain starting point (e.g., a depot) to the endpoint; finally, the system needs to define potential bus routes for overhead bus charging lines.
The second phase is concerned with the development of timetables assuming that quick charging is available at certain bus stations. Therefore, operational timetables must take into account charging time and potential detours. The third phase (or vehicle scheduling phase) assigns buses to routes and the planning authorities might use a combination of overnight and quick charging. On the one hand, overnight charging might provide enough power to complete the operations of certain buses in a workday. While on the other hand, some buses might need to quickly recharge the batteries at certain charging stations located on their route. The final phase involves the assignment of buses to drivers and this phase is not expected to be impacted by the usage of any charging technologies.
Work has been done to incorporate some charging technologies in the design of bus routes for a fleet of eBuses in a Turkish university campus (Hulagu and Çelikoglu 2019). In this work, the authors propose an objective function to minimize the total cost of charging a campus bus service with a maximum route length of 8 km. The proposed solution reduced the operational cost by 34.3% when compared to conventional buses, however, the proposed solution needed 3.4 additional hours to complete the original service due to the recharging time. Other works aim to estimate the energy consumption of a large-scale eBus system by means of estimating the number of passengers on board and the tractive force of the buses in the public transportation network (Gallet et al. 2018).
Another line of work considers the charging location problem of EVs. Notably, work exists focusing on the transition to eBuses where the authors proposed a Mixed Integer Programming (MIP) model to identify suitable locations of fast charging units to maintain the current level of service, i.e., same routes and similar timetables (Arbelaez and Climent 2020). The charging location problem has also been studied with the aim of reducing the total refilling cost of a fleet of vehicles (Wang and Lin 2009). Additionally, a considerable amount of research has been devoted to the charging location problem for regular light-duty vehicles (Frade et al. 2011;Gopalakrishnan et al. 2016;Jordán et al. 2021;Funke et al. 2016). We recall that regular light-duty EVs spend most of their time parked and rely mainly on slow overnight charging. In this paper, we focus on heavy-duty public vehicles operating daily schedules for a given set of routes; additionally, buses consume more energy than regular cars. In this paper, we assume that the charging network is already in place and the objective is to schedule the charging events while optimizing the use of renewable energies (e.g., wind power).
Finally, a number of works aim to minimize the travel distance between customers within a given area with a pre-defined charging network (Xu et al. 2013;Sadeghi-Barzani et al. 2014). We also assume that the charging network is available, however, we focus on the design of suitable schedules to optimize the amount of renewable energies used to operate a fleet of eBuses in urban cities.

Renewable energy
With the increase in research around EVs, there has also been a rising interest in using renewable energy to charge EVs. Zhang et al. (2013) proposed the use of locally generated renewable energy to supplement the requirements of acquiring energy from the national grid. The paper focuses on a single charging station, with the main objective of minimizing the waiting time of any EV waiting to be charged, while also reducing long-term cost with the assertion that any renewable energy used is free compared to grid-based power.
Alternatively, Masuch et al. (2012) looks at reducing the amount of non-renewable energy used by private EVs using an onboard agent-based system. This is done by scheduling charges at times when there is an increase in wind-generated power. As private EVs are targeted in this paper, a user calendar is required to determine what route a driver will take during an operational day. This work is further expanded upon with the ability to schedule discharges from an EV to the grid to provide additional renewable energy when there are low levels of wind-generated power.

Predict and optimize
Predict and Optimize (Elmachtoub and Grigas 2021) is a relatively new paradigm that focuses on combining predictions and combinatorial optimization. The paradigm involves two stages: the first one involves training a model (e.g., supervised learning or a time series model) to predict critical variables of the optimization problem, e.g., weights in the weighted knapsack problem (Mandi et al. 2020) or scheduling of combinatorial problems with uncertain duration times (Duque et al. 2018). In this paper, we also use this two-stage paradigm. We start with a time series model to estimate surpluses of wind power in the national grid and then optimize the scheduling of charging events based on the predictions.
The combination of learning-based approaches to solve combinatorial problems has also been extensively used in the literature in multiple domains, including but not limited to, a portfolio of algorithms (Arbelaez et al. 2012;Xu et al. 2008;Kotthoff et al. 2012), constraint acquisition (Prestwich et al. 2021), prediction of energy prices in production scheduling (Ifrim et al. 2012), solving a hard cutting stock problem by machine learning and optimisation (Prestwich et al. 2015), and the use of reinforcement learning in Constraint Programming (Balafrej et al. 2015). We refer the reader to Bengio et al. (2021) for a recent survey on the application of Machine Learning methods to solve combinatorial problems.

Wind power forecasting
There are, generally speaking, two main approaches for wind power prediction. The first one uses a vector of features with meteorological data (e.g., wind speed, temperature, sea level pressure, etc.) to build a supervised learning model (e.g., support vector machines and k-nearest neighbors). The second one is based on general time series models such as ARIMA and a variety of deep learning architectures. We limit our attention to time series forecasting as the vector of features with meteorological data is usually available for a limited number of locations (Feng et al. 2017).
A time series is a collection of consecutive measurements of powers in kWh recorded in equal intervals (15 min in this paper). The accuracy of the time series methods varies considerably with different forecasting horizons (number of future observations). In this paper, we focus on medium-term horizons, i.e., the forecasting period ranges from 6 h to 1 day ahead. A 6, 12, 18, and 24 h ahead forecasting horizon will predict respectively a total of 24 (4 per hour × 6), 48, 72, and 96 observations. Shobana Devi et al. (2021) outlines alternative models for other forecasting horizons, i.e., very short-range (a few seconds to 30 min ahead), short-range (30 min to 6 h ahead), and long-term-range forecasting (1 day to a week ahead).
Long Short-Term Memory (LSTM) is a popular deep learning architecture proven to be effective at energy forecasting (Lim and Zohren 2021). The LSTM architecture is based on Recurrent Neural Networks (RNNs) which use sequential memory cells to remember previous data and pass predictions between memory cells. LSTM fixes an issue with RNNs only remembering recent data and not noticing long-term data trends. This is done by considering a memory cell's state which regulates the memory function of the network. This state becomes an input for the next memory cell along with the current prediction.
LSTM models can be trained to make multi-step ahead predictions, where a variable n controls the number of future time-step predictions (Sangiorgio and Dercole 2020). Alternatively, recursive LSTM models aim at only predicting a single time step (the next value in the time series); the prediction becomes the last value in the input sequence to predict the next time step. After some preliminary experiments (outside of the scope of this paper) we determined that the multi-step model outperformed the recursive one.

Dynamism and uncertainty
The prediction of the clean energy time windows is a tedious task susceptible to errors and the accuracy of the models typically decreases as the forecasting horizon increases. In dynamic environments, a solution that holds for the original problem can become invalid after changes occur in the problem. Likewise, in optimization problems, the quality of the solution can get worse after changes happen. For this reason, we propose a framework capable of reacting (on-line) to unexpected changes in the availability of clean energy.
Currently, there are two main approaches when dealing with these dynamic situations: reactive and proactive (Climent et al. 2014). In the reactive approach, the optimization engine maintains an interaction with the LSTM model to resolve the problem after identifying potential errors in a predefined time frame. The proactive approach requires knowledge about the possible future changes in order to avoid or minimize their effects. Due to the inherent uncertainty and volatility of wind power, in this paper, we adopt a reactive approach.

Multi-period model reactive method
Multi-period model (MPM) focuses on the aggregation of predictions from four different forecasting models to determine an increase or decrease in the amount of clean energy available in future predefined checkpoints. Figure 1 depicts the general scheme of our MPM reactive method with four checkpoints in an operational day. At  In particular, Fig. 1a calculates a schedule for the entire day with checkpoints at 0:00, 6:00, 12:00, and 18:00. The fleet of eBuses starts operations as prescribed by the optimization model at the first checkpoint. Figure 1b outlines the behavior at the second checkpoint, i.e., at 6:00, at this point, we incorporate the current knowledge (i.e., energy measurements from 0:00 to 6:00) and update the predictions. The method recalculates the schedule for the remaining part of the day with the updated data if the previous predictions differ from the new ones. We repeat the same process for the remaining two checkpoints, i.e., Fig. 1c, d.

Single-period model reactive method
As pointed out above, the predictions of the LSTM model are more reliable and accurate for short-term time horizons. In fact, this is the basis for the rolling horizon approach (Chand et al. 2002), where a schedule is divided up into several periods, each with a different prediction of an unknown variable. However, in the rolling horizon approach, an assumption is made that predictions for later periods will not affect the schedule of an earlier period. After initial experimentation, we found that the forecast for a period at the end of a schedule does have a large impact on earlier periods, and assuming there is no clean energy in the future leads to sub-optimal schedules. Therefore, we propose a model that makes the assumption that future forecasts will impact early schedule generation, but also assumes that long-range predictions can be inaccurate.
As a result, this new model will only rely on the forecast for the current period, and consume as much clean energy as possible. Then, all charges using non-clean energy will be postponed until the next period where possible, working under the assumption that there may be clean energy available in the future. Figure 2 depicts our single-period model (SPM) reactive method. However, due to the nature of (a) SPM method starting at 0 a.m.

Fig. 2
Visual representation of the SPM reactive method relying on the most accurate clean energy prediction, a new schedule must be calculated every 6 h. Furthermore, it should be noted that each schedule covers the entire day, in the event of unexpected failures (e.g., a connection lost). In this context, Fig. 2a calculates a schedule for the entire operational day with the predictions from 0:00 to 6:00 and assumes that clean energy may be available afterward. Then Fig. 2b (resp. Figure 2c), calculates a new set of predictions from 6:00 to 12:00 (resp. 12:00-18:00), assuming that more clean energy will be available from 12:00 to 18:00 (resp. 18:00 to 24:00). Finally, Fig. 2d computes the final set of predictions of clean energy for an operational day and calculates the final schedule with this information. As a result, the SPM reactive method should be more tolerant to over-estimations in the amount of clean energy available as it only uses the accurate prediction model, and under-estimations, as it tries to spread charges throughout the day.

Optimization model
In this section, we describe our optimization model. The following terms have been defined and are commonly used throughout the paper:  We remark that we calculate the value of the uncertain variables before solving the problem with the output of the LSTM forecasting model. Therefore, these values might change from one checkpoint to another. We also note that time is defined as a floating point number representing decimals of an hour. For instance, a value of 13.75 represents the time of 1:45 p.m. We also note that the variables D ij and T ij represent symmetric matrices for energy costs and time respectively. For example, the energy cost and time needed to travel from stop i to stop j is the same when traveling from stop j to stop i.
Constraint (1) restricts the battery capacity to be within the bounds of the min. and max. values. Constraint (2) sets the max. charge time to the value of . While Constraint (3) enforces that a charging station must be present for a bus to charge. Constraint (4) indicates the energy gained by charging bus b at stop i is proportional to the charging rate ( R ) and the charge time at stop i. Constraint (5) enforces a minimum charge time on all charges. Constraint (6) denotes the capacity of bus b at stop i. (7) sets the arrival time of bus b at stop i to be greater than the arrival time at the previous stop, plus the time spent charging, and the travel time between stops i and j. Constraints (8) and (9) denote the deviation time of the bus b at stop i w.r.t. the expected arrival time. As a result, the arrival time of a bus at any of its stops will be within the deviation time from the original schedule.
Additionally, we need to ensure admissible schedules with non-overlapping charging times for the eBuses at the same stop. Constraints (10)-(12) determine if buses b and d are scheduled to charge at the same charging station. Constraints (13) and (14) assert the order in which the bus arrives and finishes charging first at the shared charging station. Constraint (15) enforces that Constraints (13) and (14) are mutually exclusive for buses sharing a charging station. We would like to highlight that this set of constraints is only needed if the scheduled arrival times of buses b and d are close enough to overlap at a given stop.

Clean energy time windows
Constraints (16)-(26) capture the amount of clean energy used in k by every bus at every stop.
Constraints (16) and (17) (19) and (20) are implied by the rest of the model, however, they are explicitly stated to assist the search process. Constraints (21) and (22) determine the maximum amount of time bus b can spend using clean energy (21) determines how much time remains between the end of k and the time bus b starts using energy from k at stop i.
For example, if k is 0 then Constraint (21) determines the time between the end of the k and the arrival time of the bus, as there is no previous to use energy from. Constraint (22) determines the amount of time between bus b finishing its charge at stop i and the beginning of k . The values from Constraints (21) and (22) are used to constrain the upper bounds of wt bik . In particular, Constraint (21) requires information about how much time bus b has spent charging from previous instances of k . This is done to determine how much time is left before the end of k . Constraint (23) associates the total amount of clean energy used for bus b at stop i during k to be the amount of time the bus spent charging from that , multiplied by the charging rate constant. Constraint (24) ensures that the total amount of time bus b spends charging at stop i using clean energy does not exceed the total amount of time bus b spends charging at stop i. Constraint (25) enforces that the total amount of nonclean energy used is equal to the total energy used to charge bus b at stop i, minus the sum of the clean energy used to charge bus b at stop i across all . Finally, Constraint (26) asserts that the amount of non-clean energy used to charge bus b at stop i must be less than the total amount of energy used by bus b at stop i.
The amount of clean energy ( ce k ) available within k is limited by a certain threshold (e.g., given by certain meteorological conditions or the capacity of the wind farms). Therefore, any energy exceeding this value must be taken as non-clean energy. Constraint (27) enforces this requirement.

Objective function
The objective function (28) aims to minimize the total amount of non-clean energy used in the schedule based on the clean energy information provided to the MIP model. In the scenario where | | = 0 (i.e., there is no availability of clean energy) the objective function will minimize the total amount of energy used.

SPM reactive method
The SPM method creates a new schedule after every checkpoint (6 h in this paper, see Fig. 2) with the most recent LSTM predictions and prioritizes non-clean energy charge events to future times after the current checkpoint. This way, charges are nc bi spread throughout the day, and the optimization model has more opportunity to reschedule non-clean energy charges with more accurate predictions.
To achieve this, the MIP model applies a small reduction to the amount of energy used if the change takes place after the current checkpoint. To this end, Constraint (29) determines if the arrival time of bus b at stop i ( t bi ) occurs before the start of the next checkpoint ( ). In this case, the binary variable ase bi is equal to 1. Constraints (30) and (31) enforce how much of a reduction ( ) is applied to nonclean energy if the charge takes place afterward and sets the reduction to zero if the change takes place during the current checkpoint. Charges starting in the current checkpoint and finishing in the next one are not considered for the non-clean energy reduction provided by the SPM reactive method.
To apply the reduction to the non-clean energy used, Constraint (25) must be replaced with Constraint (32).
It is important to notice that Constraint (32) is identical to Constraint (25), however, the reduction for charges taking place after the current checkpoint (i.e., r bi ) is applied to the amount of non-clean energy used by bus b at stop i. As a result of these constraints, the optimizer will attempt to delay any charge using non-clean energy until after the current checkpoint. Thus scheduling charges later in the day and preventing clustering of eBus charging in the morning.

Empirical evaluation
This section presents an extensive empirical evaluation with real instances for three Irish cities and actual data from the Irish national grid. We start with the prediction of clean energy time windows using our LSTM models and then we present the empirical results of our integrated optimization framework.
Experiments relating to our LSTM models were conducted on a computer featuring a 3.6 GHz AMD Ryzen 7 3700X CPU, 16 GB of DDR4 RAM, and an RTX 2070 super GPU. Keras and TensorFlow 2.3.0, CUDA toolkit 10.1, and cuDNN SDK version 8.0.5 were used when making the LSTM models. Experiments for our optimization model were executed on a server using a 2.5GHz Intel Xeon W-2175 CPU and 62GB of RAM and CPLEX version 12.10.

LSTM models
As pointed out in Sect. 2.5, we create four LSTM models (one for each checkpoint) with forecasting horizons of 6, 12, 18, and 24 h to predict the amount of excess clean energy available. Furthermore, we populated our models with public data from the Irish national grid in 15 min intervals. Additionally, we trained our LSTM models with data from August 2013 to October 2021 and tested with data from November 2021 to January 2022. 1 The demand and wind-generated power data sets are aggregated into one data set which represents the excess of clean energy at any time. For example, if at time x there is more electrical demand than wind-generated power the amount of excess clean energy at that point would be negative. However, at the moment Ireland's national grid does not supply more wind-generated power than demand. As such, a modifier is applied where the amount of wind-generated power is 1.4 times higher than the actual amount. This is in line with estimations for Ireland's growth in wind-generated power by 2025 (Department of Communications, Climate Action and Environment 2019). This modified wind power is then used when calculating the amount of excess clean power.
When aggregating the two data sets, the new data set is comprised of negative values (representing more demand than wind energy), and positive values (representing more wind energy than demand). As a result, the training data set consists of 292,000 negative values, 9851 positive values, and 4 values of 0. Due to the fact there are very few positive data points to train the LSTM models, we employed the use of weights on each data point. The weights were calculated using the equation w = v∕n where v is the number of positive data points in the training data set and n is the total number of data points in the training data set. Data points with a value of 0 or lower are assigned the weight w, while any positive data points were assigned the weight of 1 − w . This resulted in negative points being assigned a weight of 0.0337 and positive points being assigned 0.9663. The data is made stationary by applying a difference operation on each subsequent value and normalized to a range between − 1 and 1 with the min-max normalization method (MinMaxScaler in the scikit-learn library).
Additionally, we reserved 33% of the training data set for validation and hyperparameter tuning.
We trained our LSTM models with the ADAM optimizer to minimize the Root Mean Squared Error (RMSE) (Kingma and Ba 2014). All models contain one LSTM layer with 50 neurons and a tanh activation function. Followed by a densely connected layer with a linear activation function. A learning rate of 0.015 is used with a learning rate decay of 1e−06. The number of epochs each model is trained for increases with the prediction horizon used. For a horizon of 6 h the model is trained for 200 epochs, this increases by 100 epochs per additional 6 h. A dropout rate of 0.15 is also applied to the LSTM layer.
The Smart Grid platform also provides a forecast of wind-generated energy with a time horizon of 6 h. We use these predictions as a baseline to determine the performance of our LSTM model, we also explore the performance of traditional time series prediction methods such as Seasonal Autoregressive Integrated Moving Average (SARIMA) (Box et al. 2015). After some initial experimentation, we found that the best performing SARIMA model used the values 10, 2, 0, 1, 2, 1, 24 for the parameters p, d, q, P, D, Q, and M respectively. Additionally, we also experimented with a variety of seasonality values (M), however, we ran out of RAM to generate feasible models. Table 1 shows the Man Absolute Percentage Error (MAPE) and RMSE of the three different methods of time series prediction evaluated. As can be seen, our proposed LSTM model outperforms both the baseline of the predictions obtained from the data-set provider, and the SARIMA model. Table 2 shows the MAPE and RMSE performance of the LSTM models with different prediction horizons, based on the results from the test data set. As expected, the performance decreases as we increase the time horizon. For instance, the RMSE doubles as we increase the time horizon from 6 to 12 h. However, it is worth noting that there is a much smaller decrease in accuracy when comparing the 18 h model and the 24 h one, with an increase of 41.1 for MAPE compared to an increase of 73.3 with the 6 h and 12 h models. This increase in error can be explained by the fact wind power is considerably harder to predict due to the unstable and chaotic nature of the wind power derived from multiple factors, e.g., wind speed, air density, wind turbines, etc. We recall that these results are consistent with the literature for wind power prediction over a large number of time-steps (Mora et al. 2021) as our predictions range from 24 time-steps in the future (6 h) and 96 time-steps in the future (24 h).

Empirical results
We evaluate our framework in three Irish cities, i.e., Cork, Limerick, and Galway with real data for 2 weeks, i.e., 14th of February 2022 to 27th of February 2022. The bus network in Cork includes 11 bus routes operated with 81 buses and 578 stations; the network in Galway includes 6 bus routes operated with 24 buses and 254 stations; and the network in Limerick includes 6 bus routes operated with 23 buses and 288 stations. 2 We recall that our framework assumes that the charging infrastructure is already available. Therefore, we simulate the following two scenarios: -Infrastructure A (Inf-A): the fast-charging stations are placed every 12 km on each bus route, for a total of 53 fast-chargers in Cork, 13 in Limerick, and 19 in Galway. -Infrastructure B (Inf-B): the fast-charging infrastructure is placed every 15 km on each bus route, for a total of 43 charges in Cork, 12 in Limerick, and 11 in Galway.
We assume that the discharging rate is 1 kWh per km, the charging rate is 10 kWh per minute, and is set to 1 min. We use an average speed of 35 km/h, however, certain buses are required to travel faster in order to reach the destination as per official timetables, in those cases we use the minimum feasible speed to be consistent with the admissible deviation times. We assign the value 25 to M, as this value is suitably large enough when dealing with the time-related Constraints (13), (14), (16), (17), (21), (22), (29), and (31). As there are 24 h in the day, and with our implementation of a floating point number representing decimals of an hour, a value of 25 is the smallest integer that ensures the validity of the previously outlined constraints. We evaluated our framework with multiple values for C max (i.e., 120, 180, and 240 kWh) and we set C min to a flat 12 kWh. The value of scales with C max allowing the buses to charge up to 80% of their maximum capacity in a single charge. For example, the value used for experiments with C max of 120 is 0.16. Representing 9.6 min in hour decimal. Furthermore, we explored two alternative upper bounds for t , i.e., 5 and 10 min. This framework assumes that overnight charging takes place at the depot, however, due to the slow rate associated with overnight charging, buses may not start the operational day at full capacity. To represent this, we assume the buses start with a capacity of 30 kWh regardless of the selected value of C max . This allows enough capacity for each bus to travel to its first fast-charging station while respecting the C min value of 12 kWh.
Any excess in energy that takes place before 5 a.m. is not recorded as the first operational bus from the examined data sets does not occur until 5 a.m., as a result, any clean energy before that time cannot be used in our framework. In addition, to evaluate the performance of our model with LSTM predictions, we also execute experiments with | | = 0 (i.e., no prior knowledge of ) and with ideal predictions. Ideal predictions represent the actual clean energy information for the examined time frame. Figure 3 showcases the actual energy excess for the fourteen experimentation days vs the predictions from our 6 h LSTM model.
As can be seen, predictions from our 6 h model gives a general idea of when clean energy occurs. However, it should be noted there are times when the LSTM model inaccurately predicts how much clean energy is available. The occurrences of under-prediction may result in potentially unused clean energy. Figure 4 shows the amount of energy demand vs the amount of modified wind energy for our fourteen test days. While Fig. 3 is more representative of how clean energy information is passed to the MIP model, Fig. 4 gives us a clearer picture of how much energy is available each day. For example, we see that there is a large amount of energy available on the 26th and very little energy available on the 17th, 18th, 21st, and 24th. This means results for these days could lead to a skew in the results. It should also be noted that there is a large amount of clean energy available early in the morning and late at night. This means bus systems with long operational days may benefit from additional clean energy.
Additionally, hereafter we assume that only a portion of the energy surplus is available to recharge the fleet of eBuses based on how much energy is needed to operate the bus system. In total 26.371 MW is needed to operate the bus systems of all three cities, Cork requires the most energy with 16.264 MW needed so it is assigned 61.67% of the available clean energy. Galway requires 6.048 MW while Limerick needs 4.059 MW, resulting in 22.93% of the clean energy going to Galway and 15.39% to Limerick. Additionally, we perform a subset of additional experiments where each city receives 100% of the available clean energy. We also explore scenarios where the bus discharge rate is set to 1.2 kWh per km.
We pre-compute a warm solution for the first schedule in a workday in order to speed up the runtime of calculating the solution of each problem. For this purpose, we fix C max = 120 kWh, max. t = 5 min., and | | = 0 (i.e., considering a scenario without clean energy). These warm solutions took 6.1, 0.7, and 0.4 s to find an optimal solution for Cork, Galway, and Limerick respectively. Furthermore, when a schedule is recalculated due to a change in the availability of clean energy (e.g., mispredictions in the previous checkpoint), the previous solution becomes a warm solution of the new schedule. It should also be noted that values assigned to variables that occur before the recalculation of the schedule are not changed. Finally, we use a timeout of 12 min to solve each problem. Table 3 shows the average results over all experiments with max. t = 5 min and our first charging infrastructure, i.e., Inf-A. for the proposed MPM and SPM reactive methods with different values for C max . Here, values in bold highlight the best performing method for each configuration (MPM or SPM). | | = 0 shows the non-clean energy consumption assuming that no prior knowledge about (i.e., set of clean time windows) is available. Prediction presents the results of our proposed models with our LSTM predictions, and ideal presents the results with an oracle with perfect predictions. When using solutions generated using | | = 0 or predictions the resulting charging schedule is overlayed with the historic values of how much clean energy is available. We then report the average consumption of non-clean energy across the fourteen reference days. In general, we sum the amount of non-clean energy consumed per checkpoint and report the average daily consumption of nonclean energy across our reference days. As expected, the best solutions generated by the MIP model occur when using perfect knowledge of future clean energy availability and the MPM schedule creation method. Our proposed smart model generates better schedules than traditional models without prior knowledge (i.e., | | = 0). Therefore, while our LSTM models are not fully accurate there is a notable benefit in the integration of the learning component in our schedules. As it can be seen, the SPM method outperforms the MPM method in 5 out of 9 scenarios (predicted column). We attribute this performance improvement to its ability to delay non-clean energy charge events until after the current checkpoint. The MPM method schedules non-clean energy during each checkpoint with the current knowledge, as a result, this method may be susceptible to false negatives in predictions from our 12, 18, and 24 h models. It should also be noted that results for | | = 0 using SPM for the Cork data set consistently perform worse compared to the results for MPM. Here we see MPM consistently outperforms SPM for the Cork data set. This suggests that larger data sets see fewer benefits from delaying non-clean charges. This topic is explored later in this section. Table 4 shows the relative performance difference for Table 3.The column Predicted vs | | = 0 shows the relative performance difference between the results of our proposed models with our LSTM predictions. Finally, the Ideal vs Predicted column shows the relative performance difference between results using our LSTM predictions and results with an oracle for perfect predictions. The relative performance difference represents the percentage improvement between the two scenarios. For example, values for the Predicted vs | | = 0 column are generated using the equation:

MIP results
Here we see our smart model using LSTM predictions can reduce the amount of non-clean energy used by an average of 1.5% when using MPM, and 2.18% when using SPM. When we compare the results of our MIP model with predictions with those of the oracle with perfect predictions, we see that we are able to generate solutions that are only 6.33% from the optimal solution on average while using MPM. As the reader recalls from Table 3, the oracle with perfect predictions using MPM consistently produced optimal schedules. Meaning our MIP model can perform substantially better if the prediction models improve.
We would like to highlight that we were unable to find the optimal solution for only 5 (out of 2268) experiments out of those featured in Table 3. The average optimality gap for those 5 experiments was 0.012% Table 3 also shows that increasing battery capacity may not reduce the amount of non-clean energy consumed (i.e., results relating to Limerick, and Galway with ideal predictions). In some scenarios a battery capacity of 120 will use all of the available clean energy, in these cases increasing the capacity will not improve the solution quality. However, for larger data sets (e.g., Cork) increasing battery capacity does reduce the amount of non-clean energy used, this is not only due to the increased consumption of electricity but also due to the operational hours of the bus system. The Cork data set includes buses that start their operational day at 5 a.m. while the earliest bus route in the Galway data set starts at 5:45 a.m. and Limerick at 6:30 a.m. As previously outlined there is clean energy available early in the morning and late at night, as a result, the Cork data set can make use of this additional clean energy that other data sets cannot.
It is also observed that the quality of solutions generated with SPM method and ideal predictions can sometimes decrease when increasing battery capacity. This may be due to SPM's limited knowledge of future clean energy after the current checkpoint. While SPM delays charges until after the current checkpoint, this may result in "spikes" in energy consumption immediately following a checkpoint. This may result in buses not having enough free capacity to charge using clean energy later in the same checkpoint. Larger battery capacities have larger values, thus allowing them to gain more energy in a single charge potentially leading to larger energy consumption or "spikes". Figure 5 compares the amount of energy consumed by both the MPM and SPM method vs the amount of clean energy available for the Cork data-set for the 27th of February using 5 min deviation time and 240 capacity battery. This shows energy consumption spikes at 12 p.m. and 18 p.m. for the SPM method as previously mentioned. We also see that the proposed MIP model is able to generate schedules that attempt to make full use of the clean energy available. Both MPM and SPM methods are able to schedule charges at times when excess in clean energy occurs such that most if not all clean energy is consumed when it occurs during the second half of the day.
As previously outlined, we performed a number of different experiments to evaluate the impact of certain parameters. Table 5 reports experiments where each city is given 100% of the available clean energy instead of being proportionally split. Here we see that the difference between our predictions and the naive solver, and our predictions and the ideal scenario increases.
Of note MPM using our predictions are able to generate schedules that are 6.04% better than | | = 0 on average. We also see that the schedules made by our MIP model using predictions are 12.23% from the optimal solution generated by using an oracle with perfect predictions with MPM. However, it should also be noted that when only examining the Cork data set, the average difference between the optimal solution and solutions generated using predictions is 8.23%. This would imply smaller data-set are more susceptible to miss-predictions. This topic will be explored more when we discuss the performance of SPM. Appendix Table 13 shows the percentage of clean energy consumed for experiments featured in Table 5. Table 6 shows results for experiments using 100% clean energy distribution, and a bus energy discharge rate of 1.2 kWh per km. This increase in energy consumption is to simulate the usage of air conditioning or heating on a bus during various times of the year. As can be seen, the relative performance difference decreases when compared to results from Table 5. However, the difference between the schedules  generated with LSTM predictions and with the oracle with perfect predictions has also reduced from 12.23 for the experiments reported on in Table 5 to 10.17%. This would imply the average optimal result is worse compared to experiments using 100% energy distribution, this is because the total energy consumption of each bus system is increased by 20%. From this, we can determine that the amount of clean energy available is a very significant variable when generating schedules. Again we also note that when examining the Cork data set we see the average difference between schedules generated with predictions and those generated with an oracle is reduced from 10.17% down to 6.08%. Appendix Table 14 shows the percentage of clean energy consumed for experiments featured in Table 6. Table 7 shows the impact of increasing the max. deviation time to 10 min. As expected the MPM model with ideal predictions improves the solutions (i.e., with lower non-clean energy consumption). We also observe a similar behavior as before with 5 min (i.e., the relationship between solution quality and battery capacity). However, allowing a larger deviation time slightly deteriorates the solutions for both models MPM and SPM models when using LSTM predictions. We attribute this phenomenon to the prediction errors in the LSTM model, the increased deviation time may allow the MIP model to schedule chargers during a given k with less clean energy than expected. While increasing the value for t increases solution quality, it is only increased by 0.685% on average for schedules generated using ideal predictions and MPM method. However, increasing the value of this variable also increases the search space of the problem. As a result, the computation time for experiments using t = 10 min is 27.39% longer on average compared to t = 5 min. Similar to our experiments with t = 5 min, we found optimal solutions for the majority of the instances. In particular, we were unable to find the optimal solution for 22 (out of 2268) experiments featured in Table 7. However, much like the experiments using t = 5 min, the average optimality gap was small with each non-optimal solution being on average 0.023% away from the optimal solution. Table 8 shows the relative difference for the results in Table 7. Here we see the performance of MPM using predictions sees little improvement compared to the naive scheduler, with schedules only being 0.82% better on average. We also see that the optimal solution is on average 7.81% better than a schedule made using LSTM predictions. However, we see the occurring pattern regarding the performance of the Cork data set where the difference between predicted and naive, as well as ideal and predicted is smaller compared to other data sets. Table 9 shows the average execution time in seconds and the average number of constraints for each city, method, t value across all dates, capacity, and prediction types. Here we see that the biggest influence on the execution time and the number of constraints is the data set used. For example, the Cork city data set features a million additional constraints compared to the Limerick city data set.
We recall that increasing the value for t also increased the computation time, which can also be seen here. The average number of constraints for experiments featuring a t value of 10 min is also increased. This directly relates to Constraints (10)-(15). As previously mentioned these constraints are only applied if the arrival times of buses b and d are close enough to overlap. As the maximum allowed  11,825.65 11,303.12 10,464.70 deviation time increases the range of potentially overlapping arrival times increases, leading to the increased number of constraints and execution time.
We also note the impact of the two different methods on execution time and the number of constraints. SPM consistently features a lower number of constraints compared to the MPM. As we recall, the SPM features additional Constraints (28)-(31), however, as this model only takes into consideration clean energy information for the next 6 h, the maximum value of k is 24. Which limits the number of times Constraints (16)-(27) feature in the optimization model. However, this is not the case with execution time, with experiments using SPM and a t value of 10 min consistently taking longer to execute compared to MPM with the same t value. In fact, out of the previously reported 27 non-optimal experiments, 21 of those experiments used SPM and a t value of 10 min as parameters.
We now switch our attention to Table 10 with details experiments conducted with a reduced charging infrastructure (i.e., Inf-B) and a maximum deviation time of 5 min. As expected, decreasing the number of charging stations results in an increase in the non-clean energy used. Intuitively, more buses will need to use the charging units which may be shared by multiple routes at the same time, buses also may not be able to reach a charging station in time to charge using clean energy from k . Therefore buses may not have enough time to make full use of the clean energy available. It should also be noted that MPM outperforms SPM on average. Due to the nature of having fewer charging stations, the SPM method would not be able to delay charges as much as in previous experiments. Thus leading to its poorer performance in comparison. Additionally, we note that the solution quality does not directly scale with the number of charging stations. For instance, our empirical results for the best-case scenario show Cork data set with 53 charging stations (i.e., Inf-A), ideal predictions, MPM method, and C max = 240 kWh only performs 0.93% better than Inf-B with 43 charging stations. Table 11 shows the relative performance difference for the experiments featured in Table 10. Here we see similar patterns of decreased performance of the LSTM predictions, with experiments using predictions only performing 0.63% better than a naive scheduler when using MPM. We also see that schedules created using predictions are 5.78% worse than the optimal solution on average. However this aligns with the previous assertion that a reduction in available charging stations leads to less opportunity for clean charging, thus less benefit from the proposed MIP model. Also of note, out of the 2268 experiments conducted with Inf-B and t = 5 min only 4 experiments failed to find the optimal solution with an average optimality gap of 0.01%. Figure 6 shows box plots for the Galway data set using LSTM predictions, and a 5 min deviation time comparing the methods and capacities used vs the objective function. This figure shows the SPM method outperforms the MPM method in some cases which matches the previous observations seen in Table 2. Here, points on each box plot denote a day from our test days, of note on some days SPM method outperforms the MPM method. Upon closer inspection, these days are subject to mispredictions regarding how much clean energy is available later in the day. For example, on the 27th at the 6 a.m. checkpoint the 12 and 18 h prediction models incorrectly estimate there is no clean energy available after 6 a.m., where in reality there is a significant amount of energy available after 2 p.m. as seen in Figs. 3 and 4. However, at the 18 p.m. checkpoint, the LSTM predictions update to show there is clean energy available. Figure 7 compares the amount of energy consumption for MPM and SPM methods vs clean energy available for Galway on the 27th with 5 min deviation time and 240 capacity when using LSTM predictions. Here we see that the MPM method consumes a large amount of energy before 13 p.m.. Because the optimizer is not informed of any clean energy available after 6 a.m. the MIP model will attempt to reduce the total amount of energy consumed. In these scenarios, CPLEX does not consider the distribution of energy, and schedules charging events at the earliest possible convenience. For smaller data sets that require less energy overall this results in most charge events occurring in the first half of the operational day. However, when the predictions update at 18 p.m. the MPM method cannot make full use of the available clean energy, as it has already gained most of the energy it needs to complete its daily operations. The SPM method appears to avoid this by delaying charges and only relying on predictions from the 6 h model. Figure 8 shows the energy consumption for the MPM and SPM methods vs clean energy available for Galway on the 20th with 5 min deviation time and 240 capacity when using LSTM predictions. Here we see the inverse of Fig. 7 where the majority of the clean energy available is in the morning between 6 a.m. and 15 p.m.. We also see that the MPM method is able to consume a majority of the clean energy available, while the SPM does not. This is because the predictions at the 6 a.m. checkpoint show that there is no clean energy after 10 a.m. As a result, the previously outlined phenomenon where CPLEX schedules charges early in the day works to the benefit of the MPM method. From this, we can make the observation that the most important factor for SPM's performance is if clean energy occurs at the start of the day (such as the 20th shown in Fig. 8) or at the end of the day (as shown in Fig. 7). From this, we may speculate that a modification to the SPM method may generate better Fig. 6 Comparison of methods and capacities used vs objective function score for the Galway data-set, 5 min deviation time, and LSTM predictions Fig. 7 Comparison of energy used for SPM and MPM methods vs clean energy available for the 27th for Galway data-set, capacity 240, 5 min deviation time, and LSTM predictions schedules. For example, in the event that the optimization model has no knowledge of future clean energy charges should be scheduled as evenly as possible throughout the day. This would be more efficient at combating mispredictions in our prediction models. Table 12 shows the average percentage of the available clean energy consumed by the bus system for the results shown in Table 3. From this, we see that the difference between the amount of clean energy consumed by | | = 0 and Predicted scenarios increases as the size of the data-set increases. For example, with the Limerick data set using MPM there is up to a 2.19% increase in the amount of clean energy consumed. However, with the Cork data set there is up to a 9.01% increase in the amount of clean energy consumed when comparing Predicted to | | = 0. However, the gap between the percentage of clean energy consumed for the ideal and predicted scenarios is larger. When looking at experiments using MPM the difference between ideal and predicted ranges from 10.16% clean energy consumed to 20.44%. We also perceive the existing pattern of SPM outperforming MPM on the smaller data sets of Limerick and Galway in the Predicted scenario. This aligns with the previous observation relating to CPLEX's scheduling of charging events then there are inaccuracies in the predictions.
We also note that the amount of clean energy consumed is not the objective function of our proposed MIP model. As a result, the percentage of clean energy consumed may be lower compared to other configurations, but the value for non-clean energy consumed may be lower. For example, the Cork data set using capacity 240 and MPM consumes 77.17 of the available clean energy, whereas the same configuration using 180 consumes 77.93. However, as the reader recalls from Table 3 battery capacity 240 outperforms 180 by 20.5 kWh. This is because the MIP model is allowed to generate schedules that consume more energy than is needed, as long as the non-clean energy consumed is minimized. As a result, more clean energy is used. Figure 9 shows a bar chart with the average performance of the MPM method for each data type used (i.e. | | = 0 , Predicted, and Ideal) and each city. Here we see that the average difference between the three prediction types heavily depends on the data set used. For example, smaller data sets like Limerick show little difference between the three prediction types. However, the much larger Cork data set shows a more significant difference between the results of | | = 0 , Predicted, and Ideal. This means when applying methods developed in this paper to a large city's bus system, there is potentially a large saving in the amount of non-clean energy used.

Conclusion
In this paper, we have presented a robust framework for a sustainable and efficient transition to eBuses. To this end, we use a deep learning model for wind power forecasting to estimate the availability of clean energy in a day, we then integrate the output of the forecasting method into two reactive methods (MPM and SPM reactive) to properly schedule and optimize the charging events. These  Table 3 methods maintain a constant interaction with the environment to update the solution (on-line) when new information is available. Extensive experimental results with real data from the Irish national grid and a major bus operator in Ireland suggest that our MIP model is able to generate a schedule that consumes up to 77.93% of the available clean energy when using an oracle with perfect predictions. We also found that our schedules generated with LSTM predictions report an improvement of up to 5.44% against a naive scheduler and an average discrepancy of 6.33% w.r.t. the ideal scenario (with perfect predictions and MPM) for our baseline experiment simulating the transition to eBuses with the estimated increase in wind power by 2025 in Ireland. Additionally, our sensitivity analysis with additional availability of clean energy suggests that our scheduler reports an improvement of up to 9.63% against a naive scheduler and an average discrepancy of 12.23% w.r.t. the ideal scenario. Furthermore, we remark that our scheduler using LSTM predictions uses up to 58.24% of the available clean energy on our baseline experiment and up to 47.31% on our experiment with additional availability of clean energy.
As expected, the size of the batteries does have a notable impact on the percentage of renewable energy required to operate a large fleet of eBuses. Generally speaking, while a number of variables such as maximum deviation time and the total number of available charging stations impact the solution quality, the relationship is not proportional, this leaves room for further work regarding optimal infrastructure planning. While our predictions do not generate solutions as high quality as the bestcase scenario with perfect predictions, a significant reduction in non-clean energy consumed can be observed on larger data sets. Therefore, the results of the evaluation confirm the high-quality performance of the proposed approach.
In the future, we plan to extend our framework with a Bus-to-grid technology to help the national grid by returning part of the energy when needed, e.g., during peak hours. As well as making further improvements to the SPM method proposed in this paper to mitigate the impact of poor predictions. Furthermore, we also plan to extend our implementation with other sources of clean energy, e.g., solar power. Table 13 shows the percentage of clean energy consumed for experiments using 100% energy distribution across all data sets. Here we see that the total amount of clean energy consumed is slightly reduced compared to Table 12, despite the results reported in Table 5 being better than those reported in Table 3. This is because there is more energy available during certain points of the day than the bus system is able to use. Thus leading to a decrease in the total percentage of clean energy consumed. Table 14 shows the percentage of clean energy consumed for experiments using 100% energy distribution, and a bus discharge rate of 1.2kWh. When compared to Table 13 we see that the percentage of clean energy consumed has increased. This is because the bus system requires 20% more energy, and thus will be able to consume more of the available clean energy. This along with the results of the other appendix table shows that, while the percentage of clean energy consumed is a useful metric for determining the performance of our MIP model, the raw results and relative differences are also needed.