Flexible load prediction method and system based on improved TCN neural network model
By introducing an improved CPO algorithm into the TCN neural network model, the size and number of convolution kernels are optimized, and the problem of large fluctuations in prediction results in load prediction is solved, achieving higher prediction accuracy and stability.
Patent Information
- Application Number
- CN202411709507.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-03-28
AI Technical Summary
The existing load prediction methods, especially those based on the TCN neural network model, have artificial or random assignment of convolution kernel size and number of convolution kernels, resulting in large fluctuations in the error of the prediction results and low accuracy.
An improved CPO algorithm is introduced to optimize the size of the convolution kernel and the number of convolution kernels of the TCN neural network model through adaptive weight parameters and Cauchy variability factors, improve the algorithm's global search ability and local optimization ability, and reduce prediction errors.
Through the optimized CPO-TCN model, the error range of prediction results is significantly narrowed, the accuracy and stability of load prediction are improved, and the randomness of prediction is reduced.
Smart Images

Figure CN119726654A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of load forecasting, and in particular relates to a flexible load forecasting method and system based on an improved TCN neural network model. Background Art
[0002] With the advancement of social science and technology, the power system has also developed rapidly. The structure of modern power systems has become more complex, the capacity has become larger, and the number of nodes has increased. The load forecasting level of the power system is one of the important indicators of the stability of the power system operation. In order to ensure the stable operation of the power system, accurate load forecasting is an important prerequisite for formulating power generation and consumption plans. The existing load forecasting methods are mainly divided into two types: traditional load forecasting methods and methods based on machine learning and deep learning. Traditional load forecasting methods require stationarity processing of time series data, are sensitive to outliers, and the prediction accuracy may be affected by data noise. The parameters of the methods based on machine learning and deep learning are too random, the prediction time is long, and the accuracy of the prediction results is often not high. The temporal convolutional network (TCN) captures the time characteristics of the time series through convolution, and TCN can capture the complex combination pattern of the time series and is robust to time delay. The TCN network is based on one-dimensional convolution, combined with causal convolution and dilated convolution, and residual links are added to improve model performance. It is one of the most widely used neural network models. Since the load curve data samples are time series data, it is reliable to select TCN time convolution network to predict the load. However, the convolution kernel size and number of convolution kernels of TCN time convolution network are artificially or randomly assigned, which will cause large error fluctuations in its prediction results. Therefore, the present invention proposes a CPO algorithm to optimize the convolution kernel size and number of convolution kernels of TCN neural network to reduce the error range of its prediction results and improve the prediction accuracy.
[0003] The CPO algorithm (Crested Porcupine Optimizer, CPO) is an intelligent optimization algorithm that changes the position of the CP due to the mutual influence between the CP and the hunter. The CPO algorithm has four strategies: visual strategy and sound strategy with global search capabilities, and odor strategy and physical attack strategy with local search capabilities. It moves through different intervals between the CP and the hunter's position and different behaviors of the hunter's CP, and updates the position of the CP until it moves to the global optimal position. Moreover, the improved CPO algorithm has a fast convergence speed, strong local fine search capabilities, and can better achieve the global optimal.
[0004] Therefore, how to apply the improved CPO algorithm to load forecasting and solve the problem that neural network prediction is too random is currently in urgent need of being solved. Summary of the invention
[0005] The purpose of the present invention is to overcome the deficiencies of the prior art and provide a flexible load forecasting method and system based on an improved TCN neural network model that is reasonably designed, accurate, reliable and easy to implement in engineering. The present invention introduces adaptive weight parameters and Cauchy variation factors to further improve the CPO algorithm, which helps to improve the global search capability and local optimization capability of the algorithm, so that it can not only better find the local optimum and the global optimum, but also improve the population diversity and avoid falling into the local minimum through its own cyclic population reduction technology. The improved CPO algorithm solves the problem of a large error interval of the prediction result caused by the randomness of the TCN neural network model.
[0006] The technical solution adopted by the present invention is: a flexible load forecasting method based on an improved TCN neural network model, comprising the following steps:
[0007] Step S1. Select a historical period with similar influencing factors to the day to be tested, take it as a historical similar day, take the data of the historical similar day as a data sample, pre-process the data sample, and divide the pre-processed data into a training set and a test set;
[0008] Step S2. Building a temporal convolutional neural network model;
[0009] Step S3. Optimizing the temporal convolutional neural network model by improving the activation function GELUS to obtain an optimized temporal convolutional neural network model;
[0010] Step S4. Introduce the improved crown porcupine optimization algorithm (CPO) algorithm to perform intelligent parameter optimization on the temporal convolutional neural network model optimized in step S3 until the mean square error value is minimized, and obtain the optimal parameter results of the number of convolution kernels and the size of the convolution kernels;
[0011] Step S5. According to the optimal parameter results, training set and test set, the optimized temporal convolutional neural network model is trained to obtain the CPO-TCN load forecasting model;
[0012] Step S6: Use the CPO-TCN load forecasting model to predict the user's future load curve.
[0013] The data preprocessing in step S1 is specifically as follows:
[0014] The data sample consists of the total load consumption and six factors affecting the load. After the data sample is completed using the Newton interpolation method, the k groups of data columns are expressed as:
[0015] Z k =[Z k (1),Z k(2),Z k (3),Z k (4),Z(5),Z k (6),Z k (7)](Z k (i)>0k=1,…,n,i=1,…,7);
[0016] In the formula, Z k (1) represents the day type of the kth group of data, Z k (2) represents the temperature and Z of the kth group of data k (3) represents the humidity of the kth group of data, Z k (4) represents the wind speed, Z of the kth group of data k (5) represents the weather of the kth group of data, Z k (6) represents the time-of-use electricity price of the kth group of data, Z k (7) represents the total load consumption of the kth group of data;
[0017] The completed data is normalized using the normalization function.
[0018] The formula for Newton interpolation is:
[0019] P n (x)=a0+a1(x-x0)+a2(x-x0)(x-x1)+···+a n (x-x0)(x-x1)···(xx n-1 )
[0020] The interpolation node x is the historical data of the total load consumption and its influencing factors, ɑ is the difference quotient, and the formula is expressed as:
[0021]
[0022] Newton interpolation constructs a polynomial function from known data points to infer unknown data points.
[0023] The completed data is normalized using a normalization function, specifically:
[0024] Use the normalization function to normalize n groups of data columns and map the data values to [0,1];
[0025] The normalization function is:
[0026]
[0027] f(Z k (i)) is the value of each element of the data after normalization; that is, the kth group of data after normalization is
[0028] In step 2, the temporal convolutional neural network model consists of a one-dimensional full convolution, a causal convolution, a dilated convolution, and a residual block;
[0029] The one-dimensional full convolution makes the input and output of the previous and next network layers keep the same length by padding with zeros;
[0030] Causal convolution makes the output at time t in the sequence model only related to the elements at time (t-1) or before time (t-1), and the data after time t will not interfere with the learning of features;
[0031] The dilated convolution introduces a preset dilation rate to expand the convolution receptive field;
[0032] The residual block is used to replace the convolutional layer to prevent the network gradient from exploding or disappearing;
[0033] The residual block is encapsulated by one-dimensional full convolution, causal convolution and void convolution. The residual block also contains the ReLU function.
[0034] Step 2 also includes setting the basic parameters of the temporal convolutional neural network model, specifically:
[0035] Step S2.1, set the number of residual blocks, the number of convolutional layers in each residual block, and the basic parameters of each convolution layer;
[0036] Step S2.2, setting the convolution layer parameters, including the convolution kernel size, step size, and dilation factor of the convolution layer;
[0037] Step S2.3, construct residual blocks, select the number of convolutional layer stacking layers, select activation functions, Dropout and batch normalization;
[0038] Step S2.4, set the length of input and output sequences, learning rate, and optimizer.
[0039] Step S3 is specifically as follows:
[0040] The GELU function with an exponential correction unit is selected to replace the ReLU activation function in the residual block, and all values on the negative axis are set to 0. Compared with the ReLU function, the GELU function has a non-zero gradient in the negative value area, so that part of the value on the negative axis can be retained, thereby avoiding the problem of dead neurons.
[0041] Step S4 includes the following steps:
[0042] Step 4.1: Update the initial value of the population, including the learning rate parameter, population size, and maximum number of iterations T max and the trade-off percentage τf between the third and fourth defense mechanisms;
[0043] Candidate solutions for the i-th CP position in the search space It is expressed as:
[0044]
[0045] Among them, N is the number of populations, and are the lower and upper limits of the search range, respectively. is a random number between 0 and 1.
[0046] Step 4.2: Calculate the fitness of each search space; initialize iteration t = 1 until the stopping criterion t>T is met max ;
[0047] Step 4.3: When the CPO algorithm is running, its defense mechanism has 2 stages and 4 strategies, and five values τ6, τ7, τ8, τ9 and τ10 between 0 and 1 are randomly generated;
[0048] Step 4.4, if τ8<τ9, the CPO algorithm will execute the first phase of the exploration phase, which includes two strategies, namely the visual strategy and the sound strategy. When τ6<τ7, the visual defense strategy of the exploration phase is executed. When the crested porcupine CP realizes the predator, it starts to raise and fan its feathers, giving people the impression that it is larger. At this time, after t+1 iterations, the CP individual position migration operator It is expressed as:
[0049]
[0050] In the formula is the optimal position of CP at the tth iteration, is a vector generated between the current CP and a randomly selected CP from the population, used to represent the position of the predator at the tth iteration, τ1 is a random number based on a normal distribution, τ2 is a random value in the interval [0, 1], represents the position of the i-th pig at the current t iteration, indicating that when the visual strategy is executed, the position of the CP will move to the position of the t+1 iteration, generating The expression is:
[0051]
[0052] Where r is a random number between [1, N];
[0053] When τ6>τ7, the sound defense strategy of the exploration phase is executed. The CP uses sound to make noise and threaten the predator. At this time, after t+1 iterations, the CP individual position migration operator It is expressed as:
[0054]
[0055] where r1 and r2 are two random integers between [1, N], represents the position of two randomly selected CPs, τ3 is a random value generated between 0 and 1, It simulates the effect of the sound emitted by CP on the distance between the predator and CP. represents the position of the i-th pig at the current t iterations, Indicates the position relationship of the predator relative to the current CP;
[0056] Step 4.5, if τ8>τ9, the CPO algorithm will execute the second stage of development, which also includes two strategies, namely the odor strategy and the physical attack strategy. When τ10<τf, the odor defense strategy of the development stage is executed. The CP will secrete a foul odor, which will spread in the surrounding area to prevent predators from approaching it. At this time, after t+1 iterations, the CP individual position migration operator is expressed as:
[0057]
[0058] Where r3 is a random integer between [1, N], δ is a parameter used to control the search direction, is the position of the ith individual at iteration t, y t is the defense factor, τ3 is a random value in the interval [0, 1], is the odor diffusion factor, It simulates the effect of the distance between CP and predator on the odor emitted by CP. The direction parameter δ and the defense factor y are t , Odor diffusion factor It is represented by the following operator:
[0059]
[0060] where rand is a variable that contains a randomly generated number between 1 and 0. represents the objective function value of the i-th individual at the t-th iteration, is the odor diffusion factor, T max is the maximum number of iterations, t is the current number of iterations, and c is a small value that avoids division by zero;
[0061] When τ10>τf, the physical attack strategy of the development stage is executed. When the predator is very close, the CP will take physical attack and attack it with short and thick feathers. At this time, the individual position migration operator of the CP after t+1 iterations is expressed as:
[0062]
[0063] in is the best position of CP at the current t iterations, α is the convergence speed factor, τ4 and τ5 are random values in the interval [0,1], is the influence factor of the average force between the ith predator and the CP, provided by the law of inelastic collision and defined by the following formula:
[0064]
[0065] Where m i is the mass of the ith individual at iteration t, is the final velocity of the ith individual at the next iteration t+1, is the initial velocity of the ith individual at iteration t, is a vector of random values generated between 0 and 1;
[0066] Step 4.6: Use the cyclic population reduction technique CPR to remove some CPs from the population during the optimization process to speed up convergence, and reintroduce them into the population to improve diversity and avoid falling into local minima.
[0067] Step 4.7: Use a smaller adaptive weight to change the position of the optimal CP individual at this time. When the predator approaches the CP individual, the local optimization ability of the CPO algorithm is improved. The adaptive weight formula is as follows:
[0068]
[0069] Where t is the current number of iterations, and Tmax is the maximum number of iterations or the upper limit of the function evaluation times.
[0070] The improved CP individual position migration operator is expressed as:
[0071]
[0072] Step 4.8: Perform Cauchy mutation on the five CP individuals with the lowest fitness, and then arrange the CP individuals from high to low according to fitness, replace the CP individuals with low fitness with the CP individuals with high fitness, and use the replaced population as the initial population for the next iteration, so that the algorithm can better reach the global optimum;
[0073] Step 4.9. The parameters of the convolution kernel size and the number of convolution kernels in the optimized temporal convolutional neural network model are taken as a crested porcupine individual. A group of crested porcupines represents a combination of different values of the convolution kernel size and the number of convolution kernels. The positions of the crested porcupines are changed through iterative optimization of the CPO algorithm. Finally, the crested porcupine individual with the best position and the value with the smallest mean square error are output, which is the optimal solution for the convolution kernel size and the number of convolution kernels.
[0074] Step S6 is specifically as follows:
[0075] The historical time periods with similar influencing factors to those of the day to be tested are screened out and used as historical similar days. The data of historical similar days and the data of the day to be tested are input into the time convolutional network model with optimized parameters after data completion and normalization. The basic load and demand response load are predicted respectively, and the prediction results are obtained by denormalization after prediction. The prediction results of the two parts are then added together to obtain the final result using the global optimal parameters of the improved CPO algorithm, and the prediction curve is output.
[0076] A flexible load forecasting system based on an improved TCN neural network model for implementing claim 1, comprising:
[0077] A parameter extraction preprocessing module, wherein the parameter extraction preprocessing module is used to select a historical period with similar influencing factors to the day to be tested, take it as a historical similar day, take the data of the historical similar day as a data sample, preprocess the data sample, and divide the preprocessed data into a training set and a test set;
[0078] A model building module, wherein the model building module is used to build a temporal convolutional neural network model;
[0079] A model optimization module, wherein the model optimization module is used to optimize the temporal convolutional neural network model by improving the activation function GELUS to obtain an optimized temporal convolutional neural network model;
[0080] An intelligent optimization module, which is used to introduce an improved CPO algorithm to perform intelligent optimization of parameters on the temporal convolutional neural network model optimized in step S3 until the mean square error value is minimized, thereby obtaining the optimal parameter results of the number of convolution kernels and the size of the convolution kernels;
[0081] A training module, wherein the training module is used to train the optimized temporal convolutional neural network model according to the optimal parameter results, the training set and the test set to obtain a CPO-TCN load forecasting model;
[0082] The test module is used to use the CPO-TCN load forecasting model to predict the user's future load curve.
[0083] A non-volatile computer storage medium stores computer executable instructions, and the computer executable instructions can execute a flexible load forecasting method based on an improved TCN neural network model described in the above scheme.
[0084] An electronic device comprises: at least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and is characterized in that the instructions are executed by the at least one processor so that the at least one processor can execute a flexible load forecasting method based on an improved TCN neural network model as described in the above scheme.
[0085] The deep learning method adopted in the present invention can solve the problems existing in the above methods, and make a prediction of future load data based on the user's historical load data, which can be used as a reference for power grids and other power regulation industries when there is a demand for power regulation. At the same time, in view of the low efficiency of the traditional method of traversing all hyperparameter combinations of the network using the grid search method, this paper adopts the intelligent optimization algorithm CPO to optimize the number and size of the convolution kernels of the TCN network, which can improve efficiency and accuracy.
[0086] The present invention applies the CPO algorithm to the TCN neural network model, reduces the randomness of the prediction of a single TCN neural network model, narrows the prediction error range, and makes the TCN model prediction more accurate. The method is relatively simple and the prediction effect is better. Since the load curve data sample is time series data, the time convolution neural network TCN with time series data processing capability has a higher training accuracy, a more stable process and a shorter training time during the training process, which can greatly improve the accuracy and speed of future power load prediction.
[0087] The present invention will introduce the superior CPO algorithm (Crested Porcupine Optimizer, CPO) into the TCN time convolutional neural network to optimize the convolution kernel size and number of convolution kernel parameters of the convolution network when solving problems such as flexible load prediction of power systems. It proposes to optimize the TCN time convolutional network model based on the CPO algorithm, and use the mean square error between the predicted value and the actual value as the objective function of the CPO algorithm. The objective function is optimally solved by the CPO algorithm, and the position of the optimal CP at this time is changed by introducing a smaller adaptive weight, so that the local optimization ability of the CPO algorithm is improved. The Cauchy mutation operation is introduced to increase the disturbance so that the algorithm can better reach the global optimum. The cyclic population reduction technology (CPO) is introduced to speed up the convergence speed, improve the population diversity and avoid falling into the local minimum. At the same time, the activation function of TCN is improved to the activation function GELUS, which avoids the problem of dead neurons and makes the neural network easier to converge during the training process. The present invention applies the improved CPO algorithm to the TCN temporal convolutional network model, which solves the problem of large error interval of prediction results caused by the randomness of a single TCN temporal convolutional network model, and also improves the fitting degree and prediction accuracy of the TCN temporal convolutional network. The method is relatively simple and has better prediction effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0088] Figure 1 This is a flow chart of the load forecasting method based on the CPO algorithm to optimize the TCN neural network model of the present invention. DETAILED DESCRIPTION
[0089] The embodiments of the present invention are further described in detail below with reference to the accompanying drawings.
[0090] The present invention integrates the CPO algorithm with the TCN temporal convolutional neural network model, optimizes the two parameters of the convolution model, the number of convolution kernels and the size of the convolution kernels, takes the mean square error function as the objective function of the CPO algorithm, and applies the improved CPO algorithm to the TCN temporal convolutional neural network model, thereby solving the problem of a large error interval in the prediction results caused by the randomness of the single TCN temporal convolutional network model, and also improving the fitting degree and prediction accuracy of the TCN temporal convolutional network. The method is relatively simple and has better prediction effect.
[0091] In the CPO algorithm of the present invention, the position of each CP is a potential solution that satisfies the objective function. The position of the CP in the population is updated by executing four strategies in two stages. The Cauchy mutation operation is introduced to increase disturbance so that the algorithm can better reach the global optimum. The cyclic population reduction technology CPR is introduced to accelerate the convergence speed, improve the population diversity and avoid falling into the local minimum. A smaller adaptive weight is introduced to change the position of the optimal CP at this time, so that the local optimization ability of the CPO algorithm is improved. The optimal CP individual in each iteration will be recorded, and finally the individual with the best fitness is selected from the optimal individuals in each iteration, so as to achieve the optimization purpose.
[0092] Based on the above design concept, the present invention proposes a flexible load forecasting method and system based on an improved TCN neural network model. Figure 1 As shown, the following steps are included:
[0093] Step S1. Take the historical period with similar influencing factors as the day to be tested as the historical similar day, input the data day type, temperature, humidity, wind speed, weather of the historical similar day load, and input the day type and electricity price impact of the demand response load as data samples, and divide the data samples into training set and test set after preprocessing;
[0094] The data preprocessing is as follows: use Newton interpolation method to process outliers and missing values of the original data, expand the samples, and then perform normalization processing, and divide the normalized data samples into training sets and test sets;
[0095] The Newton interpolation formula is:
[0096] P n (x)=a0+a1(x-x0)+a2(x-x0)(x-x1)+···+a n (x-x0)(x-x1)···(xx n-1 )
[0097] The interpolation node x is the historical data of the total load consumption and its influencing factors, ɑ is the difference quotient, and the formula is expressed as:
[0098]
[0099] This method constructs a polynomial function through known data points to infer unknown data points and expand the data sample;
[0100] For the total load consumption and its six influencing factors, after the data samples are completed using the Newton interpolation method, the k-group data column Z k =[Z k (1),Z k (2),Zk (3),Z k (4),Z(5),Z k (6),Z k (7)](Z k (i)>0 k=1,…,n,i=1,…,7);
[0101] In the formula, Z k (1) represents the day type of the kth group of data, such as working days, holidays, or weekends, etc. k (2) represents the temperature and Z of the kth group of data k (3) represents the humidity of the kth group of data, Z k (4) represents the wind speed, Z of the kth group of data k (5) represents the weather of the kth group of data, Z k (6) represents the time-of-use electricity price of the kth group of data, Z k (7) represents the total load consumption of the kth group of data, takes part of the n-group data column as the training set, and the remaining data column is divided into the test set, and uses the normalization function to normalize the n-group data column to map the data value to [0,1];
[0102] The normalization function is:
[0103]
[0104] f(Z k (i)) is the value of each element of the data after normalization; that is, the kth group of data after normalization is
[0105] Step S2. Set the basic parameters of the TCN network and build a temporal convolutional neural network model;
[0106] The temporal convolutional neural network model consists of one-dimensional full convolution, causal convolution, dilated convolution, and residual blocks;
[0107] The one-dimensional full convolution makes the input and output of the previous and next network layers keep the same length by padding with zeros;
[0108] Causal convolution makes the output at time t in the sequence model only related to the elements at time (t-1) or before time (t-1), and the data after time t will not interfere with the learning of features;
[0109] The dilated convolution introduces a preset dilation rate to expand the convolution receptive field;
[0110] The residual block is used to replace the convolutional layer to prevent the network gradient from exploding or disappearing;
[0111] The residual block is encapsulated by one-dimensional full convolution, causal convolution and void convolution. The residual block also contains the ReLU function.
[0112] Set the basic parameters of the temporal convolutional neural network model, specifically:
[0113] Step S2.1, set the number of residual blocks, the number of convolutional layers in each residual block, and the basic parameters of each convolution layer;
[0114] Step S2.2, setting the convolution layer parameters, including the convolution kernel size, step size, and dilation factor of the convolution layer;
[0115] Step S2.3, construct residual blocks, select the number of convolutional layer stacking layers, select activation functions, Dropout and batch normalization;
[0116] Step S2.4, set the length of input and output sequences, learning rate, and optimizer.
[0117] The specific values of the above parameters are adjusted according to the situation. For the existing technology, the following is the general situation of parameter settings. Convolution kernel size: usually choose a smaller convolution kernel, 3x3 or 5x5
[0118] The step size is usually set to 1
[0119] The dilation factor is used to expand the receptive field of the convolution kernel. The value is usually 1 and then gradually increases.
[0120] The Dropout ratio is usually set between 0.2 and 0.5
[0121] The learning rate starts from 0.001.
[0122] The optimizer Adam used in this article is a widely used optimizer
[0123] There are no specific requirements for residual blocks
[0124] The number of convolutional layers within the modules are 3, 4, and 6 respectively.
[0125] Step S3. Optimizing the temporal convolutional neural network model by improving the activation function GELUS to obtain an optimized temporal convolutional neural network model;
[0126] Select the exponential correction unit GELU instead of the ReLU activation function; among them,
[0127] The exponential correction unit GELU function has a non-zero gradient in the negative region, thereby avoiding the problem of dead neurons. In addition, GELU is smoother than ReLU near 0, so it is easier to converge during training.
[0128] Step S4. Introduce the improved CPO algorithm to perform intelligent parameter optimization on the temporal convolutional neural network model to obtain the optimal parameter results of the number of convolution kernels and the size of the convolution kernels;
[0129] Step 4.1, update the initial values of the CPO population: learning rate parameter ɑ, population size N, maximum number of iterations T, and the trade-off percentage τf between the third and fourth defense mechanisms; at this time, the candidate solution for the i-th CP position in the search space is for:
[0130]
[0131] Among them, N is the number of populations, and are the lower and upper limits of the search range, respectively. is a random number between 0 and 1.
[0132] Step 4.2: Calculate the fitness of each search agent; initialize iteration t = 1 until the stopping criterion t>T is met max ; Then, the CP with the highest fitness is selected from the optimal CP individuals in each iteration as the final output after optimization.
[0133] Step 4.3: When the CPO algorithm is running, its defense mechanism has 2 stages and 4 strategies, and five values τ6, τ7, τ8, τ9 and τ10 between 0 and 1 are randomly generated;
[0134] Step 4.4, if τ8<τ9, the CPO algorithm will execute the first phase of the exploration phase, which contains two strategies, namely the visual strategy and the sound strategy. When τ6<τ7, the visual defense strategy of the exploration phase is executed. When the CP realizes the predator, it starts to raise and flap its feathers, giving people the impression that it is larger. At this time, after t+1 iterations, the CP individual position migration operator It is expressed as:
[0135]
[0136] In the formula is the optimal position of CP at the tth iteration, is a vector generated between the current CP and a randomly selected CP from the population, used to represent the position of the predator at the tth iteration, τ1 is a random number based on a normal distribution, τ2 is a random value in the interval [0, 1], represents the position of the i-th pig at the current t iteration, indicating that when the visual strategy is executed, the position of the CP will move to the position of the t+1 iteration, generating The mathematical formula is as follows:
[0137]
[0138] Where r is a random number between [1, N].
[0139] When τ6>τ7, the sound defense strategy of the exploration phase is executed. The CP uses sound to make noise to threaten the predator. When the predator approaches the CP, the CP's sound will become louder. Mathematically simulating this behavior, after t+1 iterations, the CP individual position migration operator It is expressed as:
[0140]
[0141] where r1 and r2 are two random integers between [1, N], represents the position of two randomly selected CPs, τ3 is a random value generated between 0 and 1, represents the position of the i-th pig at the current t iterations, represents the position of the predator relative to the current CP, It simulates the effect of the sound emitted by CP on the distance between the predator and CP. The effect of the sound is divided into three cases: the first case is The sound is weak, so the predator continues to move toward the CP; the second case is that the sound is slightly louder, Between 0 and 1, the predator might stand still; at the end, it's very loud, The predator will move away out of fear.
[0142] Step 4.5, if τ8>τ9, the CPO algorithm will execute the second stage of development, which also includes two strategies, namely the odor strategy and the physical attack strategy. When τ10<τf, the odor defense strategy of the development stage is executed. The CP will secrete a foul odor, which will spread in the surrounding area to prevent predators from approaching it. At this time, after t+1 iterations, the CP individual position migration operator is expressed as:
[0143]
[0144] Where r3 is a random integer between [1, N], δ is a parameter used to control the search direction, is the position of the ith individual at iteration t, y t is the defense factor, τ3 is a random value in the interval [0, 1], is the odor diffusion factor, It simulates the effect of the distance between CP and predator on the odor emitted by CP. The effect of odor is divided into three cases: the first case is CP will stop the scent diffusion because the predator will stop moving due to fear of CP, so the distance between the predator and CP remains unchanged; the second case is Between 0 and 1, the predator keeps a safe distance from the CP, so there is no need to release its scent extensively; and finally Since the predator is nearby, the CP will emit a significant scent, where the direction parameter δ and the defense factor y t , Odor diffusion factor It is represented by the following operator:
[0145]
[0146] where rand is a variable that contains a randomly generated number between 1 and 0. represents the objective function value of the i-th individual at the t-th iteration, is the odor diffusion factor, T max is the maximum number of iterations, t is the current number of iterations, c is a small value to avoid division by zero, is the odor diffusion factor and N is the population size.
[0147] When τ10>τf, the physical attack strategy of the development phase is executed. When the predator is very close, the CP will take physical attack and attack it with short and thick feathers. During the physical attack, the two objects merge strongly, representing a one-dimensional inelastic collision. At this time, the CP individual position migration operator after t+1 iterations is expressed as:
[0148]
[0149] in is the best position of CP at the tth iteration so far, α is the convergence speed factor discussed later in the parameter setting section, τ4 and τ5 are random values in the interval [0,1], represents the position of the i-th pig at the current t iteration, y t It is a defense factor. is the influence factor of the average force between the ith predator and the CP, which is provided by the law of inelastic collision and defined by the following formula:
[0150]
[0151] Where m i is the mass of the i-th individual (predator) at iteration t, is the influencing factor of the average force between the i-th predator and CP, is the final velocity of the ith individual at the next iteration t+1, is the initial velocity of the ith individual at iteration t, is a vector of random values generated between 0 and 1.
[0152] Step 4.6: Not all CPs will activate the defense mechanism, but only those CPs that are threatened will activate the defense mechanism. Therefore, the cyclic population reduction technique (CPR) is used to remove some CPs from the population during the optimization process to speed up the convergence, and reintroduce them into the population to improve diversity and avoid falling into local minima. The cyclic population reduction technique is defined by the following formula:
[0153]
[0154] Where T is a variable that determines the number of loops, t is the current function evaluation, and T max is the maximum number of function evaluations, % represents the remainder or modulo operator, N min is the minimum number of individuals in the newly generated population, so the population size cannot be less than N min As the number of current function evaluations increases, the size of the CPO gradually decreases until it reaches N min This represents the first cycle. Afterwards, the population size is maximized again and then gradually decreases until it reaches the end of the optimization process.
[0155] Step 4.7: Use a smaller adaptive weight to change the position of the optimal CP at this time. When the predator approaches the CP, the local optimization ability of the CPO algorithm is improved. The adaptive weight formula is as follows:
[0156]
[0157] Where t is the current number of iterations, and Tmax is the maximum number of iterations or the upper limit of the function evaluation times.
[0158] The improved CP individual position migration operator is expressed as:
[0159]
[0160] By integrating the adaptive weight factor ω, the CP individuals have better local optimization capabilities.
[0161] Step 4.8: Perform Cauchy mutation on the five CP individuals with the lowest fitness, and then arrange the CP individuals from high to low according to fitness, replace the CP individuals with low fitness with the CP individuals with high fitness, and use the replaced population as the initial population for the next iteration, so that the algorithm can better reach the global optimum;
[0162] The five CP individuals with the worst fitness in the population are subjected to Cauchy mutation in the following way:
[0163]
[0164] in, is the CP individual i generated in the tth iteration, w(worst) represents the CP with low fitness, Cauchy(0,1) is the Cauchy random variable generating function, Cauchy(0,1)=tan(π(ε-0.5)), ε is a random real number uniformly distributed between [0, 1].
[0165] Step 4.9. The parameters of the convolution kernel size and the number of convolution kernels in the optimized temporal convolutional neural network model are taken as a crested porcupine individual. A group of crested porcupines represents a combination of different values of the convolution kernel size and the number of convolution kernels. The positions of the crested porcupines are changed through iterative optimization of the CPO algorithm. Finally, the crested porcupine individual with the best position and the value with the smallest mean square error are output, which is the optimal solution for the convolution kernel size and the number of convolution kernels.
[0166] Step S5. According to the optimal parameter results, training set and test set, the optimized temporal convolutional neural network model is trained to obtain the CPO-TCN load forecasting model;
[0167] Step 6. Filter out historical time periods with similar influencing factors to the day to be tested, and use them as historical similar days. After data completion and normalization, the data of historical similar days and the data of the day to be tested are input into the time convolutional network model with optimized parameters. The basic load and demand response load are predicted separately. After the prediction, they are denormalized to obtain the prediction results. The prediction results of the two parts are then added together to obtain the final result using the global optimal parameters of the improved CPO algorithm, and the prediction curve is output.
[0168] The present invention applies the CPO algorithm to the TCN neural network model, reduces the randomness of the prediction of a single TCN neural network model, narrows the prediction error range, and makes the TCN model prediction more accurate. The method is relatively simple and the prediction effect is better. Since the load curve data sample is time series data, the time convolutional neural network with time series data processing capability has a higher training accuracy, a more stable process and a shorter training time during the training process, which can greatly improve the accuracy and speed of future power load prediction.
[0169] Another aspect of the present invention provides a flexible load forecasting system based on an improved TCN neural network model, comprising:
[0170] A parameter extraction preprocessing module, wherein the parameter extraction preprocessing module is used to select a historical period with similar influencing factors to the day to be tested, take it as a historical similar day, take the data of the historical similar day as a data sample, preprocess the data sample, and divide the preprocessed data into a training set and a test set;
[0171] A model building module, wherein the model building module is used to build a temporal convolutional neural network model;
[0172] A model optimization module, wherein the model optimization module is used to optimize the temporal convolutional neural network model by improving the activation function GELUS to obtain an optimized temporal convolutional neural network model;
[0173] An intelligent optimization module, which is used to introduce an improved CPO algorithm to perform intelligent optimization of parameters on the temporal convolutional neural network model optimized in step S3 until the mean square error value is minimized, thereby obtaining the optimal parameter results of the number of convolution kernels and the size of the convolution kernels;
[0174] A training module, wherein the training module is used to train the optimized temporal convolutional neural network model according to the optimal parameter results, the training set and the test set to obtain a CPO-TCN load forecasting model;
[0175] The test module is used to use the CPO-TCN load forecasting model to predict the user's future load curve.
[0176] On the other hand, the present invention also provides a non-volatile computer storage medium, which stores computer executable instructions. The computer executable instructions can execute the flexible load forecasting method based on the improved TCN neural network model described in the above scheme.
[0177] On the other hand, the present invention also provides an electronic device, comprising: at least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and is characterized in that the instructions are executed by the at least one processor so that the at least one processor can execute a flexible load forecasting method based on an improved TCN neural network model as described in the above scheme.
Claims
1. A flexible load forecasting method based on an improved TCN neural network model, characterized in that: The following steps are involved: Step S1. Select a historical period with similar influencing factors to the day to be tested, take it as a historical similar day, take the data of the historical similar day as a data sample, pre-process the data sample, and divide the pre-processed data into a training set and a test set; Step S2. Building a temporal convolutional neural network model; Step S3. Optimizing the temporal convolutional neural network model by improving the activation function GELUS to obtain an optimized temporal convolutional neural network model; Step S4. Introduce the improved crown porcupine optimization algorithm (CPO) algorithm to perform intelligent parameter optimization on the temporal convolutional neural network model optimized in step S3 until the mean square error value is minimized, and obtain the optimal parameter results of the number of convolution kernels and the size of the convolution kernels; Step S5. According to the optimal parameter results, training set and test set, the optimized temporal convolutional neural network model is trained to obtain the CPO-TCN load forecasting model; Step S6: Use the CPO-TCN load forecasting model to predict the user's future load curve.
2. According to claim 1, a flexible load forecasting method based on an improved TCN neural network model is characterized in that: The data preprocessing in step S1 is specifically as follows: The data sample consists of the total load consumption and six factors affecting the load. After the data sample is completed using the Newton interpolation method, the k groups of data columns are expressed as: WITH k =[From k (1),From k (2),With k (3),With k (4),From(5),From k (6),With k (7)](From k (i)>0 k=1,…,n,i=1,…,7); In the formula, Z k (1) represents the day type of the kth group of data, Z k (2) represents the temperature and Z of the kth group of data k (3) represents the humidity of the kth group of data, Z k (4) represents the wind speed, Z of the kth group of data k (5) represents the weather of the kth group of data, Z k (6) represents the time-of-use electricity price of the kth group of data, Z k (7) represents the total load consumption of the kth group of data; The completed data is normalized using the normalization function.
3. The flexible load forecasting method based on the improved TCN neural network model according to claim 2 is characterized in that: The formula for Newton interpolation is: P n (x)=a0+a1(x-x0)+a2(x-x0)(x-x1)+···+a n (x-x0)(x-x1)···(xx n-1 ) The interpolation node x is the historical data of the total load consumption and its influencing factors, ɑ is the difference quotient, and the formula is expressed as:
4. The flexible load forecasting method based on the improved TCN neural network model according to claim 2 is characterized in that: The completed data is normalized using a normalization function, specifically: Use the normalization function to normalize n groups of data columns and map the data values to [0,1]; The normalization function is: f(Z k (i)) is the value of each element of the data after normalization; that is, the kth group of data after normalization is 5. The flexible load forecasting method based on the improved TCN neural network model according to claim 1 is characterized in that: In step 2, the temporal convolutional neural network model consists of a one-dimensional full convolution, a causal convolution, a dilated convolution, and a residual block; The one-dimensional full convolution makes the input and output of the previous and next network layers keep the same length by padding with zeros; Causal convolution makes the output at time t in the sequence model only related to the elements at time (t-1) or before time (t-1), and the data after time t will not interfere with the learning of features; The dilated convolution introduces a preset dilation rate to expand the convolution receptive field; The residual block is used to replace the convolutional layer to prevent the network gradient from exploding or disappearing; The residual block is encapsulated by one-dimensional full convolution, causal convolution and void convolution. The residual block also contains the ReLU function.
6. The flexible load forecasting method based on the improved TCN neural network model according to claim 1 or 5, characterized in that: Step 2 also includes setting the basic parameters of the temporal convolutional neural network model, specifically: Step S2.1, set the number of residual blocks, the number of convolutional layers in each residual block, and the basic parameters of each convolution layer; Step S2.2, setting the convolution layer parameters, including the convolution kernel size, step size, and dilation factor of the convolution layer; Step S2.3, construct residual blocks, select the number of convolutional layer stacking layers, select activation functions, Dropout and batch normalization; Step S2.4, set the length of input and output sequences, learning rate, and optimizer.
7. The flexible load forecasting method based on the improved TCN neural network model according to claim 1 is characterized in that: Step S3 is specifically as follows: The GELU function with an exponential correction unit is selected to replace the ReLU activation function in the residual block, and all values on the negative axis are set to 0. Compared with the ReLU function, the GELU function has a non-zero gradient in the negative value area, so that part of the value on the negative axis can be retained, thereby avoiding the problem of dead neurons.
8. The flexible load forecasting method based on the improved TCN neural network model according to claim 1 is characterized in that: Step S4 includes the following steps: Step 4.1: Update the initial value of the population, including the learning rate parameter, population size, and maximum number of iterations T max and the trade-off percentage τf between the third and fourth defense mechanisms; Candidate solutions for the i-th CP position in the search space It is expressed as: Where N is the population size, and are the lower and upper limits of the search range, respectively. is a random number between 0 and 1. Step 4.2: Calculate the fitness of each search space; initialize iteration t = 1 until the stopping criterion t>T is met max ; Step 4.3: When the CPO algorithm is running, its defense mechanism has 2 stages and 4 strategies, and five values τ6, τ7, τ8, τ9 and τ10 between 0 and 1 are randomly generated; Step 4.4, if τ8<τ9, the CPO algorithm will execute the first phase of the exploration phase, which includes two strategies, namely the visual strategy and the sound strategy. When τ6<τ7, the visual defense strategy of the exploration phase is executed. When the crested porcupine CP realizes the predator, it starts to raise and fan its feathers, giving people the impression that it is larger. At this time, after t+1 iterations, the CP individual position migration operator It is expressed as: In the formula is the optimal position of CP at the tth iteration, is a vector generated between the current CP and a randomly selected CP from the population, used to represent the position of the predator at the tth iteration, τ1 is a random number based on a normal distribution, τ2 is a random value in the interval [0, 1], represents the position of the i-th pig at the current t iteration, indicating that when the visual strategy is executed, the position of the CP will move to the position of the t+1 iteration, generating The expression is: Where r is a random number between [1, N]; When τ6>τ7, the sound defense strategy of the exploration phase is executed. The CP uses sound to make noise and threaten the predator. At this time, after t+1 iterations, the CP individual position migration operator It is expressed as: where r1 and r2 are two random integers between [1, N], represents the position of two randomly selected CPs, τ3 is a random value generated between 0 and 1, It simulates the effect of the sound emitted by CP on the distance between the predator and CP. represents the position of the i-th pig at the current t iterations, Indicates the position relationship of the predator relative to the current CP; Step 4.5, if τ8>τ9, the CPO algorithm will execute the second stage of development, which also includes two strategies, namely the odor strategy and the physical attack strategy. When τ10<τf, the odor defense strategy of the development stage is executed. The CP will secrete a foul odor, which will spread in the surrounding area to prevent predators from approaching it. At this time, after t+1 iterations, the CP individual position migration operator is expressed as: Where r3 is a random integer between [1, N], δ is a parameter used to control the search direction, is the position of the ith individual at iteration t, y t is the defense factor, τ3 is a random value in the interval [0, 1], is the odor diffusion factor, It simulates the effect of the distance between CP and predator on the odor emitted by CP. The direction parameter δ and the defense factor y are t , Odor diffusion factor It is represented by the following operator: where rand is a variable that contains a randomly generated number between 1 and 0. represents the objective function value of the i-th individual at the t-th iteration, is the odor diffusion factor, T max is the maximum number of iterations, t is the current number of iterations, and c is a small value that avoids division by zero; When τ10>τf, the physical attack strategy of the development stage is executed. When the predator is very close, the CP will take physical attack and attack it with short and thick feathers. At this time, the individual position migration operator of the CP after t+1 iterations is expressed as: in is the best position of CP at the current t iterations, α is the convergence speed factor, τ4 and τ5 are random values in the interval [0,1], is the influence factor of the average force between the ith predator and the CP, provided by the law of inelastic collision and defined by the following formula: Where m i is the mass of the ith individual at iteration t, is the final velocity of the ith individual at the next iteration t+1, is the initial velocity of the ith individual at iteration t, is a vector of random values generated between 0 and 1; Step 4.6: Use the cyclic population reduction technique CPR to remove some CPs from the population during the optimization process to speed up convergence, and reintroduce them into the population to improve diversity and avoid falling into local minima. Step 4.7: Use a smaller adaptive weight to change the position of the optimal CP individual at this time. When the predator approaches the CP individual, the local optimization ability of the CPO algorithm is improved. The adaptive weight formula is as follows: Where t is the current number of iterations, and Tmax is the maximum number of iterations or the upper limit of the function evaluation times. The improved CP individual position migration operator is expressed as: Step 4.8: Perform Cauchy mutation on the five CP individuals with the lowest fitness, and then arrange the CP individuals from high to low according to fitness, replace the CP individuals with low fitness with the CP individuals with high fitness, and use the replaced population as the initial population for the next iteration, so that the algorithm can better reach the global optimum; Step 4.
9. The parameters of the convolution kernel size and the number of convolution kernels in the optimized temporal convolutional neural network model are taken as a crested porcupine individual. A group of crested porcupines represents a combination of different values of the convolution kernel size and the number of convolution kernels. The positions of the crested porcupines are changed through iterative optimization of the CPO algorithm. Finally, the crested porcupine individual with the best position and the value with the smallest mean square error are output, which is the optimal solution for the convolution kernel size and the number of convolution kernels.
9. The flexible load forecasting method based on the improved TCN neural network model according to claim 1 is characterized in that: Step S6 is specifically as follows: The historical time periods with similar influencing factors to those of the day to be tested are screened out and used as historical similar days. The data of historical similar days and the data of the day to be tested are input into the time convolutional network model with optimized parameters after data completion and normalization. The basic load and demand response load are predicted respectively, and the prediction results are obtained by denormalization after prediction. The prediction results of the two parts are then added together to obtain the final result using the global optimal parameters of the improved CPO algorithm, and the prediction curve is output.
10. A flexible load forecasting system based on an improved TCN neural network model for implementing claim 1, characterized in that: include: A parameter extraction preprocessing module, wherein the parameter extraction preprocessing module is used to select a historical period with similar influencing factors to the day to be tested, take it as a historical similar day, take the data of the historical similar day as a data sample, preprocess the data sample, and divide the preprocessed data into a training set and a test set; A model building module, wherein the model building module is used to build a temporal convolutional neural network model; A model optimization module, wherein the model optimization module is used to optimize the temporal convolutional neural network model by improving the activation function GELUS to obtain an optimized temporal convolutional neural network model; An intelligent optimization module, which is used to introduce an improved CPO algorithm to perform intelligent optimization of parameters on the temporal convolutional neural network model optimized in step S3 until the mean square error value is minimized, thereby obtaining the optimal parameter results of the number of convolution kernels and the size of the convolution kernels; A training module, wherein the training module is used to train the optimized temporal convolutional neural network model according to the optimal parameter results, the training set and the test set to obtain a CPO-TCN load forecasting model; The test module is used to use the CPO-TCN load forecasting model to predict the user's future load curve.
11. A non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions can execute the flexible load forecasting method based on the improved TCN neural network model described in claims 1-9.
12. An electronic device comprising: At least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, characterized in that the instructions are executed by the at least one processor so that the at least one processor can execute a flexible load forecasting method based on an improved TCN neural network model as described in claims 1-9.
Citation Information
Cited By
Low-voltage power distribution network line loss prediction method, model training method and related device
CN120930887A
A low-voltage power distribution network line loss prediction method, model training method and related device
CN120930887B
Convolutional neural network fish identification method and device based on optimized structure
CN120953767A
Distributed measurement and full-field reconstruction method for deformation gap of large-scale composite part
CN121234641A