An Attention-Based Model for Travel Energy Consumption of Electric Vehicle with Traffic Information

. Mileage anxiety is one of the most important factors that aﬀect the driving experience due to the limitation of battery capacity. Robust and accurate prediction of the energy consumption of the journey of the electric vehicle can guide the driver to allocate the power rationally and relieve the anxiety of the mileage. Since vehicle sharing is the biggest application scenario of electric vehicles, it is a critical challenge in share mobility research area. In this paper, a travel energy consumption prediction model of electric vehicles is proposed in order to improve the mobility of shared cars and reduce the anxiety of drivers because they are worried about insuﬃcient power. A recurrent neural network with attention mechanism and deep neural network is used to build the model. To validate the proposed model, a simulation is demonstrated based on both traﬃc and vehicle information. After the simulation, experimental results show that the proposed model has high prediction accuracy, and we also show through visualization how the model ﬁnds high relevant road segments of the road network while dealing with corresponding traﬃc state input.


Introduction
In recent years, people have paid sufficient attention to environmental pollution problems and the depletion of oil resources caused by excessive use of fossil fuel. e development of pure electric vehicles to replace the traditional energy vehicles is one of the important ways to solve these problems. e current commercialized application of electric vehicles is car sharing, which has many benefits such as being environmentally friendly, saving energy, and reducing emission [1]. However, the imperfection of the current battery technology and the battery capacity constraint still leads to car sharing user experience mileage anxiety while driving a shared electric car.
ere are many existing applications for car sharing system using electric vehicles showing the strong correlation between electric vehicles and car sharing technologies, but with the lack of discussion on range anxiety caused by limitation of the current battery technology and the battery capacity constraint [2,3]. Neubauer and Wood published a paper to examine the sensitivity of BEV utility to range anxiety and different charging infrastructure scenarios, including variable time schedules, power levels, and locations (home, work, and public installations). e results indicated that the effects of range anxiety can be significant but are reduced with access to additional charging infrastructure [4]. Some state-of-the-art works have made effort to address the aforementioned problem by improving the battery performances during the battery manufacturing production chain. In [5], a random forest based feature analyses and modelling method is proposed for battery manufacturing, and the coupling effects of the battery features are mined and quantified by using the ML technologies. Further in [6], a Gaussian process regression model is used to analyze the influence of battery electrode mass load under the underlying correlation of four intermediate production feature variables. Meanwhile, applying advanced battery management technology is the other approach to reduce mileage anxiety. For instance, King et al. used on-demand vehicle access method to alleviate electric vehicle range anxiety, and with the help of battery management strategy, the driving range of EVs get is further improved [7]. In [8], a multiobjective constrained nonlinear optimization is applied to adjust batteries charging patterns, which effectively improve the energy-saving performance of EV. In [9], a battery changing management strategy is proposed to cooptimize the energy consumption and battery degradation. In [10], battery charging process considering internal temperature control is addressed by generalized predictive control (GPC). Energy consumption prediction is a core technology for battery management of EVs; besides the driver, accurate prediction of energy consumption can effectively alleviate the driver's anxiety and help them concentrate on driving the vehicle. However, the energy consumption of an electric car is affected by many factors, such as traffic status, vehicle status, and weather. For this reason, travel energy consumption prediction has long been considered as a difficult problem.
ere has been much research on this issue. Cartenì et al. proved that the performance of electric vehicle has huge impact on car sharing models. e results indicated that the most statically significant attributes for those models are travel cost and travel time [11]. Ralf made a research on the estimation on energy consumption of the navigation route. A rule-based method was used in this work, which was conditioned on historical traffic and speed limit. However, the design of rules and the setting of coefficients needed experts, which should be changed under different situations [12]. De Cauwer et al. constructed energy consumption calculation models based on traffic information, vehicle parameters, road topology, and other information. e models are constructed by multiple linear regression, which was based on vehicle dynamics equation as underlying physical model. e model is complex and requires extensive feature preprocessing of the data [13]. Moreover, there are many similar works on the vehicle's energy consumption prediction [14,15]. However, there is a complex and coupling relationship between driving condition and energy consumption of EVs. e tradition method cannot handle the nonlinear regression with spatiotemporal features especially considering traffic information. Since 2006, deep learning has been applied in many fields and has achieved very successful results [16], such as object recognition [17,18], machine translation [19], and speech recognition [20]. Deep learning creates abstract high-level features by combining lower-level features to discover the distributed representation of the data, and in the high-level feature space, we can perform some operations that cannot be done in lower-level space. A deep convolutional neural network based energy consumption prediction method was proposed considering the influence of vehicle speed, tractive effort, and road elevation [21]. Recurrent Neural Networks are adapted to estimate the energy consumption of EVs during the specific route [22]. However, these methods cannot guarantee the prediction accuracy and robustness because they do not take the impact of traffic flow on vehicle operating conditions into account, where the traffic information on the driving route is merely considered in the existing ones at best. In fact, the traffic states of the whole road networks, especially the neighbor roads of the driving route, would make great influence on the energy consumption of EVs. However, the information of the whole road networks is tremendous to capture and distill the useful knowledge for deep neural networks. However, working with such high-dimensional information necessitates a powerful mechanism to steer the model to information important to the task at hand. us, an adaptive weighting mechanism should be applied when exacting features of road networks. Fortunately, the attention mechanism has a great promotion effect in sequence learning task and has many successful applications in the field of image caption [23], NLP [24] graph transformers [25], and other areas [26,27], which is a kind of encoder that imitates the behavior of human attention. However, the attention mechanism based energy consumption prediction method has not been constructed; further, as a result of this, the traffic information of the road networks is still not fully unutilized to further improve the prediction accuracy for energy consumption of EVs. Motivated by that, we proposed an attention based prediction model to improve the robustness and accuracy by extracting traffic state information in different sections of the road network during the forecasting process.
Accordingly, a deep learning method is used to construct an electric vehicle travel energy consumption prediction model based on traffic conditions and vehicle states in this paper, which aims to make a robust and accurate prediction of the vehicle energy consumption during the journey. In the proposed model, we utilize traffic information and vehicle status information, which are two different types of information. Since traffic conditions of the road network are continuously changing during the trip, traffic conditions during the trip as a sequential input were considered. And the recurrent neural network is used, which is suitable for dealing with sequential input, to extract the features of the traffic status of the whole trip. en, the deep neural network was applied to fuse the vehicle state features with the traffic state features and output the prediction results of energy consumption of the trip. For the traffic feature extraction, the traffic information of the road network is used as the input of the model. e traffic conditions of the road network can help provide information on the traffic state changes during the driving of the vehicle in the task of predicting travel energy consumption. More specifically, the congestion, the morning peak hour, and the evening peak hour are major scenarios that would be tested in the paper. Besides, an attention mechanism was employed to help the model extract the information that has a great influence on the current task from the traffic state of road network. erefore, we extract the feature of these two kinds of information separately and fuse the extracted feature information in the hidden space. Finally, we use the fused feature to predict the energy consumption of the trip. Furthermore, we show how attention mechanism can help the energy consumption forecasting model extract traffic state information and how its attention degree changes in different sections of the road network during the forecasting process.
In the following sections of the article, first, we described the construction of the model. en, we conducted a comparative experiment and analyzed the influence of input of different information and the model structure on the accuracy of the model. Finally, we visualize the attentional mechanisms of the model and illustrate the characteristics of attentional mechanisms in extracting traffic characteristics.

