EMS photovoltaic prediction method based on LSTM-Attention neural network
By introducing an LSTM-Attention neural network into the EMS system for photovoltaic power generation prediction, the problem of low power prediction efficiency in existing technologies is solved, and more efficient energy management and scheduling are achieved.
Patent Information
- Application Number
- CN202411259093.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-10
- Publication Date
- 2025-01-10
Smart Images

Figure CN119294584A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of photovoltaic prediction systems, and in particular relates to an EMS photovoltaic prediction method based on an LSTM-Attention neural network. Background Art
[0002] EMS (Energy Management System) is an important tool to ensure the stable, efficient and reliable operation of the power grid. It improves the operating efficiency of the power system, reduces operating costs, and enhances the reliability and sustainability of the system by monitoring the state of the power grid in real time, controlling power grid equipment, predicting power demand and supply, optimizing power system operation, managing faults, and processing analysis reports. The EMS energy management system mainly consists of sensors and detectors, meteorological data acquisition systems, communication networks, central servers, cloud platforms, energy optimization strategy units, etc. They work together to ensure the stable operation and efficient management of the power system through integration and coordination. However, existing EMS energy management systems usually rely on physical models and statistical analysis to predict power demand and supply, but these methods often cannot adapt to rapidly changing power markets and environmental conditions.
[0003] In recent years, the development of artificial intelligence and machine learning technologies has provided new ways to optimize power systems. The application of artificial intelligence (AI) in energy management systems (EMS) is an important trend in the current energy industry. It can help achieve more efficient use of energy, improve the reliability of the power grid, reduce operating costs, and promote the integration of renewable energy to a certain extent. In terms of predicting data, deep learning models with long short-term memory (LSTM) neural networks as the core have been shown to have significant advantages in processing time series data. LSTM controls the flow of information by introducing three gate structures - forget gate, input gate, and output gate - so that long-term dependencies can be effectively learned, which makes it widely used in the field of energy management. Summary of the invention
[0004] In order to overcome the above-mentioned shortcomings, the present invention provides an EMS photovoltaic prediction method based on LSTM-Attention neural network, which integrates the method of predicting photovoltaic power generation by LSTM-Attention neural network into the EMS energy management system, greatly improving the EMS energy management efficiency.
[0005] The main technical solutions adopted in the present invention are:
[0006] An EMS photovoltaic prediction method based on LSTM-Attention neural network, the specific steps are as follows:
[0007] S1: Collect aggregated equipment data and meteorological data, and normalize the obtained aggregated meteorological data;
[0008] S2: Divide the aggregated meteorological data set into a test set and a validation set, build an LSTM-Attention neural network, train and adjust the parameters of the LSTM-Attention neural network, and obtain a prediction model;
[0009] S3: Convert the trained prediction model into a rknn model;
[0010] S4: Deploy the rknn model to the EMS board, import new aggregated meteorological data into the EMS system, and use the trained prediction model to predict power generation to achieve energy management and scheduling.
[0011] Preferably, the specific steps of S1 are as follows:
[0012] S11: Collecting equipment data and meteorological data of energy equipment, and performing aggregation operation on the acquired data to obtain aggregated meteorological data;
[0013] S12: Perform normalization operation on the obtained aggregated meteorological data. The specific formula is as follows:
[0014]
[0015] Among them, x' is the normalized result of each aggregated meteorological data, x is the actual value of each clustering indicator data, and x min is the minimum value of each clustering indicator data, x max is the maximum value of each clustering indicator data.
[0016] Preferably, the specific steps of building the LSTM-Attention neural network are as follows:
[0017] S21. Determine the number of input layer nodes according to the input parameters. The output parameter is the power generation. Therefore, the number of output layer nodes is 1. The remaining network parameters are debugged according to the data type.
[0018] S22, the initial aggregated meteorological data set is processed by the LSTM network to obtain the sequence data of each time step, the sequence data is divided into a training set and a test set according to a certain ratio, and then the LSTM neural network is used to capture the long-distance dependency relationship in the sequence data;
[0019] S23. Based on the LSTM network, the Attention mechanism is introduced to assign a weight to each feature in the sequence data of each time step output by the LSTM network;
[0020] S24. Input the sequence data after weights are assigned by the Attention mechanism into the fully connected layer to obtain the final output result.
[0021] Preferably, the built LSTM-Attention neural network is trained and adjusted. The specific steps are as follows:
[0022] Sa initializes the hyperparameters, including the number of layers, number of hidden layer nodes, learning rate, batch size, and number of iterations of the LSTM network;
[0023] Sb, the prediction performance of the prediction model was evaluated using the mean relative error;
[0024] Sc. Adjust the prediction model by adjusting the hyperparameters until the model can achieve relatively optimal prediction performance.
[0025] Preferably, the specific steps of S3 are as follows:
[0026] S31: Export the model trained in step S2 in the format of “.pth”;
[0027] S32: converting the model exported in step S31 into an onnx model;
[0028] S33: Convert the onnx model into a rknn model.
[0029] Preferably, the specific steps of S4 are as follows:
[0030] S41: Deploy the rknn model to the EMS board through the embedded method;
[0031] S42: Generate an executable program to run the rknn model and deploy it to the EMS board;
[0032] S43: Import the data and make predictions on the input meteorological data through commands.
[0033] Preferably, the LSTM network is composed of multiple LSTM units, wherein one LSTM unit consists of four parts: a forget gate, an output gate, a storage unit state and an output gate.
[0034] Preferably, the specific steps of S23 are as follows:
[0035] S231: For the sequence data output by the LSTM network, each feature is scored with an attention coefficient, and its mathematical model is:
[0036] e t =α1tanh(α2·h t +b) (2);
[0037] Among them, e t is the attention coefficient score, α1 and α2 are weight parameters, and h tis the output of the LSTM network, b is the bias term, and tanh() is the activation function;
[0038] S232: Use the softmax function to convert the attention coefficient into a probability form as the weight of the corresponding feature, as shown below:
[0039] α t =soft max(e t ) (3);
[0040] S233: The weight obtained in step S232 is added to the weighted output of the LSTM network to obtain the output sequence H:
[0041]
[0042] Beneficial effects: The present invention provides an EMS photovoltaic prediction method based on LSTM-Attention neural network, which has the following advantages:
[0043] (1) The present invention uses the LSTM-Attention neural network to predict the power generation to optimize the operating parameters of the equipment and reduce unnecessary waste. Compared with the LSTM neural network, it has better performance in processing long sequence time series data, and can better grasp the important features of multi-feature data, and has stronger generalization ability.
[0044] (2) The present invention can be applied to the prediction of power load, so that EMS can achieve more effective energy scheduling, reduce peak load, and balance supply and demand, which plays an important role in the operation and maintenance of photovoltaic modules and energy scheduling in the future. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 is a flow chart of the present invention;
[0046] Figure 2 Schematic diagram of the composition of the LSTM network in the present invention;
[0047] Figure 3 It is a schematic diagram of the principle of the LSTM-Attention neural network in the present invention. DETAILED DESCRIPTION
[0048] In order to enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in the embodiments of this application are clearly and completely described below. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application.
[0049] Example 1
[0050] An EMS photovoltaic prediction method based on LSTM-Attention neural network, such as Figure 1 As shown, the specific steps are as follows:
[0051] S1: Collect aggregated equipment data and meteorological data, and normalize the obtained aggregated meteorological data; the specific steps are as follows:
[0052] S11: collecting equipment data and meteorological data of energy equipment through external energy equipment, mainly including solar photovoltaic panels and energy storage batteries, and performing aggregation operations on the acquired data, such as aggregating by time period to obtain aggregated meteorological data;
[0053] S12: Perform normalization operation on the obtained aggregated meteorological data. The specific formula is as follows:
[0054]
[0055] Among them, x' is the normalized result of each aggregated meteorological data, x is the actual value of each clustering indicator data, and x min is the minimum value of each clustering indicator data, x max is the maximum value of each clustering indicator data.
[0056] S2: Input the aggregated meteorological data set into the LSTM-Attention neural network for training and parameter adjustment to obtain a prediction model. Figure 3 As shown, the specific steps for building the LSTM-Attention neural network are as follows:
[0057] S21: Determine the number of input layer nodes according to input parameters, including but not limited to weather parameters or energy parameters such as irradiance and temperature; the output parameter is power generation, so the number of output layer nodes is 1; the remaining network parameters are debugged according to the data type;
[0058] S22: After the initial aggregated meteorological data set is processed by the LSTM network, the sequence data of each time step is obtained, and the sequence data is divided into a training set and a test set according to a certain ratio, and then the LSTM neural network is used to capture the long-distance dependency relationship in the sequence data. In this embodiment 1, the LSTM network is composed of multiple LSTM units, such as Figure 2 As shown, an LSTM unit consists of four modules: a forget gate, an output gate, a storage unit state, and an output gate. The following is the transmission process of each module in the LSTM network in this embodiment 1:
[0059] Forget gate: f t =σ(W f ·[h t-1 ,Xt ]+b f );
[0060] Input gate: i t =σ(W i ·[h t-1 ,X t ]+b i );
[0061] Input unit status:
[0062] Calculate the unit status at the moment:
[0063] Output gate: o t =σ(W o ·[h t-1 ,X t ]+b o );
[0064] h t =o t ·tanh(c t )
[0065] Among them, f t is the forget gate, W f is the weight matrix of the forget gate, b f is the bias of the forget gate, σ is the sigmoid function, [h t-1 ,X t ] means combining two vectors into a longer vector; i t is the input gate, W i is the weight matrix of the input gate, b i is the bias of the input gate; is the current input unit state, W c is the weight matrix of the input gate, b c is the bias of the input gate, tanh is the tanh activation function; c t is the unit state at the current moment, c t-1 is the unit state at the previous moment; o t is the output gate, W o is the weight matrix of the output gate, b o is the bias of the output gate; h t is the final output of the LSTM network.
[0066] S23: In order to grasp the main factors in the multivariate features, the Attention mechanism is introduced on the basis of the LSTM network, so that the model can pay more attention to the important parts of the sequence data when processing each time step. For each time step of the LSTM network output, the Attention mechanism will assign a weight to each feature in the sequence data. These weights represent the importance of the feature to the current output. The larger the weight, the greater the influence of the feature information on the current output. In this embodiment 1, the specific method of assigning weights by the Attention mechanism is as follows:
[0067] S231: For the sequence data output by the LSTM network, each feature is scored with an attention coefficient, and its mathematical model is:
[0068] e t =α1tanh(α2·h t +b) (2);
[0069] Among them, e t is the attention coefficient score, α1 and α2 are weight parameters, and h t is the output of the LSTM network, b is the bias term, and tanh() is the activation function;
[0070] S232: Use the softmax function to convert the attention coefficient into a probability form as the weight of the corresponding feature, as shown below:
[0071] α t =soft max(e t ) (3);
[0072] S233: The weight obtained in step S232 is added to the weighted output of the LSTM network to obtain the output sequence H:
[0073]
[0074] S24: Input the sequence data after weights are assigned by the Attention mechanism into the fully connected layer to obtain the final output result.
[0075] The above process is the process of building the LSTM-Attention neural network. Next, we need to train and adjust the parameters of the LSTM-Attention neural network. The specific process is as follows:
[0076] Sa initializes the hyperparameters, including the number of layers, number of hidden layer nodes, learning rate, batch size, and number of iterations of the LSTM network;
[0077] Sb, the mean relative error (MRE) is used to evaluate the prediction performance of the prediction model, where the calculation formula of the mean relative error MRE is as follows;
[0078]
[0079] Among them, n is the total number of prediction results, y i is the predicted value, is the actual value.
[0080] Sc. Adjust the prediction model by adjusting the hyperparameters until the model can achieve relatively optimal prediction performance.
[0081] S3: Convert the trained prediction model into a rknn model; the specific steps are as follows:
[0082] S31: Export the model trained in step S2 in the format of ".pth", which can be exported by code;
[0083] S32: converting the model exported in step S31 into an onnx model, which can be done by code;
[0084] S33: Use the rknn_toolkit2 tool to convert the onnx model into a rknn model.
[0085] S4: Deploy the rknn model to the EMS board, import new meteorological data into the EMS system, and use the trained prediction model to predict power generation to achieve energy management and scheduling.
[0086] The specific methods are as follows
[0087] S41: Deploy the rknn model to the EMS board through the embedded method;
[0088] S42: Generate an executable program to run the rknn model through C++ and CMakeLists and deploy it to the EMS board;
[0089] S43: Import the data and make predictions on the input meteorological data through commands.
[0090] The meteorological data of a photovoltaic site in Yinchuan for the whole month of August 2019 were selected for analysis and training of the LSTM-Attention network, and the prediction model was constructed using the prediction method of this embodiment 1. The data of one day were selected for testing, and 8 groups of short-term data were taken to predict the accuracy of the power generation after 5 minutes. The specific mean relative error (MRE unit %) is shown in the following table:
[0091]
[0092] It can be seen from the average relative error of each model that the prediction accuracy is the most accurate in the noon prediction time period. The accuracy loss of the onnx model relative to the LSTM-Attention model is almost 0. The accuracy loss of the RKNN model relative to the LSTM-Attention model fluctuates, but the overall accuracy loss is small, indicating that the prediction method of the present invention can improve the prediction accuracy without much performance loss.
[0093] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. An EMS photovoltaic prediction method based on LSTM-Attention neural network, characterized in that: The specific steps are as follows: S1: Collect aggregated equipment data and meteorological data, and normalize the obtained aggregated meteorological data; S2: Divide the aggregated meteorological data set into a test set and a validation set, build an LSTM-Attention neural network, train and adjust the parameters of the LSTM-Attention neural network, and obtain a + prediction model; S3: Convert the trained prediction model into a rknn model; S4: Deploy the rknn model to the EMS board, import new aggregated meteorological data into the EMS system, and use the trained prediction model to predict power generation to achieve energy management and scheduling.
2. The EMS photovoltaic prediction method based on LSTM-Attention neural network according to claim 1 is characterized in that: The specific steps of S1 are as follows: S11: Collecting equipment data and meteorological data of energy equipment, and performing aggregation operation on the acquired data to obtain aggregated meteorological data; S12: Perform normalization operation on the obtained aggregated meteorological data. The specific formula is as follows: Among them, x' is the normalized result of each aggregated meteorological data, x is the actual value of each clustering indicator data, and x min is the minimum value of each clustering indicator data, x max is the maximum value of each clustering indicator data.
3. The EMS photovoltaic prediction method based on LSTM-Attention neural network according to claim 1 is characterized in that: The specific steps of building the LSTM-Attention neural network are as follows: S21. Determine the number of input layer nodes according to the input parameters. The output parameter is the power generation. Therefore, the number of output layer nodes is 1. The remaining network parameters are debugged according to the data type. S22, the initial aggregated meteorological data set is processed by the LSTM network to obtain the sequence data of each time step, the sequence data is divided into a training set and a test set according to a certain ratio, and then the LSTM neural network is used to capture the long-distance dependency relationship in the sequence data; S23. Based on the LSTM network, the Attention mechanism is introduced to assign a weight to each feature in the sequence data of each time step output by the LSTM network; S24. Input the sequence data after weights are assigned by the Attention mechanism into the fully connected layer to obtain the final output result.
4. The EMS photovoltaic prediction method based on LSTM-Attention neural network according to claim 3 is characterized in that: Train and adjust the parameters of the built LSTM-Attention neural network. The specific steps are as follows: Sa initializes the hyperparameters, including the number of layers, number of hidden layer nodes, learning rate, batch size, and number of iterations of the LSTM network; Sb, the prediction performance of the prediction model was evaluated using the mean relative error; Sc. Adjust the prediction model by adjusting the hyperparameters until the model can achieve relatively optimal prediction performance.
5. The EMS photovoltaic prediction method based on LSTM-Attention neural network according to claim 1 is characterized in that: The specific steps of S3 are as follows: S31: Export the model trained in step S2 in the format of ".pth"; S32: converting the model exported in step S31 into an onnx model; S33: Convert the onnx model into a rknn model.
6. The EMS photovoltaic prediction method based on LSTM-Attention neural network according to claim 1 is characterized in that: The specific steps of S4 are as follows: S41: Deploy the rknn model to the EMS board through the embedded method; S42: Generate an executable program to run the rknn model and deploy it to the EMS board; S43: Import the data and make predictions on the input meteorological data through commands.
7. The EMS photovoltaic prediction method based on LSTM-Attention neural network according to claim 3 is characterized in that: The LSTM network is composed of multiple LSTM units, wherein one LSTM unit consists of four parts: a forget gate, an output gate, a storage unit state and an output gate.
8. The EMS photovoltaic prediction method based on LSTM-Attention neural network according to claim 3 is characterized in that: The specific steps of S23 are as follows: S231: For the sequence data output by the LSTM network, each feature is scored with an attention coefficient, and its mathematical model is: e t =α1tanh(α2·h t +b) (2); Among them, e t is the attention coefficient score, α1 and α2 are weight parameters, and h t is the output of the LSTM network, b is the bias term, and tanh() is the activation function; S232: Use the softmax function to convert the attention coefficient into a probability form as the weight of the corresponding feature, as shown below: a t =softmax(e t ) (3); S233: The weight obtained in step S232 is added to the weighted output of the LSTM network to obtain the output sequence H: