A joint prediction method for electric bus energy consumption and v2g schedulable power
Patent Information
- Application Number
- CN202611189089.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-06
- Publication Date
- 2026-10-30
AI Technical Summary
[0052]本发明通过构建KDTree空间索引将车载OBD数据与路网坡度特征进行高精度匹配,并引入全路网拥堵背景特征,以各路段拥堵指数的统计均值表征全局交通流状态,实现了微观车辆状态与宏观城市环境信息的空间匹配与深度融合,打破了单一车载数据的信息孤岛,有效解决了现有技术中因缺乏道路物理属性(如坡度)和动态交通流(如拥堵)信息而导致的预测偏差问题。通过引入坡度特征,模型能够有效反映车辆在爬坡或下坡过程中的势能变化对能耗及电量回收的影响;通过引入拥堵背景特征,模型能够感知全局交通流对车辆频繁启停的潜在影响,通过这种多源异构数据的时空融合,极大地丰富了输入数据的特征维度,显著提高了训练数据的有效性和全面性,为后续模型准确理解复杂城市工况下的车辆运行规律奠定了坚实的数据基础,从而有效提升了电动公交能耗与V2G可调度电量预测的鲁棒性。
Smart Images

Figure CN123014734A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the interdisciplinary fields of intelligent transportation, new energy vehicles, and deep learning, specifically to a joint prediction method for the energy consumption of electric buses and the dispatchable power of V2G. Background Technology
[0002] Electric buses not only undertake daily passenger transport tasks, but their large-capacity power batteries also make them mobile energy storage units. Through vehicle-to-grid (V2G) technology, electric buses can feed electricity back into the grid during off-peak hours, participating in peak shaving and valley filling and ancillary services. However, V2G dispatching relies on accurately determining the vehicle's dispatchable power capacity, which directly depends on the remaining power after the vehicle completes its subsequent operational tasks, i.e., it is closely related to the vehicle's energy consumption. Therefore, accurate prediction of the electric bus's trip energy consumption and V2G dispatchable power capacity is crucial for balancing public transport operation assurance and grid interaction benefits, and has significant practical implications for improving the synergistic efficiency of transportation and energy systems.
[0003] Currently, research on energy consumption prediction for electric vehicles is quite extensive, primarily employing methods such as physical model-based analysis and data-driven machine learning. However, in the specific application scenario of electric buses, existing technologies still have significant shortcomings, failing to meet the demands for high-precision joint prediction. These shortcomings are mainly reflected in the following two aspects:
[0004] (1) Existing technologies, when constructing training data for predictive models, have a single feature dimension and lack effective integration of complex urban environmental factors. Most existing methods rely solely on onboard OBD (On-Board Diagnostics) data, such as vehicle speed, battery current, and SOC, treating vehicles as isolated individuals for analysis. However, the energy consumption of electric buses is greatly affected by the external environment. For example, changes in road gradient directly determine the amount of work done by the vehicle against gravity, which has a significant impact on energy consumption; while the traffic congestion of the entire road network reflects the potential impact of macro-traffic flow on frequent vehicle starts and stops and idling. Existing technologies ignore these key urban background features or only use simple average road segment speeds to characterize road conditions, resulting in training data that cannot fully reflect the operating status of vehicles under real complex urban conditions, and insufficient data validity, thus limiting the accuracy of predictive models.
[0005] (2) Existing technologies lack effective means for deep spatiotemporal matching and fusion of multi-source heterogeneous data. Vehicle OBD data is high-frequency time-series data, road network slope is a spatial static attribute, and traffic flow is time-varying data. The three have huge differences in data structure and sampling frequency. Simply splicing data from different sources cannot guarantee the accurate alignment of data in time and space, and will introduce a lot of noise. For example, failing to accurately match the vehicle position at a certain moment to the actual slope of its road segment, or failing to effectively associate the vehicle's operating segment with the congestion background and road slope attributes of the road network, will lead to ambiguity in the causal relationship between features and labels, affecting the model's ability to learn effective mapping rules from training data.
[0006] Therefore, there is an urgent need for a prediction method that can deeply integrate multi-source spatiotemporal data, construct high-quality training feature sequences, and perform joint modeling to solve the above-mentioned technical challenges. Summary of the Invention
[0007] To address the shortcomings of the existing technologies, the technical problem this invention aims to solve is: how to provide a joint prediction method for electric bus energy consumption and V2G schedulable power, capable of integrating multi-source heterogeneous data such as onboard OBD data, road network slope characteristics, and overall road network congestion background. By constructing a spatiotemporal fusion feature matrix, performing NCA dimensionality reduction and SOC bypass normalization, and utilizing a Transformer multi-task model to capture long-term temporal dependencies and inter-task correlations, the accuracy and robustness of the joint prediction of electric bus energy consumption and V2G schedulable power can be significantly improved.
[0008] To solve the above-mentioned technical problems, the present invention adopts the following technical solution:
[0009] A joint prediction method for electric bus energy consumption and V2G dispatchable power includes:
[0010] S1: Acquire multi-source data including electric bus OBD data, road network data, and road traffic flow data;
[0011] S2: Extract on-board OBD data aligned with the trip, a slope feature table containing the slope characteristics of each road segment, and full road network congestion data of the target area from electric bus OBD data, road network data, and road traffic flow data;
[0012] S3: For each vehicle OBD data, spatiotemporal matching is performed with the slope features in the slope feature table and the congestion background features in the road congestion data of the entire road network in the target area to obtain the corresponding spatiotemporal fused OBD data.
[0013] S4: For each spatiotemporal fused OBD data, extract the original feature matrix containing OBD dynamic features, urban background features, and multi-source interaction features, as well as the corresponding trip energy consumption target and V2G schedulable power target.
[0014] S5: After performing NCA dimensionality reduction on each original feature matrix, normalization is then performed, and the corresponding battery SOC features are normalized and then concatenated separately to the end of the regression-normalized feature matrix to generate the corresponding input feature sequence.
[0015] S6: For each input feature sequence, use it together with the corresponding normalized travel energy consumption target and V2G schedulable power target as a set of training data; divide all training data into training set and test set according to the proportion;
[0016] S7: Construct a Transformer multi-task model with input feature sequences as input and predicted travel energy consumption and V2G schedulable power as output, and train the model using training data to obtain a trained Transformer multi-task joint prediction model.
[0017] S8: Construct an input feature sequence based on the multi-source data to be processed, and input it into the trained Transformer multi-task joint prediction model to output the corresponding trip energy consumption prediction value and V2G schedulable power prediction value.
[0018] Preferably, in step S2, the processing steps for extracting vehicle OBD data include:
[0019] S201: Extract onboard OBD data from electric bus OBD data, including vehicle speed, battery SOC, battery current, ambient temperature, engine speed, GPS coordinates, timestamp, and trip energy consumption proxy indicators;
[0020] S202: Identify the vehicle OBD data by trip as the organizational unit to obtain vehicle OBD data associated with the trip.
[0021] Preferably, in step S2, the processing steps for extracting the slope feature table include:
[0022] S203: Filter and extract the segment IDs of all road segments within the target area from the road network data; query the representative coordinates corresponding to each segment ID in batches via API;
[0023] S204: Take the representative coordinates of the road segment as input to obtain the elevation value of each coordinate point; calculate the slope characteristics of the road segment based on the elevation difference and horizontal distance between adjacent coordinate points.
[0024] S205: Execute S204 for each road segment to generate a slope feature table containing the slope characteristics of each road segment.
[0025] Preferably, in step S204, the slope characteristics of the road segment include average slope, maximum slope, and minimum slope.
[0026] Preferably, in step S2, the processing steps for extracting road congestion data for the entire road network in the target area include:
[0027] S206: Extract road segment traffic data from road traffic flow data, including timestamps, road segment IDs, road types, average vehicle speeds, and congestion indices.
[0028] S207: Using road segment ID as the dimension, aggregate traffic data for all road segments within the target area to generate comprehensive road network congestion statistics for the target area.
[0029] Preferably, step S3 specifically includes the following processing steps:
[0030] S301: Construct a KDTree spatial index based on the representative coordinates of all road segments in the slope feature table;
[0031] S302: Extract the GPS coordinates from the vehicle OBD data, find the road segment with the closest spatial distance in the slope feature table through the KDTree spatial index, and associate the slope features of the corresponding road segment with the vehicle OBD data to obtain slope-matched vehicle OBD data;
[0032] S303: At each moment, perform statistical feature calculations on the road congestion data of the entire road network in the target area, extract the congestion background features, and obtain the congestion background features at each moment.
[0033] S305: Extract the timestamp of the slope-matched vehicle OBD data, match the congestion background features at the same time, and associate the congestion background features with the slope-matched vehicle OBD data to obtain spatiotemporal fusion OBD data containing slope features and congestion background features.
[0034] S306: For each piece of vehicle OBD data, execute steps S302 to S305 respectively to obtain the corresponding spatiotemporal fusion OBD data.
[0035] Preferably, in step S303, the congestion background characteristics include the congestion mean, congestion standard deviation, average road network speed, average traffic flow, and peak-to-off-peak congestion ratio.
[0036] Preferably, in step S4, the OBD dynamic characteristics include vehicle speed difference, rolling mean, kinetic energy, absolute current value, current square, current difference, RPM square and RPM difference;
[0037] Urban background characteristics include slope characteristics and congestion background characteristics, specifically including average slope, maximum slope and minimum slope, as well as congestion mean, congestion standard deviation, average road network speed, average traffic flow and peak-to-off-peak congestion ratio;
[0038] Multi-source interaction features include the product of air temperature and vehicle speed, the product of air temperature and current, the product of gradient and vehicle speed, the product of gradient and kinetic energy, and the product of congestion features and vehicle speed.
[0039] The travel energy consumption target is a proxy indicator for travel energy consumption;
[0040] V2G dispatchable power is calculated based on battery SOC, total battery capacity, and minimum reserved SOC.
[0041] Preferably, step S5 specifically includes the following processing steps:
[0042] S501: Supervised dimensionality reduction of the original feature matrix is performed using the neighborhood component analysis algorithm to reduce it to a preset dimension, thus obtaining the dimensionality-reduced feature matrix.
[0043] S502: Normalize the reduced-dimensional feature matrix;
[0044] S503: Extract battery SOC features from the vehicle OBD data corresponding to the original feature matrix and perform normalization processing;
[0045] S504: The normalized battery SOC features are concatenated separately to the end of the regression-normalized feature matrix to generate the input feature sequence.
[0046] Preferably, in step S6, the Transformer multi-task joint prediction model includes a cascaded input layer, a Transformer encoder, a shared layer, and a prediction head;
[0047] The input layer is used to receive the input feature sequence;
[0048] The Transformer encoder consists of multiple stacked Transformer encoder blocks, each containing a multi-head self-attention mechanism and a feedforward network to capture global dependencies in the feature sequence.
[0049] The shared layer consists of cascaded global average pooling layers and shared fully connected layers, used to learn shared representations for the two tasks;
[0050] The prediction head includes two separate task heads for predicting travel energy consumption and V2G schedulable power, respectively.
[0051] Compared with existing technologies, the joint prediction method for electric bus energy consumption and V2G dispatchable power in this invention has the following advantages:
[0052] This invention constructs a KDTree spatial index to achieve high-precision matching between onboard OBD data and road network slope features, and introduces full-network congestion background features. The statistical mean of the congestion index for each road segment represents the global traffic flow status, achieving spatial matching and deep fusion of micro-level vehicle status and macro-level urban environmental information. This breaks down the information silos of single onboard data and effectively solves the prediction bias problems caused by the lack of road physical attributes (such as slope) and dynamic traffic flow (such as congestion) information in existing technologies. By introducing slope features, the model can effectively reflect the impact of potential energy changes during vehicle ascent or descent on energy consumption and power recovery. By introducing congestion background features, the model can perceive the potential impact of global traffic flow on frequent vehicle starts and stops. Through this spatiotemporal fusion of multi-source heterogeneous data, the feature dimensions of the input data are greatly enriched, significantly improving the effectiveness and comprehensiveness of the training data. This lays a solid data foundation for subsequent models to accurately understand vehicle operation patterns under complex urban conditions, thereby effectively improving the robustness of electric bus energy consumption and V2G schedulable power prediction.
[0053] This invention significantly improves the quality and relevance of feature engineering by constructing an original feature matrix containing OBD dynamic features, urban background features, and multi-source interaction features, and combining NCA (Neighborhood Component Analysis) dimensionality reduction and SOC bypass normalization strategies. First, by constructing multi-source interaction features such as temperature and vehicle speed, and slope and kinetic energy, the nonlinear coupling relationships between variables under complex operating conditions can be explicitly expressed, enhancing the data's explanatory power for energy consumption changes. Second, supervised dimensionality reduction using the NCA algorithm can compress data dimensionality while maximizing the retention of feature components most correlated with the prediction targets (travel energy consumption and V2G power), effectively removing redundant noise and improving the effectiveness of training data. Finally, the SOC bypass normalization strategy processes battery SOC features separately and concatenates them to the end of the normalized feature matrix. This avoids interference from differences in SOC numerical ranges on the normalization process of other features and highlights the key position of SOC as a core parameter for calculating V2G schedulable power, ensuring that the feature sequence of the input model has higher discriminative power and representativeness, thereby significantly improving the accuracy of joint prediction.
[0054] This invention employs a multi-task learning model based on the Transformer architecture for joint prediction. It fully leverages the advantage of multi-head self-attention mechanisms in capturing global dependencies in long-sequence data, overcoming the gradient vanishing or information forgetting problems that traditional recurrent neural networks easily encounter when processing long-term data. In the electric bus operation scenario, energy consumption and V2G power are not only affected by the current state but also closely related to driving habits and road condition changes over a historical period. The Transformer structure can accurately capture this long-distance temporal dependency. Furthermore, by constructing a multi-task architecture including a shared layer and independent task heads, the model can learn the inherent correlation and common features between trip energy consumption and V2G schedulable power in the lower shared layer, achieving knowledge transfer and complementarity between tasks. Meanwhile, the prediction head layer can independently optimize for the characteristics of each task, improving the model's generalization ability and avoiding overfitting that may occur with single-task models. Thus, in complex and ever-changing real-world operating environments, it achieves high-precision synchronous prediction of electric bus trip energy consumption and V2G schedulable power. Attached Figure Description
[0055] To make the objectives, technical solutions, and advantages of the invention clearer, the invention will now be described in further detail with reference to the accompanying drawings, wherein:
[0056] Figure 1 This is a logic block diagram of a joint prediction method for the energy consumption of electric buses and the dispatchable power of V2G.
[0057] Figure 2 Comparison chart of predicted travel energy consumption results: Figure 2 (a), (b), (c), (d), and (e) are the travel energy consumption prediction results of MLR, RF, SVM, GPR, and the Transformer method of this invention, respectively.
[0058] Figure 3 This is a comparison chart of V2G dispatchable power prediction results.
[0059] Figure 4 A comprehensive comparison bar chart of MLR, RF, SVM, GPR, and the Transformer method of this invention: Figure 4 (a), (b), and (c) are bar charts comparing MLR, RF, SVM, GPR, and the Transformer method of this invention on the three indicators of RMSE, R², and MAE, respectively. Detailed Implementation
[0060] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but only to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.
[0061] The following detailed explanation illustrates the specific implementation methods:
[0062] Example:
[0063] This embodiment discloses a joint prediction method for the energy consumption of electric buses and the dispatchable power of V2G.
[0064] like Figure 1 As shown, a joint prediction method for the energy consumption of electric buses and the dispatchable power of V2G includes:
[0065] S1: Acquire multi-source data including electric bus OBD data, road network data, and road traffic flow data;
[0066] S2: Extract on-board OBD data aligned with the trip, a slope feature table containing the slope characteristics of each road segment, and full road network congestion data of the target area from electric bus OBD data, road network data, and road traffic flow data;
[0067] S3: For each vehicle OBD data, spatiotemporal matching is performed with the slope features in the slope feature table and the congestion background features in the road congestion data of the entire road network in the target area to obtain the corresponding spatiotemporal fused OBD data.
[0068] S4: For each spatiotemporal fused OBD data, extract the original feature matrix containing OBD dynamic features, urban background features, and multi-source interaction features, as well as the corresponding trip energy consumption target and V2G schedulable power target.
[0069] S5: After performing Neighborhood Components Analysis (NCA) to reduce the dimensionality of each original feature matrix, normalization is then performed. The corresponding battery SOC features are then normalized and separately concatenated to the end of the regression-normalized feature matrix to generate the corresponding input feature sequence.
[0070] S6: For each input feature sequence, use it together with the corresponding normalized travel energy consumption target and V2G schedulable power target as a set of training data; divide all training data into training set and test set according to the proportion;
[0071] S7: Construct a Transformer multi-task model with input feature sequences as input and predicted travel energy consumption and V2G schedulable power as output, and train the model using training data to obtain a trained Transformer multi-task joint prediction model.
[0072] S8: Construct an input feature sequence based on the multi-source data to be processed, and input it into the trained Transformer multi-task joint prediction model to output the corresponding trip energy consumption prediction value and V2G schedulable power prediction value.
[0073] To better illustrate the technical solution of the present invention, this embodiment will be described in more detail through the following parts.
[0074] I. Multi-source data acquisition and preprocessing
[0075] In the specific implementation process, the multi-source data acquisition and preprocessing steps include:
[0076] S201: Extract onboard OBD data from electric buses, including vehicle speed, battery SOC (state of charge), battery current, ambient temperature, engine speed, GPS coordinates, timestamp, and trip energy consumption proxy index (Electricity Consumption Rate).
[0077] In this embodiment, the surrogate metric for energy consumption refers to an observable variable or simplified model used to indirectly represent, reflect, or predict the actual energy consumption level of a vehicle. This invention selects the electricity consumption rate as the surrogate metric for energy consumption.
[0078] S202: Align the granularity of the vehicle OBD data with the trip as the basic unit to obtain vehicle OBD data associated with the trip or mark the trip to which each OBD record belongs with the Trip field.
[0079] S203: Filter and extract the segment IDs (unique identifiers) of all road segments within the target area from the (OpenStreetMap) road network data; use the Nominatim lookup API to batch query the representative coordinates (such as the start and end coordinates of the road segment, or the center point coordinates) corresponding to each segment ID.
[0080] S204: Using the representative coordinates of the road segment as input, the Open-Meteo Elevation API (elevation data interface) is called to obtain the elevation value of each coordinate point; based on the elevation difference and horizontal distance between adjacent coordinate points, the slope characteristics corresponding to the road segment are calculated.
[0081] In this embodiment, the slope characteristics of the road segment include average slope, maximum slope, and minimum slope.
[0082] S205: Execute S204 for each road segment to generate a slope feature table containing the slope characteristics of each road segment;
[0083] S206: Extract road traffic data from road traffic flow data, including timestamps (usually 15-minute granularity), road segment ID, road type, traffic flow (vehicles / 15 minutes), average vehicle speed (km / h), and congestion index;
[0084] S207: Using timestamps as the dimension, aggregate traffic data for all road segments within the target area to generate full road network congestion data for the target area.
[0085] II. Integration of Urban Background Features
[0086] In the specific implementation process, the steps for integrating urban background features include:
[0087] S301: Based on the representative coordinates of all road segments in the slope feature table (such as the coordinates of the center point of the road segment), construct a KDTree spatial index;
[0088] S302: Extract the GPS coordinates from the vehicle OBD data, find the nearest road segment in the slope feature table using the KDTree spatial index, and associate the slope feature of the corresponding road segment with the vehicle OBD data (add it as a new attribute to the corresponding vehicle OBD data) to obtain slope-matched vehicle OBD data; for a few vehicle OBD data that fail to match a valid road segment (such as being too far from all road segments), the global slope mean is used to fill in the gaps to ensure data integrity.
[0089] S303: At each moment, perform statistical feature calculations on the road congestion data of the entire road network in the target area, extract the congestion background features, and obtain the congestion background features at each moment.
[0090] In this embodiment, the congestion background characteristics include the congestion mean, congestion standard deviation, average road network speed, average traffic flow, and peak-to-off-peak congestion ratio.
[0091] S305: Extract the timestamp of the slope-matched vehicle OBD data, match the congestion background features at the same time (or the nearest time), and associate the congestion background features with the slope-matched vehicle OBD data to obtain spatiotemporal fusion OBD data containing slope features and congestion background features.
[0092] S306: For each piece of vehicle OBD data, execute steps S302 to S305 respectively to obtain the corresponding spatiotemporal fusion OBD data.
[0093] This invention constructs a KDTree spatial index to achieve high-precision matching between onboard OBD data and road network slope features, and introduces full-network congestion background features. The statistical mean of the congestion index for each road segment represents the global traffic flow status, achieving spatial matching and deep fusion of micro-level vehicle status and macro-level urban environmental information. This breaks down the information silos of single onboard data and effectively solves the prediction bias problems caused by the lack of road physical attributes (such as slope) and dynamic traffic flow (such as congestion) information in existing technologies. By introducing slope features, the model can effectively reflect the impact of potential energy changes during vehicle ascent or descent on energy consumption and power recovery. By introducing congestion background features, the model can perceive the potential impact of global traffic flow on frequent vehicle starts and stops. Through this spatiotemporal fusion of multi-source heterogeneous data, the feature dimensions of the input data are greatly enriched, significantly improving the effectiveness and comprehensiveness of the training data. This lays a solid data foundation for subsequent models to accurately understand vehicle operation patterns under complex urban conditions, thereby effectively improving the robustness of electric bus energy consumption and V2G schedulable power prediction.
[0094] III. Feature Engineering and Bi-objective Construction
[0095] In the specific implementation process, the following three types of features are constructed on the feature matrix after multi-source fusion:
[0096] OBD dynamic characteristics include vehicle speed difference, rolling mean, kinetic energy, absolute current value, current square, current difference, RPM square and RPM difference;
[0097] In this embodiment, the rolling mean is obtained by using a sliding mean filter with a window size of 5. The instantaneous vehicle speed at each moment is calculated as the arithmetic mean of the previous 5 consecutive moments (including the current moment), expressed by the formula v̄. t = mean(v t-4 , ..., v t Missing values are filled with preceding valid values. Kinetic energy is obtained by calculating a simplified kinetic energy term based on instantaneous vehicle speed, using the formula E. k= 0.5 × v², where v is the instantaneous vehicle speed (km / h). After normalizing the vehicle mass, the square of the velocity represents the trend of kinetic energy change in the vehicle's motion. The RPM square is obtained by squaring the motor speed. The RPM difference is obtained by taking the first-order difference of the motor speed at adjacent time points, with missing values filled with 0.
[0098] Urban background characteristics include slope characteristics and congestion background characteristics, specifically including average slope, maximum slope and minimum slope, as well as congestion mean, congestion standard deviation, average road network speed, average traffic flow and peak-to-off-peak congestion ratio;
[0099] Multi-source interaction features include the product of temperature and vehicle speed, the product of temperature and current, the product of gradient and vehicle speed, the product of gradient and kinetic energy, and the product of congestion features and vehicle speed; among them, congestion features are quantified through the congestion index field in the data. The processing flow is as follows: group and aggregate by road segment, extract the average congestion index of each road segment; then use the global mean of the congestion index of all road segments as the congestion background feature for this trip. bg (A continuous scalar with values in the range [0,10]). The final product of the congestion characteristic and the vehicle speed is: congestion bg ×Average vehicle speed, this scalar directly participates in model training.
[0100] In this embodiment, based on the original OBD dynamic features and urban background features, multi-source interaction terms such as temperature × vehicle speed, slope × kinetic energy, and congestion × vehicle speed are explicitly constructed, which enhances the ability of features to express nonlinear coupling relationships under complex working conditions.
[0101] The travel energy consumption target is the travel energy consumption proxy index (i.e., energy consumption rate), with IQR cut off from the 1% to 99th percentile.
[0102] V2G dispatchable power = battery SOC × total battery capacity (set to 180kWh in this embodiment, which can be modified according to the actual vehicle model) × (1 - minimum reserved SOC).
[0103] Strictly eliminate leakage characteristics: battery power (I×V), HV Battery Voltage, HV Battery SOC and its derivative SOC series diff , soc sq .
[0104] IV. NCA Dimensionality Reduction and SOC Bypass Normalization
[0105] In the specific implementation process, the processing steps for NCA dimensionality reduction and SOC bypass normalization include:
[0106] S501: Supervised dimensionality reduction of the original feature matrix is performed using the neighborhood component analysis algorithm, reducing it to a preset dimension (15 dimensions) to obtain the dimensionality-reduced feature matrix.
[0107] In this embodiment, the samples are binary classified using the median of the travel energy consumption as the label. Supervised dimensionality reduction is performed on the high-dimensional original feature matrix, compressing the feature dimension from the original tens of dimensions to ≤15 dimensions. This removes redundant noise while maximizing the retention of the feature components most relevant to the prediction target.
[0108] S502: Normalize the dimensionality-reduced feature matrix, travel energy consumption target, and V2G schedulable power target; the feature matrix and V2G schedulable power target are normalized using MinMaxScaler, and the travel energy consumption target is normalized using RobustScaler.
[0109] S503: Extract battery SOC features from the vehicle OBD data corresponding to the original feature matrix and perform normalization processing;
[0110] S504: The normalized battery SOC features are concatenated separately to the end of the regression-normalized feature matrix to generate the input feature sequence.
[0111] In this embodiment, the battery SOC feature is extracted from the regular feature matrix, and after being processed separately by MinMax normalization, it is appended to the end of the dimensionality-reduced feature matrix. This avoids the interference of SOC numerical range differences on the normalization of other features, while preserving the direct physical correlation between SOC and V2G schedulable power.
[0112] This invention significantly improves the quality and relevance of feature engineering by constructing an original feature matrix containing OBD dynamic features, urban background features, and multi-source interaction features, and combining NCA (Neighborhood Component Analysis) dimensionality reduction and SOC bypass normalization strategies. First, by constructing multi-source interaction features such as temperature and vehicle speed, and slope and kinetic energy, the nonlinear coupling relationships between variables under complex operating conditions can be explicitly expressed, enhancing the data's explanatory power for energy consumption changes. Second, supervised dimensionality reduction using the NCA algorithm can compress data dimensionality while maximizing the retention of feature components most correlated with the prediction targets (travel energy consumption and V2G power), effectively removing redundant noise and improving the effectiveness of training data. Finally, the SOC bypass normalization strategy processes battery SOC features separately and concatenates them to the end of the normalized feature matrix. This avoids interference from differences in SOC numerical ranges on the normalization process of other features and highlights the key position of SOC as a core parameter for calculating V2G schedulable power, ensuring that the feature sequence of the input model has higher discriminative power and representativeness, thereby significantly improving the accuracy of joint prediction.
[0113] V. Transformer Multi-Task Joint Prediction Model
[0114] In practice, the Transformer multi-task joint prediction model includes a cascaded input layer, a Transformer encoder, a shared layer, and a prediction head.
[0115] The input layer is used to receive the input feature sequence;
[0116] The Transformer encoder consists of multiple stacked Transformer encoder blocks, each containing a multi-head self-attention mechanism and a feedforward network to capture global dependencies in the feature sequence.
[0117] The shared layer consists of cascaded global average pooling layers and shared fully connected layers, used to learn shared representations for the two tasks;
[0118] The prediction head includes two separate task heads for predicting travel energy consumption and V2G schedulable power, respectively.
[0119] This invention employs a multi-task learning model based on the Transformer architecture for joint prediction. It fully leverages the advantage of multi-head self-attention mechanisms in capturing global dependencies in long-sequence data, overcoming the gradient vanishing or information forgetting problems that traditional recurrent neural networks easily encounter when processing long-term data. In the electric bus operation scenario, energy consumption and V2G power are not only affected by the current state but also closely related to driving habits and road condition changes over a historical period. The Transformer structure can accurately capture this long-distance temporal dependency. Furthermore, by constructing a multi-task architecture including a shared layer and independent task heads, the model can learn the inherent correlation and common features between trip energy consumption and V2G schedulable power in the lower shared layer, achieving knowledge transfer and complementarity between tasks. Meanwhile, the prediction head layer can independently optimize for the characteristics of each task, improving the model's generalization ability and avoiding overfitting that may occur with single-task models. Thus, in complex and ever-changing real-world operating environments, it achieves high-precision synchronous prediction of electric bus trip energy consumption and V2G schedulable power.
[0120] VI. Experimental Instructions
[0121] This experiment ran multiple linear regression (MLR) and random forest (RF, n) sequentially on the same dataset. estimators =20), Support Vector Machine (SVR), and Gaussian Process Regression (GPR) were used as baseline comparison methods to comprehensively compare the Transformer method of this invention on the three indicators of RMSE, R², and MAE.
[0122] Figure 2A comparison of prediction curves for MLR, RF, SVM, GPR, and the Transformer method of this invention on the task of travel energy consumption prediction is presented (horizontal axis represents sample number, vertical axis represents energy consumption value, red line represents actual value, green line represents predicted value). The sub-figures provide a clear visual observation:
[0123] like Figure 2 As shown in (a), the predicted curve (green) of the multiple linear regression (MLR) deviates significantly from the actual value (red) in several peak regions, especially at sample points where energy consumption fluctuates dramatically, reflecting the inadequacy of the linear model in modeling nonlinear coupling factors such as slope, temperature and vehicle speed.
[0124] like Figure 2 As shown in (b), Random Forest (RF) implicitly captures some nonlinear interactions through the Bagging ensemble of multiple decision trees. The overall trend of the predicted curve is close to the true value, but there is still some deviation in some peak areas.
[0125] like Figure 2 As shown in (c), the support vector machine (SVM) uses kernel tricks to handle nonlinear relationships and the prediction curve is relatively smooth, but the response sensitivity is insufficient in some regions of abrupt energy consumption changes.
[0126] like Figure 2 As shown in (d), Gaussian process regression (GPR) is limited by the sampling size of the training samples and the choice of kernel function. The prediction curve deviates significantly, and some prediction values even exceed the reasonable energy consumption range, indicating that GPR has poor applicability in large sample high-dimensional feature scenarios.
[0127] like Figure 2 As shown in (e), the prediction curve (green) of the Transformer method of this invention has the highest degree of fit with the true value (red), maintaining good tracking ability in energy consumption peaks, valleys, and transition regions. This verifies the effectiveness of the multi-head self-attention mechanism in globally modeling the dependency of a high-dimensional feature matrix containing OBD dynamic features, urban background features, and multi-source interaction features. It should be noted that Transformer here serves as a multi-task model to simultaneously optimize two objectives: travel energy consumption and V2G schedulable power. Its single-task accuracy for travel energy consumption is slightly lower than that of RF, which is specifically optimized for this task. However, its core value lies in completing two prediction tasks simultaneously through a single model—something that no single-task baseline method can achieve.
[0128] Figure 3 The prediction curves of the Transformer method of this invention on the V2G schedulable power prediction task are given (horizontal axis is sample number, vertical axis is V2G schedulable power, unit is kWh, blue line is the actual value, orange line is the predicted value). From Figure 3 It can be seen from this:
[0129] The Transformer model's prediction curve (orange) maintains high tracking accuracy for the overall fluctuation trend of the actual V2G schedulable energy (blue), with small deviations between predicted and actual values at most sample points. Since V2G schedulable energy is physically determined directly by the difference between the end-of-trip SOC and the minimum retained SOC, its value variation range is mainly concentrated between 20 kWh and 140 kWh, with a relatively singular source of variance. Therefore, the model's prediction difficulty is lower than that of the trip energy consumption task. This figure only shows the prediction results of the Transformer method because baseline methods such as MLR, RF, SVM, and GPR are all single-task models and cannot output predicted V2G schedulable energy values. In contrast, the Transformer multi-task model of this invention learns the intrinsic relationship between trip energy consumption and V2G energy by sharing a coding layer, optimizing two objectives separately in the head layer of independent tasks, thereby simultaneously completing two prediction tasks within a unified framework. Figure 3 The results validated the effectiveness of the multi-task architecture in V2G schedulable power prediction.
[0130] Figure 4 A comprehensive comparison of MLR, RF, SVM, GPR, and the Transformer method of this invention on RMSE, R², and MAE is presented (gold bars represent the method of this invention). The specific metrics for each method are as follows:
[0131] The MLR's RMSE was 0.6542, R² was 0.9237, and MAE was 0.1799;
[0132] The RMSE of RF is 0.6330, R² is 0.9305, and MAE is 0.1218.
[0133] The SVM has an RMSE of 1.0280, an R² of 0.8167, and a MAE of 0.2847.
[0134] The GPR's RMSE was 11.5670, R² was -22.2113, and MAE was 1.9566;
[0135] The RMSE of the Transformer in this invention is 0.9775, R² is 0.8342, and MAE is 0.2426.
[0136] from Figure 4It can be observed that: RF achieved the best performance in all three metrics, with its low RMSE (0.6330) and high R² (0.9305) reflecting the strong fitting ability of the Bagging ensemble strategy in single-task regression problems; MLR, as a linear baseline, was at a moderate level in all three metrics; SVM, affected by the kernel function and feature scale, had slightly lower accuracy than MLR; GPR suffered from severe prediction failure (negative R²) due to limited sampling scale and kernel matrix calculation problems under high-dimensional features. The Transformer method of this invention has an RMSE of 0.9775, an R² of 0.8342, and a MAE of 0.2426. While its accuracy in single-task travel energy consumption prediction is lower than RF and MLR, it is significantly better than SVM and GPR. It should be noted that these metrics were obtained under a multi-task joint optimization framework—the Transformer shared coding layer simultaneously undertakes feature learning for both travel energy consumption prediction (Y1) and V2G schedulable power prediction (Y2), with two independent task heads optimizing their respective objectives. In this multi-task setting, the model needs to make trade-offs between gradient updates for Y1 and Y2. Therefore, the single-task accuracy of Y1 will be slightly lower than that of RF, which is specifically optimized for this task. However, the core advantage of Transformer is not that its single-task accuracy for Y1 surpasses all single-task models, but that it can simultaneously perform joint prediction of energy consumption and V2G power consumption through a unified model. This is something that single-task baseline methods such as RF, MLR, SVM, and GPR cannot achieve at all.
[0137] Experimental results show that the Transformer multi-task model of this invention can effectively predict V2G schedulable power while maintaining reasonable energy consumption prediction accuracy, thus verifying the feasibility and effectiveness of the proposed joint prediction method in practical applications.
[0138] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit the technical solutions. Those skilled in the art should understand that any modifications or equivalent substitutions to the technical solutions of the present invention without departing from the spirit and scope of the present invention should be covered within the scope of the claims of the present invention.
Claims
1. A method for jointly predicting the energy consumption of electric buses and the dispatchable power of V2G, characterized in that, include: S1: Acquire multi-source data including electric bus OBD data, road network data, and road traffic flow data; S2: Extract on-board OBD data aligned with the trip, a slope feature table containing the slope characteristics of each road segment, and full road network congestion data of the target area from electric bus OBD data, road network data, and road traffic flow data; S3: For each vehicle OBD data, spatiotemporal matching is performed with the slope features in the slope feature table and the congestion background features in the road congestion data of the entire road network in the target area to obtain the corresponding spatiotemporal fused OBD data. S4: For each spatiotemporal fused OBD data, extract the original feature matrix containing OBD dynamic features, urban background features, and multi-source interaction features, as well as the corresponding trip energy consumption target and V2G schedulable power target. S5: After performing NCA dimensionality reduction on each original feature matrix, normalization is then performed, and the corresponding battery SOC features are normalized and then concatenated separately to the end of the regression-normalized feature matrix to generate the corresponding input feature sequence. S6: For each input feature sequence, use it as a set of training data along with the corresponding normalized travel energy consumption target and V2G schedulable power target; S7: Construct a Transformer multi-task model with input feature sequences as input and predicted travel energy consumption and V2G schedulable power as output, and train the model using training data to obtain a trained Transformer multi-task joint prediction model. S8: Construct an input feature sequence based on the multi-source data to be processed, and input it into the trained Transformer multi-task joint prediction model to output the corresponding trip energy consumption prediction value and V2G schedulable power prediction value.
2. The joint prediction method for electric bus energy consumption and V2G dispatchable power as described in claim 1, characterized in that: Step S2, the processing steps for extracting vehicle OBD data include: S201: Extract onboard OBD data from electric bus OBD data, including vehicle speed, battery SOC, battery current, ambient temperature, engine speed, GPS coordinates, timestamp, and trip energy consumption proxy indicators; S202: Identify the vehicle OBD data by trip as the organizational unit to obtain vehicle OBD data associated with the trip.
3. The joint prediction method for electric bus energy consumption and V2G dispatchable power as described in claim 2, characterized in that: Step S2, the processing steps for extracting the slope feature table include: S203: Filter and extract the segment IDs of all road segments within the target area from the road network data; query the representative coordinates corresponding to each segment ID in batches via API; S204: Take the representative coordinates of the road segment as input to obtain the elevation value of each coordinate point; calculate the slope characteristics of the road segment based on the elevation difference and horizontal distance between adjacent coordinate points. S205: Execute S204 for each road segment to generate a slope feature table containing the slope characteristics of each road segment.
4. The joint prediction method for electric bus energy consumption and V2G dispatchable power as described in claim 3, characterized in that: In step S204, the slope characteristics of the road segment include average slope, maximum slope, and minimum slope.
5. The joint prediction method for electric bus energy consumption and V2G dispatchable power as described in claim 3, characterized in that: Step S2, the processing steps for extracting road congestion data for the entire road network in the target area include: S206: Extract road segment traffic data from road traffic flow data, including timestamps, road segment IDs, road types, average vehicle speeds, and congestion indices. S207: Using road segment ID as the dimension, aggregate traffic data for all road segments within the target area to generate comprehensive road network congestion statistics for the target area.
6. The joint prediction method for electric bus energy consumption and V2G dispatchable power as described in claim 5, characterized in that: Step S3 specifically includes the following processing steps: S301: Construct a KDTree spatial index based on the representative coordinates of all road segments in the slope feature table; S302: Extract the GPS coordinates from the vehicle OBD data, find the road segment with the closest spatial distance in the slope feature table through the KDTree spatial index, and associate the slope features of the corresponding road segment with the vehicle OBD data to obtain slope-matched vehicle OBD data; S303: At each moment, perform statistical feature calculations on the road congestion data of the entire road network in the target area, extract the congestion background features, and obtain the congestion background features at each moment. S305: Extract the timestamp of the slope-matched vehicle OBD data, match the congestion background features at the same time, and associate the congestion background features with the slope-matched vehicle OBD data to obtain spatiotemporal fusion OBD data containing slope features and congestion background features. S306: For each piece of vehicle OBD data, execute steps S302 to S305 respectively to obtain the corresponding spatiotemporal fusion OBD data.
7. The method for jointly predicting the energy consumption of electric buses and the dispatchable power of V2G as described in claim 6, characterized in that: In step S303, the congestion background characteristics include the congestion mean, congestion standard deviation, average road network speed, average traffic flow, and peak-to-off-peak congestion ratio.
8. The method for jointly predicting the energy consumption of electric buses and the dispatchable power of V2G as described in claim 1, characterized in that: In step S4, the OBD dynamic characteristics include vehicle speed difference, rolling mean, kinetic energy, absolute current value, current square, current difference, RPM square and RPM difference; Urban background characteristics include slope characteristics and congestion background characteristics, specifically including average slope, maximum slope and minimum slope, as well as congestion mean, congestion standard deviation, average road network speed, average traffic flow and peak-to-off-peak congestion ratio; Multi-source interaction features include the product of air temperature and vehicle speed, the product of air temperature and current, the product of gradient and vehicle speed, the product of gradient and kinetic energy, and the product of congestion features and vehicle speed. The travel energy consumption target is a proxy indicator for travel energy consumption; V2G dispatchable power is calculated based on battery SOC, total battery capacity, and minimum reserved SOC.
9. The method for jointly predicting the energy consumption of electric buses and the dispatchable power of V2G as described in claim 8, characterized in that: Step S5 specifically includes the following processing steps: S501: Supervised dimensionality reduction of the original feature matrix is performed using the neighborhood component analysis algorithm to reduce it to a preset dimension, thus obtaining the dimensionality-reduced feature matrix. S502: Normalize the reduced-dimensional feature matrix; S503: Extract battery SOC features from the vehicle OBD data corresponding to the original feature matrix and perform normalization processing; S504: The normalized battery SOC features are concatenated separately to the end of the regression-normalized feature matrix to generate the input feature sequence.
10. The method for jointly predicting the energy consumption of electric buses and the dispatchable power of V2G as described in claim 1, characterized in that: In step S6, the Transformer multi-task joint prediction model includes a cascaded input layer, a Transformer encoder, a shared layer, and a prediction head; The input layer is used to receive the input feature sequence; The Transformer encoder consists of multiple stacked Transformer encoder blocks, each containing a multi-head self-attention mechanism and a feedforward network to capture global dependencies in the feature sequence. The shared layer consists of cascaded global average pooling layers and shared fully connected layers, used to learn shared representations for the two tasks; The prediction head includes two separate task heads for predicting travel energy consumption and V2G schedulable power, respectively.