Methodology
e travel energy consumption of a vehicle is mainly determined by the driving cycles of the vehicle, and the operating conditions of the vehicle are affected by traffic conditions and the status of the vehicle. erefore, in order to accurately predict the energy consumption of electric vehicle travel, we need to use these two kinds of information. In this section, a prediction method of travel energy consumption of electric vehicles based on deep learning model combined with attention mechanism is proposed. Figure 1 gives the framework of the proposed deep learning architecture. e details are given as follows.
RNN is a kind of neural network, which is suitable for dealing with sequential input data. e connection between hidden layers makes RNN have memory of preceding input data [25]. Road network is composed of numerous road segments, and the vehicle travel is a sequential composition of several road segments. We use traffic states of the road segments, in which the car during the travel is the input of RNN. In this paper, we use traffic flow, velocity, density, and the length of road segment as traffic state input. e traffic states input of a travel is represented as X.
where n is the number of road segments of the travel and d is the size of input vector. In this paper, d is equal to 4 as we described above. Vehicle travel energy consumption is directly affected by vehicle driving cycles, and vehicle driving cycles are mainly affected by traffic states. For the travel energy consumption prediction task, the future traffic state information corresponding to the traveling route of the vehicle is the key information. However, future traffic states of each road have a complex correlation with the current traffic states of road network. In order to make a reasonable and precise explanation of the total traffic state of vehicle travel, we utilize not only the traffic states of the route, but also the traffic states of road network as input. We represent current time traffic states of road network as where m is the number of roads of road network and ts i is the traffic state vector of i-th road segment of the road network. For each trip, the current traffic conditions of some sections of the road network may affect the traffic conditions on the vehicle's path in the future. However, it is difficult to determine which roads we should pay more attention to. In order to help the model find out high relevant roads to the prediction task, we employ attention mechanism in our model. Attention is implemented as a hidden layer, which computes a categorical distribution (or hierarchy of categorical distributions) to make a soft-selection over source elements [28]. For each road segments in the road network, the attention mechanism produces m-dimensional positive weight a t . Each dimension of a t , shown as a t,i , can be interpreted as the relative importance to give to road segment i in blending the ts i ,'s together.
A � a 1 , a 2 , . . . , a n , a t ∈ R m . (3) e a t is computed by an attention model f att for which we use a multilayer perceptron (MLP) conditioned on x t and previous hidden states h t−1 .
Once weights are computed, the traffic state representation feature s t can be computed by where w s is the learned weights and ⊕ is the concatenation of two vectors. e initial hidden state h 0 is computed through one MLP conditioned on x 1 .
e traffic states feature vector of the whole trip can be computed in a recursive way.
We use the final hidden states h n as the output of traffic information extractor. e other important factor of travel energy consumption is vehicle state. For electric vehicle, State of Charge (SOC), cell temperature, and cell voltage are key influence factors of vehicle energy consumption. In order to combine vehicle states into prediction model, we employ a MLP as vehicle states extractor. e vehicle state v s ∈ R k is a k dimensional vector, which contains all key factor of vehicle energy system, which can be collected.
where w vh and b v are the learned weights and bias and PReLU [29] is the activation function. e task of energy consumption predictor is to make the prediction conditioned on the output of traffic information extractor and vehicle states extractor. We concatenate traffic information extractor's output h n and vehicle states extractor's output v h as C and use it as the input of the predictor. We use a deep neural network (DNN) to make the Advances in Civil Engineering prediction, and 3 hidden layers should be enough in this task. e output of energy consumption predictor y pred is the prediction result of the task. e model can be trained jointly by minimizing the residual between model's prediction result and ground truth, and the loss function is where N is the number of training sets.
In the training process, the sequenced traffic information is input into RNN, and h n is outputted by the last layer, then the feature vector v s mapped to the vehicle state vector is fused with h n as a input vector of DNN, and the final energy consumption prediction result y pred is obtained by DNN. us, the loss function can be calculated with the ground truth y truth . ough backpropagation, the neural network parameters can be optimized with the optimizer RMSprop [30], where the learning rate is set as 0.00001 before the 10 th epoch and 0.000001 after that. After 100 epochs, the training process will be terminated, and the trained neural network will be tested under the test dataset.

