A method and device for predicting charging demand of electric vehicle
Through the improved deep neural network model of probability sparse self-attention and comparative learning, the problem of the accuracy and high deployment cost of the existing charging demand prediction system is solved, and efficient and accurate charging demand prediction on the edge computing platform is achieved , improving the operational efficiency and user experience of charging facilities.
Patent Information
- Application Number
- CN202111648643.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-30
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2041-12-30
AI Technical Summary
Due to the lack of accurate prediction capabilities, the existing charging demand forecasting system has low utilization rate of charging facilities, difficulty finding piles during peak hours, idle facilities during low peak hours, and high deployment costs, so it cannot be flexibly deployed in edge computing platforms and remote areas.
Using a deep neural network model based on improved probability sparse self-attention and contrast learning, combined with an edge computing platform, electric vehicle charging demand prediction is carried out, and through self-supervised comparison learning and data enhancement methods, the prediction accuracy and tolerance for noise are improved. Reduce computing volume and adapt to mobile and edge device deployment.
It realizes more accurate charging demand forecasting, reduces prediction errors, improves model compatibility and deployment flexibility, is suitable for edge computing platforms and remote areas, and improves the operational efficiency and user experience of charging facilities.
Smart Images

Figure CN114331542B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of electric vehicles, and in particular to a method and device for predicting charging demand of electric vehicles. Background Art
[0002] In recent years, the electric vehicle industry has developed rapidly, and the large-scale demand for electric vehicle charging has led to a high electricity load. Accurate charging demand forecasting is an important basis for achieving refined operation management of charging stations, overall optimization and scheduling, and upgrading of operation strategies.
[0003] Different from the traditional power load characteristics, the charging behavior of electric vehicles at charging stations is not only a continuous process in time; due to the mobility of electric vehicles, their charging behavior is closely related to the travel behavior of users. The transfer of electric vehicles between different charging stations will cause the charging demand of different stations to have spatial correlation. Therefore, the charging demand of electric vehicles is highly random in terms of time and space distribution. In addition, the charging demand of electric vehicles is also affected by many factors such as charging station operation strategy, holiday arrangements, weather conditions, national policy subsidies, etc. Therefore, predicting the fluctuations of electric vehicle charging demand in time dimension, space dimension and other additional dimensions is a complex dynamic system problem.
[0004] On the other hand, due to the lack of accurate charging demand prediction capabilities, the existing charging capacity management system has certain automatic monitoring and processing means, but the comprehensive dispatching capabilities are limited. It is only adjusted manually in combination with actual charging use, which is inefficient and has prominent contradictions in the vehicle charging process. Users often face difficulties in finding charging piles during peak hours, and vehicles need to queue up for charging and wait for a long time. During off-peak hours, charging facilities will be idle and the utilization rate will be low. Sometimes, even if the charging facilities are fully charged, due to the factors of the power demand curve of the charging process, the charging guns and parking spaces are limited, and the charging facilities will have sufficient capacity during peak hours, but the vehicles are forced to wait, that is, electric vehicles are still charging in the equalization stage. Summary of the invention
[0005] The embodiments of the present application provide a method and a method device for predicting charging demand of electric vehicles, which adopts a deep neural network charging demand prediction model based on improved probabilistic sparse self-attention and contrastive learning, can meet the deployment requirements of edge computing platforms, low-computing power grassroots equipment, off-grid privatization and other scenarios, and has high prediction accuracy and a certain tolerance margin for data noise.
[0006] The present application embodiment adopts the following technical solutions:
[0007] In a first aspect, an embodiment of the present application provides an electric vehicle charging demand prediction method, which is applied to an electric vehicle charging demand prediction server, and the method includes:
[0008] Build a test dataset;
[0009] Training the load forecasting model using the test data set;
[0010] The test data set is input into the trained load forecasting model to obtain a forecasting result.
[0011] Optionally, the data in the test data set is segmented according to the desired prediction time period, including the following dimensions: historical traffic data, historical charging demand data, regional time-of-day electricity price data, holiday data, temperature data, energy storage operation status data, longitude and latitude of the charging station, season, weather, and whether there is an operating subsidy.
[0012] Optionally, the load prediction model includes an embedding layer, a coding layer and a decoding layer; wherein,
[0013] The embedding layer includes a convolution module, a position encoder and a time encoder, which are used to perform linear transformation and time series information splicing on the input test data set to generate time series position encoding data;
[0014] The encoding layer includes two branches, wherein the first branch includes a first probabilistic sparse self-attention network module for long-term attention construction and allocation; the second branch includes a gated linear activation unit, a convolution module and a fully connected module for extracting local correlation information within a specified time period of the input data; the encoding layer is used to parallel process the data output by the embedding layer to obtain the query, key, value query sequence matrix and the self-attention output Z1", Z2"; and the processing results are spliced and sent to the fully connected layer for output;
[0015] The decoding layer includes a mask sparse self-attention network module and a second self-attention network module, which are used to obtain a joint attention sequence according to the output of the embedding layer and the encoding layer, and obtain a prediction result according to the joint attention sequence; wherein the second self-attention network module has the same structure as the first self-attention network module of the encoding layer.
[0016] Optionally, the embedding layer is further used for:
[0017] Performing data enhancement on the data generated after the linear transformation and the time series information are concatenated;
[0018] Sending the data generated by concatenating the linear transformation and the time series information and the data generated by data enhancement as the output data of the embedding layer to the encoding layer;
[0019] The data enhancement adopts one of the following methods:
[0020] Method 1:
[0021] In a time period, data is split according to dimensions;
[0022] For one or more dimension data after splitting, part or all of its content is replaced with a random value within its numerical limit range;
[0023] Combine the replaced dimension data into the original data format;
[0024] Method 2:
[0025] Within a time period, one or more slices are identified in the data;
[0026] Randomly extract one or more slices of the same length in other time periods;
[0027] Overlay the one or more slices determined in the present data with one or more slices of the same length within the other time period.
[0028] Optionally, the training of the load forecasting model by using the test data set includes:
[0029] Performing self-supervised contrastive learning training on the outputs of the embedding layer and the encoding layer through the Adam optimizer;
[0030] The output of the load forecasting model is trained through the Adam optimizer.
[0031] Optionally, the performing self-supervised contrastive learning training on the outputs of the embedding layer and the encoding layer by using an Adam optimizer includes:
[0032] Calculate the total loss L total ,
[0033] The total loss L total Sending to the convolution module of the embedding layer, updating the parameters of the convolution module;
[0034] Among them, the total loss L total Obtained by the following formula:
[0035]
[0036]
[0037] L total =L1+L2,
[0038] Among them, Z1 and Z2 are respectively the data generated by concatenating the linear transformation and timing information output by the embedding layer and the data generated after data enhancement, the P1 and P2 are the data output by the first branch and the second branch during the coding layer processing and have not yet entered the full-link module, and the ||…||2 represents the binary norm.
[0039] Optionally, the temporal position encoding data output by the embedding layer includes a Query, Key, and Value sequence, and the method for the first self-attention network module to generate a sparse probabilistic self-attention output includes:
[0040] For each time series moment, randomly sample the Key part corresponding to other time series moments, and the number of samples is M;
[0041] The following formula is used to calculate the sparsity scores corresponding to the M sampling keys of each Query:
[0042]
[0043] Among them, qi is the query of the i-th time moment, j is the time moments other than the i-th time moment, and k is the key part corresponding to all other time moments except the i-th time moment. T is the transposed form of k, d is the number of self-attention channels, and L is the sequence length;
[0044] Select the queries of the N time series moments with the highest sparsity scores, and use the following formula to calculate the dot product of the queries of the N time series moments and the keys corresponding to all time moments:
[0045]
[0046] Among them, softmax is the cross entropy function, Q, K, and V correspond to the query, key, and value sequence matrices obtained by transformation respectively;
[0047] The following formula is used to calculate the self-attention results of the Query at the N time sequence moments:
[0048]
[0049] Calculate the mean of the self-attention of the Query at the remaining LN time series moments as the self-attention result of the Query at the remaining LN time series moments;
[0050] The self-attention results of the Query at the N time sequence moments and the self-attention results of the Query at the remaining LN time sequence moments are combined as a sparse probabilistic self-attention output.
[0051] Optionally, the method for the decoding layer to obtain the prediction result includes:
[0052] Determine the data encoding of the specified time window length before the prediction time point and the data encoding of the specified time window length after the prediction time point, recorded as L';
[0053] Obtain the self-attention sequence Z through the second attention network module dec-mask , the self-attention sequence Z dec-mask The convolution transformation sequence Z output by the embedding layer convolution transformation module dec-glu To splice;
[0054] The concatenated sequence and the processing results V” and K” output by the encoding layer are subjected to sparse self-attention calculation by the mask attention network module to obtain joint attention;
[0055] The load forecasting model is iteratively trained using the following loss function and Adam optimizer:
[0056] Loss = ∑L1 s (Gt, Zt),
[0057] Wherein, Gt is the training data ground truth sequence, and Zt is the prediction sequence; the iterative training adopts a step-by-step mode, that is, after predicting a time sequence moment value, it is added to the encoding layer input to fill in the original unknown corresponding time moment data, and predict the next time moment result;
[0058] Get the predicted sequence Zt.
[0059] In a second aspect, an embodiment of the present application further provides an electric vehicle charging demand prediction device, which is applied to an electric vehicle charging demand prediction server, and the device is used to implement any of the aforementioned methods.
[0060] In a third aspect, an embodiment of the present application further provides an electronic device, including:
[0061] Processor; and
[0062] A memory arranged to store computer executable instructions which, when executed, cause the processor to perform any of the methods described above.
[0063] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects: First, contrastive learning and data enhancement methods are adopted to allow the prediction network to obtain a feature extractor that can be iteratively optimized by itself to obtain better feature expression. Due to the uncontrollable quality of data acquisition, certain measures need to be taken to make the prediction results relatively insensitive to the noise or interpolation errors in various dimensions of the charging demand input data, so as to obtain better compatibility. Second, the global self-attention and local attention separation method is adopted to improve the probabilistic sparse self-attention module to replace the traditional self-attention neural network module. Different from the multi-head attention calculation process in the existing attention module or sparse attention module, the attention module and convolution module adopted in this application are responsible for global attention generation and local attention generation, respectively, and the corresponding decoder's self-attention module is also changed accordingly, thereby greatly reducing the amount of calculation and improving the model operation efficiency. The deep neural network electric vehicle charging demand prediction method based on improved probabilistic sparse self-attention and contrastive learning adopted in the embodiment of the present application can overcome the problems of large long-term demand prediction errors and the need for additional information correction. It can meet the deployment requirements of mobile terminal use, edge device operation, local area networks in remote areas, and scenarios with limited network security. In particular, it can be deployed in charging site energy storage systems or even charging piles for independent operation, providing more accurate prediction results and more flexible deployment methods, allowing existing charging sites to have room for intelligent upgrades. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0065] Figure 1 This is a schematic diagram of the overall process of a method for predicting charging demand of an electric vehicle in an embodiment of the present application;
[0066] Figure 2 This is a schematic diagram of an electric vehicle charging demand prediction network structure in an embodiment of the present application;
[0067] Figure 3 This is a schematic diagram of the overall structure of an electric vehicle charging demand prediction device in an embodiment of the present application;
[0068] Figure 4 This is a schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0069] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0070] In order to facilitate the understanding of the present application, the prior art is briefly introduced below.
[0071] The existing main research methods for electric vehicle charging demand can be divided into three categories: traditional prediction methods based on probability models, intelligent prediction methods based on machine learning, and neural network prediction methods based on deep learning. In order to improve the accuracy of charging demand prediction, all relevant dimensional data must be considered as much as possible, and data representation must be constructed through perfect feature engineering.
[0072] The method based on probability model mainly establishes a probability model for the charging behavior of electric vehicles at a certain charging pile, and then generates a set of random data through Monte Carlo simulation to simulate the charging behavior of electric vehicles for prediction. Considering the randomness of charging behavior in time and space, it is very difficult to establish an accurate probability model, and the above method can only make simple estimates. At the same time, due to the lack of real charging data, most studies on the simulation of electric vehicle charging behavior may be far from the actual situation.
[0073] Intelligent prediction methods based on machine learning mainly use machine learning algorithms and models to model from a data-driven perspective, and make predictions by analyzing and training historical data to obtain prediction models. However, most studies use shallow models such as ANN, SVM, and KNN to make one-dimensional time series predictions, and the model learning ability and expression ability of complex systems are limited. These methods only model from the perspective of time characteristics, without considering the spatiotemporal correlation of electric vehicle charging demand, and the prediction accuracy needs to be improved.
[0074] The load forecasting model based on the combination of deep learning and traditional methods can be used to solve the problem of spatiotemporal feature sequence prediction, but it also has the following disadvantages: First, in the existing technology, recurrent neural network frameworks such as BiLSTM and GRU are more used in the coarse-grained prediction of the total demand for a short period of time or a month in the next few hours or a day, and lack the verification of the application results of long-term fragment cycles. Due to the randomness and nonlinearity of charging behavior, it involves multiple subjective and objective dimensions, and the above data usually has problems such as noise and uneven collection quality, which increases the complexity of charging demand prediction and reduces the accuracy of the prediction results. Second, with the development of model structure and parameter quantity, higher requirements are also placed on the computing power and storage capacity of the model deployment system, and the deployment cost of the model becomes increasingly negligible. Third, due to the remote location of some charging stations, for safety reasons, their device layer network and big data cloud platform network can only communicate in one direction or run separately as a local area network, requiring the model and the corresponding strategy optimization service to be deployed in more basic devices. Therefore, the load forecasting model needs to have compatibility with the basic edge computing platform and the ability to learn and iterate by itself.
[0075] In fact, due to the uncertainty of charging demand, it is very challenging to make accurate demand power forecasts. In the context of the trend of refined management of charging station operations, even with a small prediction error, the power peaks generated by charging piles and energy storage operations and the linked charging and discharging parameters will be greatly adjusted. Because the peak reduction of energy storage scheduling at charging stations is based on the results of charging demand forecasts, even a small prediction error may reduce the effectiveness of the scheduling strategy and reduce the power station's revenue. The shortcomings of existing methods are mainly reflected in: 1. Although the use of traditional machine learning methods or LSTM and other paths has achieved good results in short-term predictions, it performs poorly in long-term fine-grained predictions in units of days, months, and seasons, and requires additional data or constraints to correct the prediction results. 2. The Transformer framework using a partially improved deep self-attention network can meet the accuracy requirements of practical applications to a certain extent, but it also faces the problems of large computational complexity, slow running speed, high deployment cost, and inability to be flexibly deployed on mobile or edge computing platforms. 3. Some of the dimensional data that the model prediction relies on have problems such as data noise, missing fragments, recording and interpolation errors, and the model lacks effective filtering means and tolerance.
[0076] At present, a large number of relevant studies have been carried out in the field of time series prediction combining multiple dimensions, among which the classic prediction methods include: time series method, regression analysis method, etc. The implementation principle of these methods is simple, the operation speed is fast, and they are suitable for processing data sets with simple structure and small scale. However, with the continuous improvement of charging station infrastructure and the improvement of equipment informatization, the continuous expansion of user scale, the rapid growth of data, and the nonlinear characteristics of most data themselves, the performance of existing methods on large-scale data is not ideal. Machine learning methods have attracted attention because of their strong adaptability and nonlinear processing capabilities. Among them, deep neural networks can theoretically approximate any function and have achieved very good results in image recognition, natural language processing and other fields. The self-attention mechanism can calculate the attention of each data in the sequence data to other data and assign different weights to them, so that the sequence data processed by it becomes sequence data containing weight information, and has a strong ability to process sequence data.
[0077] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0078] This embodiment provides an electric vehicle charging demand prediction method, which is applied to an electric vehicle charging demand prediction server, such as Figure 1 As shown, the method includes steps S110 to S130:
[0079] Step S110: construct a test data set;
[0080] The test data set is constructed based on historical data, mainly including historical vehicle flow data, historical charging demand data, etc., which are used to train the load prediction model.
[0081] Step S120: training the load forecasting model using the test data set;
[0082] The load forecasting model is constructed based on a deep neural network of improved probabilistic sparse self-attention and contrastive learning. The load forecasting model is trained through a test data set to determine various parameters in the model, so that the model has forecasting capabilities.
[0083] Step S130: input the test data set into the trained load forecasting model to obtain a forecasting result.
[0084] Among them, the trained load forecasting model can achieve a more accurate prediction of the charging demand in the future period.
[0085] The deep neural network electric vehicle charging demand prediction method based on improved probabilistic sparse self-attention and contrastive learning proposed in this embodiment can overcome the problem of large long-term demand prediction errors and the need for additional information correction. And the use of contrastive learning makes the model have a certain tolerance for poor data quality. And it reduces the computational complexity of the existing method framework, making the deployable scenarios more flexible and diverse, such as mobile terminal use, edge device operation, and deployment requirements for remote area local area networks and network security restrictions.
[0086] In one embodiment of the present application, the data in the test data set is segmented according to the desired prediction time period, including the following dimensions: historical vehicle flow data, historical charging demand data, regional time-of-day electricity price data, holiday data, temperature data, energy storage operation status data, longitude and latitude of the charging station, season, weather, and whether there is an operating subsidy.
[0087] The expected prediction time period refers to the minimum time length set according to the time period required by the user's prediction, such as one minute, one hour or one day. The historical vehicle flow data and historical charging demand data can be the total number of vehicles that come to charge in each prediction time period, the charging power and power of each vehicle and other charging parameters based on historical data statistics; the energy storage operation status data refers to the operation status data of the storage and charging station or storage and charging system used in conjunction with the charging power station.
[0088] In a specific scenario, if the data in the test data set has problems such as out-of-limit values or missing values caused by communication failures, the out-of-limit values in the above-mentioned dimensional data are set to blank, and then the missing values in the data are interpolated according to the forward filling principle to construct the test data set.
[0089] In one embodiment of the present application, the load prediction model includes an embedding layer, an encoding layer, and a decoding layer; wherein,
[0090] The embedding layer includes a convolutional module (CNN), a position encoder and a time encoder, which are used to perform linear transformation and time series information splicing on the input test data set to generate time series position encoding data;
[0091] The encoding layer includes two branches, wherein the first branch includes a first probabilistic sparse self-attention network module for long-term attention construction and allocation; the second branch includes a gated linear activation unit, a convolution module and a fully connected module for extracting local correlation information within a specified time period of the input data; the encoding layer is used to parallel process the data output by the embedding layer to obtain the query, key, value query sequence matrix and the self-attention output Z1", Z2"; and the processing results are spliced and sent to the fully connected layer for output;
[0092] The full connection layer and each stacking layer are bundled, and the existing self-attention output is spliced and then fully connected. At the same time, the encoding layer and decoding layer are also equipped with a fully connected layer and perform the same processing. By setting two branches with contrast learning functions, the prediction network can obtain a feature extractor that can be iteratively optimized by itself to obtain better feature expression.
[0093] The decoding layer includes a mask sparse self-attention network module and a second self-attention network module, which are used to obtain a joint attention sequence according to the output of the embedding layer and the encoding layer, and obtain a prediction result according to the joint attention sequence; wherein the second self-attention network module has the same structure as the first self-attention network module of the encoding layer.
[0094] In one embodiment of the present application, the embedding layer is further used to: perform data enhancement on the data generated after the linear transformation and the time series information are spliced; the data generated after the linear transformation and the time series information are spliced and the data generated after the data enhancement are sent to the encoding layer as the data output by the embedding layer; wherein the data enhancement adopts one of the following methods:
[0095] Method 1: Split the data by dimension within a time period; replace part or all of the content of one or more dimension data after the split with a random value within the value limit range; combine the replaced dimension data into the original data format; for example, randomly extract 10% of the slice data of a certain dimension data, replace it with a random value within the respective value limit range (such as the temperature data range: 0 to 50 degrees Celsius, then replace it with a random value within the range of 0 to 50), and pair it with the original data;
[0096] Method 2: within a time period, determine one or more slices in the data; randomly intercept one or more slices of the same length in other time periods; and overwrite the one or more slices determined in the data with the one or more slices of the same length in the other time periods.
[0097] In this embodiment, each batch of transformed data entering the coding layer includes two parts, one enhanced data and one unenhanced data. By performing data enhancement, the prediction result can be made relatively insensitive to noise or interpolation errors in various dimensions of the charging demand input data, thereby improving the training effect and prediction accuracy of the model.
[0098] In one embodiment of the present application, the training of the load forecasting model using the test data set includes: performing self-supervised comparative learning training on the outputs of the embedding layer and the encoding layer through the Adam optimizer; and training the output of the load forecasting model through the Adam optimizer.
[0099] Of course, other existing training methods can also be used to obtain the best training effect by setting a reasonable loss function.
[0100] In one embodiment of the present application, the self-supervised contrastive learning training of the outputs of the embedding layer and the encoding layer is performed by the Adam optimizer, including: calculating the total loss L total ; The total loss L total Sending to the convolution module of the embedding layer, updating the parameters of the convolution module;
[0101] Among them, the total loss L total Obtained by the following formula:
[0102]
[0103]
[0104] L total =L1+L2,
[0105] Among them, Z1 and Z2 are respectively the data generated by concatenating the linear transformation and timing information output by the embedding layer and the data generated after data enhancement, the P1 and P2 are the data output by the first branch and the second branch during the coding layer processing and have not yet entered the full-link module, and the ||…||2 represents the binary norm.
[0106] In this embodiment, the above L total The total loss is fed back to the convolution module to update the corresponding parameters, so that the convolution module can have self-supervised noise adaptation ability.
[0107] In one embodiment of the present application, the temporal position encoding data output by the embedding layer includes a Query, Key, and Value sequence, and the method for the first self-attention network module to generate a sparse probabilistic self-attention output includes:
[0108] For each time series moment, randomly sample the Key part corresponding to other time series moments, and the number of samples is M;
[0109] The following formula is used to calculate the sparsity scores corresponding to the M sampling keys of each Query:
[0110]
[0111] Where qi is the query of the i-th time moment, j is the time moments other than the i-th time moment, k is the key part corresponding to all other time moments except the i-th time moment, kT is the transposed form of k, d is the number of self-attention channels (for example, 8), and L is the sequence length;
[0112] Select the queries of the N time series moments with the highest sparsity scores, and use the following formula to calculate the dot product of the queries of the N time series moments and the keys corresponding to all time moments:
[0113]
[0114] Among them, softmax is the cross entropy function, Q, K, and V correspond to the query, key, and value sequence matrices obtained by transformation respectively;
[0115] The following formula is used to calculate the self-attention results of the Query at the N time sequence moments:
[0116]
[0117] Calculate the mean of the self-attention of the Query at the remaining LN time series moments as the self-attention result of the Query at the remaining LN time series moments;
[0118] The self-attention results of the Query at the N time sequence moments and the self-attention results of the Query at the remaining LN time sequence moments are combined as a sparse probabilistic self-attention output.
[0119] In this embodiment, the value of N may be M.
[0120] In one embodiment of the present application, the method for the decoding layer to obtain a prediction result includes:
[0121] Determine the data encoding of the specified time window length before the prediction time point and the data encoding of the specified time window length after the prediction time point, recorded as L';
[0122] Obtain the self-attention sequence Z through the second attention network module dec-mask , the self-attention sequence Z dec-maskThe convolution transformation sequence Z output by the embedding layer convolution transformation module dec-glu To splice;
[0123] The spliced sequence and the processing results V” and K” output by the encoding layer are subjected to sparse self-attention calculation by the mask attention network module to obtain joint attention; wherein, the obtained joint attention Zdec-mask and Zdec-glu are again divided into two branches to enter the sparse self-attention module and the threshold activation unit module respectively after the splicing and full-link processing in the previous step, just like the encoding layer. The part entering the sparse self-attention module also generates the corresponding new Query sequence through the preset transformation matrix, denoted as Qdec-mask. This part and the encoder output Q”, V” are subjected to sparse self-attention calculation to output the joint attention At, which is then spliced with the output of the threshold activation unit module of the other branch and processed by the full-link layer to output the predicted sequence Zt;
[0124] The load forecasting model is iteratively trained using the following loss function and Adam optimizer:
[0125] Loss = ∑L1 s (Gt, Zt),
[0126] Wherein, Gt is the training data ground truth sequence, and Zt is the prediction sequence; the iterative training adopts a step-by-step mode, that is, after predicting a time sequence moment value, it is added to the encoding layer input to fill in the original unknown corresponding time moment data, and predict the next time moment result;
[0127] Get the predicted sequence Zt.
[0128] In this embodiment, the time series moment refers to each time slice within a time period (window). For example, using the first 72 hours of data to predict the next 24 hours of data, a time slice is 1 hour.
[0129] In this embodiment, the embedding layer generates the corresponding Query, Key, and Value sequences by the transformation matrix preset by the self-attention module after the temporal position encoding data, and half of them are used to calculate the multi-head self-attention output Z' according to the number of channels (for example, 8), and the other half enters the threshold activation branch to calculate the local features. Since the calculation result of the entire attention module is the result of merging the calculation results of all query sequences, the result is sparse, that is, most of the queries at the temporal moments only occupy a small amount of self-attention weight, so it is necessary to find a method to measure the sparsity score of the query to determine whether the query is worth calculating.
[0130] In order to facilitate the understanding of the embodiments of the present application, Figure 2As shown, a schematic diagram of the overall structure of an electric vehicle charging demand prediction network structure in an embodiment of the present application is provided, including an embedding layer, an encoding layer and a decoding layer. Wherein, the embedding layer includes a convolution module (CNN), a position encoder and a time encoder, which are used to perform linear transformation and splicing of time series information on the input test data set to generate time series position encoding data. The encoding layer includes two branches, wherein the first branch includes a first probabilistic sparse self-attention network module for long-term attention construction and allocation; the second branch includes a gated linear activation unit for extracting local correlation information within a specified time period of the input data. The two branches each have a normalization layer and an addition layer (add), and the data is processed in parallel by the two branches, and then spliced together and sent to a fully connected layer (FC) for processing and output, wherein the fully connected layer and each splicing layer (stacking) are bundled, and the existing self-attention output is spliced and then fully connected. Processing, at the same time, the encoding layer and the decoding layer are also provided with a fully connected layer, and the same processing process is performed. The decoding layer includes a mask sparse self-attention network module and a second self-attention network module, which are used to obtain a joint attention sequence according to the output of the embedding layer and the encoding layer, and obtain a prediction result according to the joint attention sequence; wherein the second self-attention network module has the same structure as the first self-attention network module of the encoding layer.
[0131] In a second aspect, the present application also provides an electric vehicle charging demand prediction device, which is applied to an electric vehicle charging demand prediction server, such as Figure 3 As shown, an electric vehicle charging demand prediction device 300 is provided in an embodiment of the present application, and the device 300 includes: a construction unit 310, a training unit 320, and a prediction unit 330, wherein:
[0132] The construction unit 310 constructs a test data set;
[0133] The training unit 320 is used to train the load prediction model 340 using the test data set;
[0134] The prediction unit 330 inputs the test data set into the trained load prediction model 340 to obtain a prediction result.
[0135] In one embodiment of the present application, the data in the test data set is segmented according to the desired prediction time period, including the following dimensions: historical vehicle flow data, historical charging demand data, regional time-of-day electricity price data, holiday data, temperature data, energy storage operation status data, longitude and latitude of the charging station, season, weather, and whether there is an operating subsidy.
[0136] In one embodiment of the present application, the load forecasting model includes an embedding layer, an encoding layer and a decoding layer; wherein the embedding layer includes a convolution module, a position encoder and a time encoder, which are used to perform linear transformation and time series information splicing on the input test data set to generate time series position encoding data; the encoding layer includes two branches, wherein the first branch includes a first probabilistic sparse self-attention network module, which is used for long-term attention construction and allocation; the second branch includes a gated linear activation unit, a convolution module and a fully connected module, which is used to extract local correlation information within a specified time period of the input data; the encoding layer is used to perform parallel processing on the data output by the embedding layer to obtain Query, Key, Value query sequence matrices and self-attention outputs Z1", Z2"; and the processing results are spliced and sent to the fully connected layer and output; the decoding layer includes a mask sparse self-attention network module and a second self-attention network module, which are used to obtain a joint attention sequence according to the output of the embedding layer and the encoding layer, and obtain a prediction result according to the joint attention sequence; wherein the second self-attention network module has the same structure as the first self-attention network module of the encoding layer.
[0137] In one embodiment of the present application, the training unit 320 is specifically used to: perform data enhancement on the data generated after the linear transformation and the time series information are spliced together; send the data generated after the linear transformation and the time series information are spliced together and the data generated after the data enhancement as the data output by the embedding layer to the encoding layer; wherein the data enhancement adopts one of the following methods: Method 1: within a time period, split the data according to the dimension; for one or more dimensional data after the split, replace part or all of its content with a random value within its numerical limit range; combine the replaced dimensional data into the original data format; Method 2: within a time period, determine one or more slices in the data; randomly intercept one or more slices of the same length in other time periods; cover one or more slices determined in the data with one or more slices of the same length in other time periods.
[0138] In one embodiment of the present application, the training unit 320 is specifically used to: perform self-supervised contrastive learning training on the outputs of the embedding layer and the encoding layer through an Adam optimizer; and train the output of the load forecasting model through an Adam optimizer.
[0139] In one embodiment of the present application, the training unit 320 is specifically used to: perform self-supervised contrastive learning training on the outputs of the embedding layer and the encoding layer through the Adam optimizer, including: calculating the total loss L total , the total loss L totalSent to the convolution module of the embedding layer, updating the parameters of the convolution module; wherein the total loss L total Obtained by the following formula:
[0140]
[0141]
[0142] L total =L1+L2,
[0143] Among them, Z1 and Z2 are respectively the data generated by concatenating the linear transformation and timing information output by the embedding layer and the data generated after data enhancement, the P1 and P2 are the data output by the first branch and the second branch during the coding layer processing and have not yet entered the full-link module, and the ||…||2 represents the binary norm.
[0144] In one embodiment of the present application, the training unit 320 is specifically used for: the temporal position encoding data output by the embedding layer includes a Query, Key, and Value sequence, and the method for the first self-attention network module to generate a sparse probabilistic self-attention output includes:
[0145] For each time series moment, randomly sample the Key part corresponding to other time series moments, and the number of samples is M;
[0146] The following formula is used to calculate the sparsity scores corresponding to the M sampling keys of each Query:
[0147]
[0148] Among them, qi is the query of the i-th time moment, j is the time moments other than the i-th time moment, and k is the key part corresponding to all other time moments except the i-th time moment. T is the transposed form of k, d is the number of self-attention channels, and L is the sequence length;
[0149] Select the queries of the N time series moments with the highest sparsity scores, and use the following formula to calculate the dot product of the queries of the N time series moments and the keys corresponding to all time moments:
[0150]
[0151] Among them, softmax is the cross entropy function, Q, K, and V correspond to the query, key, and value sequence matrices obtained by transformation respectively;
[0152] The following formula is used to calculate the self-attention results of the Query at the N time sequence moments:
[0153]
[0154] Calculate the mean of the self-attention of the Query at the remaining LN time series moments as the self-attention result of the Query at the remaining LN time series moments;
[0155] The self-attention results of the Query at the N time sequence moments and the self-attention results of the Query at the remaining LN time sequence moments are combined as a sparse probabilistic self-attention output.
[0156] In one embodiment of the present application, the prediction unit 330 is specifically used for:
[0157] Determine the data encoding of the specified time window length before the prediction time point and the data encoding of the specified time window length after the prediction time point, recorded as L';
[0158] Obtain the self-attention sequence Z through the second attention network module dec-mask , the self-attention sequence Z dec-mask The convolution transformation sequence Z output by the embedding layer convolution transformation module dec-glu To splice;
[0159] The concatenated sequence and the processing results V” and K” output by the encoding layer are subjected to sparse self-attention calculation by the mask attention network module to obtain joint attention;
[0160] The load forecasting model is iteratively trained using the following loss function and Adam optimizer:
[0161] Loss = ∑L1 s (Gt, Zt),
[0162] Wherein, Gt is the training data ground truth sequence, and Zt is the prediction sequence; the iterative training adopts a step-by-step mode, that is, after predicting a time sequence moment value, it is added to the encoding layer input to fill in the original unknown corresponding time moment data, and predict the next time moment result;
[0163] Get the predicted sequence Zt.
[0164] It can be understood that the above-mentioned electric vehicle charging demand prediction device can implement the various steps of the electric vehicle charging demand prediction method performed by the electric vehicle charging demand prediction server provided in the aforementioned embodiment, and the relevant explanations on electric vehicle charging demand prediction are applicable to the electric vehicle charging demand prediction device and will not be repeated here.
[0165] Figure 4This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 4 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.
[0166] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0167] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0168] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming an electric vehicle charging demand prediction device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:
[0169] Build a test dataset;
[0170] Training the load forecasting model using the test data set;
[0171] The test data set is input into the trained load forecasting model to obtain a forecasting result.
[0172] The above application Figure 3The method performed by the electric vehicle charging demand prediction device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in a decoding processor. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0173] The electronic device may also perform Figure 3 The method for executing the electric vehicle charging demand prediction device in the present invention is realized Figure 3 The functions of the illustrated embodiment will not be described in detail in the embodiments of the present application.
[0174] The present application also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by an electronic device including multiple application programs, enable the electronic device to execute Figure 1 The method executed by the electric vehicle charging demand prediction device in the illustrated embodiment is specifically used to execute:
[0175] Build a test dataset;
[0176] Training the load forecasting model using the test data set;
[0177] The test data set is input into the trained load forecasting model to obtain a forecasting result.
[0178] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0179] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0180] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0181] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0182] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0183] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0184] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0185] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0186] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0187] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A method for predicting electric vehicle charging demand, applied to an electric vehicle charging demand prediction server, It is characterized in that The method comprises: Build a test dataset; Training the load forecasting model using the test data set; Obtain prediction results based on the trained load prediction model; The load prediction model includes an embedding layer, a coding layer and a decoding layer; wherein, The embedding layer includes a convolution module, a position encoder and a time encoder, which are used to perform linear transformation and time series information splicing on the input test data set to generate time series position encoding data; The encoding layer includes two branches, wherein the first branch includes a first probabilistic sparse self-attention network module for long-term attention construction and allocation; the second branch includes a gated linear activation unit, a convolution module and a fully connected module for extracting local correlation information within a specified time period of the input data; the encoding layer is used to process the data output by the embedding layer in parallel to obtain the query, key, value query sequence matrix and the self-attention output Z1", Z2"; and the processing results are spliced and sent to the fully connected layer for output; The decoding layer includes a mask sparse self-attention network module and a second self-attention network module, which are used to obtain a joint attention sequence according to the output of the embedding layer and the encoding layer, and obtain a prediction result according to the joint attention sequence; wherein the second self-attention network module has the same structure as the first probability sparse self-attention network module; The method for the first probabilistic sparse self-attention network module to generate a sparse probabilistic self-attention output includes: For each time series moment, the query randomly samples the key parts corresponding to other time series moments, and the number of samples is M; The following formula is used to calculate the sparsity scores corresponding to the M sampling keys of each Query: Among them, q i is the query for the i-th time moment, j is the time moment other than the i-th time moment, k is the key part corresponding to all other time moments except the i-th time moment, k T is the transposed form of k, d is the number of self-attention channels, and L is the sequence length; Select the queries of the N time series moments with the highest sparsity scores, and use the following formula to calculate the dot product of the queries of the N time series moments and the keys corresponding to all time moments: Among them, softmax is the cross entropy function, Q, K, and V correspond to the query, key, and value sequence matrices obtained by transformation respectively; The following formula is used to calculate the self-attention results of the Query at the N time sequence moments: Calculate the mean of the self-attention of the Query at the remaining LN time series moments as the self-attention result of the Query at the remaining LN time series moments; Merge the self-attention results of the Query at the N time sequence moments and the self-attention results of the Query at the remaining LN time sequence moments as a sparse probabilistic self-attention output; The method for the decoding layer to obtain the prediction result includes: Determine the data encoding of the specified time window length before the prediction time point and the data encoding of the specified time window length after the prediction time point, recorded as L'; The self-attention sequence Z is obtained by the second self-attention network module dec-mask , the self-attention sequence Z dec-mask The convolution transformation sequence Z output by the embedding layer convolution module dec-glu To splice; The concatenated sequence and the processing results V” and K” output by the encoding layer are subjected to sparse self-attention calculation by the mask sparse self-attention network module to obtain joint attention; The load forecasting model is iteratively trained using the following loss function and Adam optimizer: Loss=∑L1 s (Gt,Zt), Wherein, Gt is the training data groundture sequence, and Zt is the prediction sequence; the iterative training adopts a step-by-step mode, that is, after predicting a time sequence moment value, it is added to the encoding layer input to fill in the original unknown corresponding time moment data, and predict the next time moment result; Get the predicted sequence Zt; The training of the load forecasting model by using the test data set includes: Performing self-supervised contrastive learning training on the outputs of the embedding layer and the encoding layer through the Adam optimizer; Training the output of the load forecasting model through an Adam optimizer; The self-supervised contrastive learning training is performed on the outputs of the embedding layer and the encoding layer by using the Adam optimizer, including: Calculate the total loss L total , The total loss L total Sending to the convolution module of the embedding layer, updating the parameters of the convolution module; Among them, the total loss L total Obtained by the following formula: L total =L 1 +L 2 , Among them, Z 1 , Z 2 are the data generated by concatenating the linear transformation and time series information output by the embedding layer and the data generated by data enhancement, respectively. 1 , P 2 is the data output by the first branch and the second branch during the coding layer processing and not yet entering the fully connected module, ||···|| 2 represents the two-norm.
2. The electric vehicle charging demand prediction method according to claim 1, Features: The data in the test data set is segmented according to the expected prediction time period, including the following dimensions: historical traffic data, historical charging demand data, regional time-of-day electricity price data, holiday data, temperature data, energy storage operation status data, latitude and longitude of the charging station, season, weather, and whether there is an operating subsidy.
3. The electric vehicle charging demand prediction method according to claim 1, Features: The embedding layer is also used to: Performing data enhancement on the data generated after the linear transformation and the time series information are concatenated; Sending the data generated by concatenating the linear transformation and the time series information and the data generated by data enhancement as the output data of the embedding layer to the encoding layer; The data enhancement adopts one of the following methods: Method 1: In a time period, data is split according to dimensions; For one or more dimension data after splitting, part or all of its content is replaced with a random value within its numerical limit range; Combine the replaced dimension data into the original data format; Method 2: Within a time period, one or more slices are identified in the data; Randomly extract one or more slices of the same length in other time periods; Overlay one or more slices determined in the data with one or more slices of the same length within the other time period.
4. An electric vehicle charging demand prediction device, applied to an electric vehicle charging demand prediction server, in, The device is used to implement any one of the methods described in claims 1 to 3.
5. An electronic device, include: processor; as well as A memory arranged to store computer executable instructions, which when executed cause the processor to perform the method of any one of claims 1 to 3.
