Short-term power load prediction method and device based on woa-am-gru
By combining the whale optimization algorithm and the attention mechanism of the GRU network, the problems of prediction accuracy and hyperparameter selection difficulties in complex power load forecasting of traditional methods are solved, and more efficient short-term power load forecasting is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- STATE GRID JILIN ELECTRIC POWER COMPANY LIMITED
- Filing Date
- 2026-03-10
- Publication Date
- 2026-06-26
AI Technical Summary
Traditional short-term power load forecasting methods suffer from low prediction accuracy, difficulty in selecting hyperparameters, and low computational efficiency when dealing with complex nonlinear and high-dimensional data.
We employ a WOA-AM-GRU-based approach, combining whale optimization algorithm, attention mechanism, and gated recurrent unit network. Through data preprocessing, GRU neural network construction, attention mechanism, and hyperparameter optimization, we enhance the model's predictive ability.
It significantly improves the accuracy and efficiency of short-term power load forecasting, reduces forecasting errors, and enhances the economy and reliability of the power system.
Smart Images

Figure CN122292301A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of power load forecasting technology, specifically relating to a short-term power load forecasting method and apparatus based on WOA-AM-GRU. Background Technology
[0002] In the field of short-term power load forecasting, traditional methods such as time series analysis, linear regression, and Kalman filtering typically rely on relatively simple mathematical models. These methods exhibit significant limitations when dealing with complex nonlinear and high-dimensional data. For example, methods based on traditional regression models usually require high data stationarity and have weak capabilities in handling nonlinear factors, resulting in low prediction accuracy in complex power load forecasting scenarios. While machine learning methods based on artificial neural networks (ANNs) and support vector machines (SVMs) can handle nonlinear problems better, they still face challenges such as difficulty in hyperparameter selection and low computational efficiency. Summary of the Invention
[0003] To address the problems existing in the prior art, this invention provides a short-term power load forecasting method and apparatus based on WOA-AM-GRU. It overcomes the shortcomings of traditional methods when processing complex power load data and can also fully explore potential patterns in historical data, thereby improving the effectiveness of short-term power load forecasting.
[0004] To achieve the above objectives, the present invention provides the following solution: A short-term power load forecasting method based on WOA-AM-GRU includes: Step S1: Preprocess historical load and meteorological data; Step S2: Construct a GRU neural network based on the preprocessed load data and meteorological data; Step S3: Pass the hidden state output by the GRU neural network to the attention mechanism to obtain the AM-GRU model; Step S4: Use the whale optimization algorithm to optimize the hyperparameters of the AM-GRU model to obtain the WOA-AM-GRU model; Step S5: Use the training dataset to train the WOA-AM-GRU model and make predictions using the optimized hyperparameters.
[0005] As preferred options, hyperparameters include: learning rate, number of iterations, and number of hidden layer nodes.
[0006] Preferably, meteorological data includes: minimum temperature, maximum temperature, average temperature, and humidity.
[0007] The present invention also provides a short-term power load forecasting device based on WOA-AM-GRU, comprising: The first processing module is used to preprocess historical load and meteorological data; The second processing module constructs a GRU neural network based on the preprocessed load data and meteorological data. The third processing module passes the hidden state output by the GRU neural network to the attention mechanism to obtain the AM-GRU model; The fourth processing module uses the whale optimization algorithm to optimize the hyperparameters of the AM-GRU model to obtain the WOA-AM-GRU model. The fifth processing module uses the training dataset to train the WOA-AM-GRU model and performs predictions using the optimized hyperparameters.
[0008] As preferred options, hyperparameters include: learning rate, number of iterations, and number of hidden layer nodes.
[0009] Preferably, meteorological data includes: minimum temperature, maximum temperature, average temperature, and humidity.
[0010] Compared with the prior art, the beneficial effects of the present invention are as follows: This invention, based on the WOA-AM-GRU model, effectively improves the accuracy and efficiency of short-term power load forecasting by combining the whale optimization algorithm, attention mechanism, and Gated Recurrent Unit (GRU) network. The whale optimization algorithm addresses the parameter selection difficulties in traditional methods through hyperparameter optimization, while the attention mechanism enables the model to better capture important features in the data, improving its sensitivity to key factors. Simultaneously, the GRU network can process long-term series data and uncover complex patterns in load data. Attached Figure Description
[0011] To more clearly illustrate the technical solution of the present invention, the drawings used in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a flowchart of the short-term power load forecasting method based on WOA-AM-GRU according to an embodiment of the present invention; Figure 2 This is a schematic diagram illustrating global optimization using the Whale Optimization Algorithm (WOA). Detailed Implementation
[0013] 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 embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0014] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0015] Example 1 like Figure 1 As shown, this invention provides a short-term power load forecasting method based on WOA-AM-GRU. Based on the WOA-AM-GRU model, it comprehensively utilizes historical load data and meteorological information, combining the time-series processing capabilities of GRU, feature weighting with an attention mechanism, and hyperparameter optimization using the whale optimization algorithm, significantly improving the accuracy of short-term power load forecasting. Specifically, it includes: Step S1: Data Preprocessing First, the load and meteorological data were preprocessed using historical load data from 2014 and corresponding meteorological data (including minimum temperature, maximum temperature, average temperature, humidity, etc.). The data sampling interval was 15 minutes, with 96 data points per day. Load values were logarithmically processed, while temperature values were processed using the max-min normalization method. Humidity values were normalized to between 0 and 1, and the day type (e.g., Monday to Friday, weekend, holidays, etc.) was also numerically processed accordingly.
[0016] Step S2: Construct the GRU neural network Preprocessed load data and meteorological data (such as temperature and humidity) are input into the GRU (Gated Recurrent Unit) network. The GRU can mine long-term dependencies in the data through its reset and update gates, and generate a hidden state vector (H) based on the input historical load data and meteorological information. This process helps the model learn the inherent patterns between load data.
[0017] Specifically, the GRU network structure includes a reset gate and an update gate. The former allows information from the previous time step to be ignored, while the latter passes information from the previous time step to the current time step. Its detailed construction and calculation process is as follows: Calculate the reset gate: Compute update gate: Calculate candidate hidden states: Update the current hidden state: Calculate the network's predicted output value: in, for Input at any moment; This is the hidden state from the previous moment; For the Sigmoid function; This is the weight matrix for different variables.
[0018] Step S3: Introduce an attention mechanism The hidden state (H) output by the GRU network is passed to the attention mechanism (AM).
[0019] The AM function is represented as a set of functions, and its probability distribution is calculated to obtain the weight values of key factors influencing the target. The magnitude of the weight value represents the degree of correlation between the influencing factor and the target. The hidden state row vectors output by the GRU network are then used to calculate the weights. The calculation process for directly using the input sequence of AM is as follows: in, For GRU networks in Time and The hidden layer state output at any given time; These are the weight matrix (weight values) of the multilayer perceptron during the process of obtaining the network weights. These are bias parameters; For the network in The intermediate probability distribution (or attention score) at each time step; These are derived from network calculations. Time and The contribution ratio of time-specific feature information (i.e., the final weight); The dimension (data length) of the hidden state sequence; This is the final output result after dynamic weighted summation through the attention mechanism.
[0020] The attention mechanism dynamically adjusts the weights of each feature by calculating the weights of different hidden states based on the different importance of load data and meteorological data. This results in higher weights for data that have a greater impact on load forecasting, while ignoring features that have a smaller impact on the results. The weighted hidden state is then imported into the GRU network to further uncover the hidden patterns among the data.
[0021] Step S4: Optimize hyperparameters using the Whale Optimization Algorithm (WOA). For hyperparameters (such as learning rate, number of iterations, number of hidden layer nodes, etc.) in the AM-GRU model, the Whale Optimization Algorithm (WOA) is used for global optimization. Figure 2 As shown, the whale optimization algorithm is a novel intelligent optimization algorithm inspired by the hunting behavior of humpback whales. The position of each humpback whale represents a feasible solution. Throughout the process, the input data represents a randomly initialized set of AM-GRU model hyperparameters, and the output data represents the optimal AM-GRU model hyperparameters obtained through iterative optimization.
[0022] The specific steps are described below: Step 1: First, randomly initialize the whale population. Each "whale individual location" represents a set of hyperparameter solutions to be optimized for the AM-GRU model (specifically including: learning rate, number of iterations, and number of nodes in the two hidden layers). Input these hyperparameters into the AM-GRU model for training, and use the mean squared error (MSE) of the model on the training and test sets as the fitness function value for that individual. The smaller the fitness value, the better the prediction performance of that set of hyperparameters.
[0023] Step 2: Compare the fitness values of all individuals in the current population, find the individual with the best current fitness, and record its position (i.e., the best performing AM-GRU hyperparameter combination) and corresponding fitness value as the global optimum.
[0024] Step 3: Determine whether the current algorithm has reached the preset termination condition (such as reaching the maximum number of iterations or meeting the accuracy requirements).
[0025] If the condition is met: then break out of the loop and directly execute the last step, "output optimal hyperparameters".
[0026] If not (condition not met): then proceed to the next step of the population position update mechanism.
[0027] Step 4: Generate a random number in the range [0,1] for each whale. This serves as a probability basis for choosing a predation method. (Judgment / Determination) >0.5: Yes: A bubble net feeding mechanism is employed. The whale approaches its current optimal position (optimal hyperparameter combination) in a spiral trajectory, and the corresponding hyperparameter position update formula is: .
[0028] No: An encirclement predation mechanism is employed. The whales directly shrink their encirclement towards the current optimal position (optimal hyperparameter combination) of the population, and the corresponding hyperparameter position update formula is: .
[0029] Step 5: Iterate After all individuals' hyperparameter positions are updated, the process returns to the "calculate the fitness of each individual" step as indicated by the arrow, and continues to evaluate the updated AM-GRU hyperparameters, repeating steps 2 to 4.
[0030] Step 6: Output the optimal hyperparameters Output data: Once the termination condition is met, the algorithm stops iterating and outputs the globally optimal whale position. This position represents the optimal hyperparameter combination (best learning rate, number of iterations, and number of hidden layer nodes) of the AM-GRU model obtained through optimization. Subsequently, this set of optimal hyperparameters is substituted into the final WOA-AM-GRU short-term power load forecasting model.
[0031] (1) Searching for prey When hunting, humpback whales search for prey by randomly updating their relative positions; the mathematical expression for this is: Where S represents the degree of difference between the current hyperparameter combination and the randomly selected hyperparameter combination; X represents the current AM-GRU model hyperparameter combination vector (including learning rate, number of iterations, number of hidden layer nodes, etc.); T is the number of iterations; X(T+1) is the AM-GRU model hyperparameter combination vector updated after T+1 iterations; Xrand is a set of AM-GRU model hyperparameter combination vectors randomly selected from the current population; A and C are coefficient vectors that control the hyperparameter search step size and weights; a is the convergence factor that linearly decreases from 2 to 0 during the optimization iteration process; and r is a random vector between [0, 1].
[0032] (2) Encirclement and bubble net predation Humpback whales employ two hunting mechanisms: encirclement and bubble net hunting. Assuming a 50 / 50 probability of choosing between these two methods, the mathematical expression for this is: In the formula: P is the probability of selecting the update strategy, which is a random number between [0, 1]; This represents the hyperparameter combination vector of the AM-GRU model with the best fitness in the current T-th iteration (i.e., the hyperparameter combination that minimizes the model's prediction error). and This represents the current hyperparameter combination and the current optimal hyperparameter combination. The degree of difference between them; b is a constant that defines the shape of the logarithmic spiral search path; l is a random number between [-1, 1].
[0033] The whale optimization algorithm simulates the hunting behavior of humpback whales, searches for the optimal solution through the search space, and adjusts the hyperparameters of AM-GRU. Especially when the data volume is large and complex, it can avoid the difficulty of manually adjusting the hyperparameters and ensure that the model can perform well on both training and testing data.
[0034] Step S5: Model Training and Prediction Output The training dataset (load data for the first 364 days of 2014) was used to train the WOA-AM-GRU model, and predictions were made using the optimized hyperparameters.
[0035] Then, the load data from the last day was used for testing. By repeating the prediction experiment three times, the average error of each prediction was calculated and compared to evaluate the prediction performance of different models.
[0036] Finally, the WOA-AM-GRU model showed superior performance in short-term power load forecasting, with a MAPE (mean absolute percentage error) of 0.2012, a MAE (mean absolute error) of 0.0254, and excellent RMSE (root mean square error) and MASE (mean square absolute error) indicators. The R² (coefficient of determination) was 0.9955.
[0037] As shown in Table 1, the WOA-AM-GRU model of this invention significantly improves prediction accuracy and reduces prediction error compared to traditional prediction methods. Furthermore, it exhibits higher computational efficiency when processing large-scale data, further enhancing the economy and reliability of the power system. Table 1 Example 2 The present invention also provides a short-term power load forecasting device based on WOA-AM-GRU, comprising: The first processing module is used to preprocess historical load and meteorological data; The second processing module constructs a GRU neural network based on the preprocessed load data and meteorological data. The third processing module passes the hidden state output by the GRU neural network to the attention mechanism to obtain the AM-GRU model; The fourth processing module uses the whale optimization algorithm to optimize the hyperparameters of the AM-GRU model to obtain the WOA-AM-GRU model. The fifth processing module uses the training dataset to train the WOA-AM-GRU model and performs predictions using the optimized hyperparameters.
[0038] As one embodiment of the present invention, the hyperparameters include: learning rate, number of iterations, and number of hidden layer nodes.
[0039] As one embodiment of the present invention, the meteorological data includes: minimum temperature, maximum temperature, average temperature, and humidity.
[0040] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Various modifications and improvements made by those skilled in the art to the technical solutions of the present invention without departing from the spirit of the present invention should fall within the protection scope defined by the claims of the present invention.
Claims
1. A short-term power load forecasting method based on WOA-AM-GRU, characterized in that, include: Step S1: Preprocess historical load and meteorological data; Step S2: Construct a GRU neural network based on the preprocessed load data and meteorological data; Step S3: Pass the hidden state output by the GRU neural network to the attention mechanism to obtain the AM-GRU model; Step S4: Use the whale optimization algorithm to optimize the hyperparameters of the AM-GRU model to obtain the WOA-AM-GRU model; Step S5: Use the training dataset to train the WOA-AM-GRU model and make predictions using the optimized hyperparameters.
2. The short-term power load forecasting method based on WOA-AM-GRU as described in claim 1, characterized in that, Hyperparameters include: learning rate, number of iterations, and number of hidden layer nodes.
3. The short-term power load forecasting method based on WOA-AM-GRU as described in claim 2, characterized in that, Meteorological data includes: minimum temperature, maximum temperature, average temperature, and humidity.
4. A short-term power load forecasting device based on WOA-AM-GRU, characterized in that, include: The first processing module is used to preprocess historical load and meteorological data; The second processing module constructs a GRU neural network based on the preprocessed load data and meteorological data. The third processing module passes the hidden state output by the GRU neural network to the attention mechanism to obtain the AM-GRU model; The fourth processing module uses the whale optimization algorithm to optimize the hyperparameters of the AM-GRU model to obtain the WOA-AM-GRU model. The fifth processing module uses the training dataset to train the WOA-AM-GRU model and performs predictions using the optimized hyperparameters.
5. The short-term power load forecasting device based on WOA-AM-GRU as described in claim 4, characterized in that, Hyperparameters include: learning rate, number of iterations, and number of hidden layer nodes.
6. The short-term power load forecasting device based on WOA-AM-GRU as described in claim 5, characterized in that, Meteorological data includes: minimum temperature, maximum temperature, average temperature, and humidity.