Experiments Design
In this section, we introduce the process of the construction of dataset and implement detail of the model.

Data Description.
Our model is a data-driven model and needs two kinds of data, traffic information of road network and the vehicle state. However, it is difficult for us to obtain traffic status data and vehicle status data corresponding to each other. We have built a simulation platform for electric vehicle operation data collection and travel energy consumption calculation.
We utilize Quadstone Paramics traffic simulation software to construct a traffic simulation model, from which we can collect traffic states of all road segments of road network and driving cycles of vehicles. Moreover, we build a vehicle simulation model by Simulink/MATLAB, from which we can collect vehicle states and compute travel energy consumption. e logic diagram of the simulation platform is shown in Figure 2.

Traffic Simulation Model. Quadstone
Paramics is a traffic microsimulation software, which is widely used in many aspects of transportation. A Paramics model is represented by a combination of "nodes, links, and traffic zones" to construct the road network in the real world. rough the set of OD matrices, users can adjust the traffic flow on different roads. Users can also change the individual vehicle movements by adding plug-ins in the model. As shown in Figure 3, we construct the road network of traffic simulation model based on the road network of Beijing Northwest ird Ring Road. Each road segment of the road network has an index from 1 to n, where n is the amount of road segments in the road network. In this paper, we construct a road network with 330 road segments and 27 travel regions. From traffic simulation model, we get traffic information of road network and driving cycles of vehicles, which run on the road. Traffic information contains the average traffic flow, velocity, and density of every road segment in the road network every minute. And, we randomly choose numerous vehicles running on road from the traffic simulation model and record its driving cycles by granularity of 0.5 s and the index of the road segments the vehicles have passed.
When making a prediction, we should choose a possible route at first and construct traffic states input based on this route. We also add vehicle location information loc t to traffic state input x t , and one-hot encoding vector is employed to represent location information (e.g., in the case road, the network has 5 road segments, loc t � [1, 0, 0, 0, 0] for the index of t th road segment of the route is No. 1). Figure 4,

Driver Simulation Model.
e driver controls vehicle vertical dynamic by the accelerator or brake pedal based on the difference between the actual speed of the feedback and the expected speed of the vehicle, thereby determining the driving or braking torque, and real-time following the speed. Commonly using the PI controller to simulate the driver's operation, the driver's PI controller principle is shown in the following formula: where v ref is the reference speed, v f is the real speed, and v e is the error between v ref and v f , Acc is the angel of the accelerator or brake pedal normalized into [−1, 1], in which [0, 1] represents acceleration and [−1, 0] represents deceleration, A is the full range of pedal angel, k p is the proportional factor, k i is the integral factor, and λ i is the Integral antisaturation coefficient. e driver model adjusts the output driving or braking torque as follows: T d is the motor torque, where T d ≥ 0 represents the driving torque, and T d ≤ 0 represents the brake torque.

Motor Model.
e drive motor uses a quasi-steady state method to simulate the motor and its controller, and the quasi-steady state equation is shown in the following equation: In the formula, n m is the rotation speed of the drive motor, T m is the torque of the drive motor, and η m is the efficiency of the main drive motor. Its efficiency MAP is shown in Figure 4:

Battery Model.
e battery model uses a R int model, which is an equivalent circuit model characterized by open circuit voltage and resistance. e calculation formulas of current and power under this model are as follows: Among them, V oc is the open circuit voltage, and R int is the internal resistance of the battery; they are the function of battery SOC and temperature T. e energy consumption of the battery can be calculated by the following formula: In the formula, f is the rolling resistance, α is the road ramp angle (the default value is 0), m is the curb mass, g is the acceleration of gravity, C d is the air resistance coefficient, and A is the windward area of the vehicle.
We randomly set the initial SOC and collect the status of various key components in the running process of the vehicle and calculate the travel energy consumption. e travel energy consumption results of the vehicle are used as the ground truth of prediction model. We used the data collected by real vehicles to verify the accuracy of the vehicle simulation model. e test results show that the error in the calculation of travel energy consumption of our vehicle simulation model is within ±3%. erefore, we can treat the simulation data as a replacement of real data.
We made a four-hour traffic simulation and collected 31175 vehicle driving cycles using the traffic simulation model. Furthermore, we compute the energy consumption of these driving cycles by utilizing the vehicle simulation model. For stabilizing the training process, we normalize the data by rescaling data to [0, 1].

Results Analysis
We divide the dataset into numerous batches with a size of 30. We make the dataset by combining traffic states information and vehicle states information together. e model can realize an end to end training by minimizing the loss function, and we use RMSProp to optimize the model.
We employ the deterministic "soft" attention [23] in our model, which computes the weighted expectation of road network's traffic states. Ideally, the attention mechanism should be able to find out high relevant roads to the prediction task, by setting high value to the corresponding road of the weight vector. e visualization of attention mechanism is shown in Figure 5.
As we can see in Figure 6, during the whole trip, the attention mechanism promotes the prediction model, paying more attention to the traffic state of currently located and roads, where the vehicle on it can reach the road in a short time. Furthermore, at the initial stage of the trip (before 5 min in Figure 6), the model pays more attention to roads near to the location of the vehicle. As the vehicle travels on the preset route (10∼15 min in Figure 6), attention is attached to the mainline far away from the vehicle location. e pattern learned by attention mechanism agrees with the principle of traffic evolution process. As the traffic flow of the road network changes dynamically, the near future traffic state of a road is mainly affected by the current traffic state of the road itself and roads, where the vehicle on it can reach the road in a short time, where the far future traffic state of a road is further affected by the traffic state of a wider range of road network. Besides, the attention mechanism also helps  the RNN based prediction model with recursively feeding traffic states input into the model. In order to explore whether the attention mechanism helps improve the model's performance on prediction, we make a comparison experiment by removing attention mechanism from our model but using the same dataset for training and testing. Furthermore, we explore the importance of traffic information and vehicle information to our model by making a simply modification to our model and training the model by using traffic information and vehicle states separately. For verification, the results are shown in Table 1 and Figure 7.
e experiment result shows that the model with attention mechanism has a better performance than the model without attention. Combined with the visualization of the attention, we can know that the attention mechanism exactly helps the model extract the feature of traffic state. We verify the importance of vehicle state information by removing vehicle states extractor from the model, and we train the model using traffic state and distance data. For the verification of the importance of traffic states information, we use vehicle states and distance to finish the prediction task. For the selection of model, we choose a DNN with three hidden layers. From the results, we know that traffic states information is the key information of the travel energy consumption prediction, and the model has a poor performance without traffic states information.
e performance of the model trained without vehicle states information also has a decline. In this paper, the impact of removing traffic information is greater than removing vehicle state information from the model.

Conclusion
In this paper, a method of traffic state feature extraction was proposed based on attention mechanism, which can extract effective key features from high-dimensional traffic network state data and reduce the interference of irrelevant features on travel energy consumption prediction model. Furthermore, a deep learning prediction method for energy consumption of electric vehicles based on traffic information is demonstrated.
e method integrates vehicle status information and traffic network status features. e experimental result shows that the travel energy consumption prediction proposed in this paper has a high prediction accuracy. e idea of this paper can help the future work in travel energy prediction and traffic state prediction. Besides pure electric vehicle, how other vehicle models affect the proposed method needs to be further investigated in future studies.

Advances in Civil Engineering
However, there are still some limitations of this paper. e proposed prediction model is trained with data produced form simulation because the match data of traffic networks and electric vehicles is hard to be obtained in the real world. For future research, the model will be further researched and tested with real data. Besides, the effects of air condition usage and driver styles will be taken into consideration for a more accurate energy consumption prediction.
Data Availability e EV data collected from ROEWE used to support the findings of this study were supplied by SAIC under license, and so these cannot be made freely available. Requests for data, (6/12 months) after publication of this article, will be considered by the corresponding author.

Conflicts of Interest
e authors declare that they have no conflicts of interest.