Shore power system load prediction method and system based on QPSO-LSTM network
By applying the QPSO-LSTM network in the shore power system and optimizing the parameters of the LSTM network, the deficiencies in the load prediction technology of the shore power system are solved and the prediction effect and performance are improved.
Patent Information
- Application Number
- CN202410735105.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-09-10
AI Technical Summary
Existing shore power system load prediction technology mainly focuses on traditional power systems, lacking load prediction for shore power systems, and the selection of LSTM network parameters relies on human experience, resulting in poor prediction results.
A method based on the QPSO-LSTM network was used to clean and normalize the original shore power system load data. The QPSO algorithm was used to optimize the number of hidden layer nodes, learning rate and training times of the LSTM network, and a QPSO-LSTM network model was constructed. Load forecasting.
By optimizing the LSTM network parameters, the accuracy and performance of shore power system load prediction are improved, the impact of human selection is reduced, and the prediction effect is improved.
Smart Images

Figure CN118627671A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of shore power systems, and in particular to a shore power system load prediction method and system based on a QPSO-LSTM network. Background Art
[0002] When ships are docked at ports, exhaust gas generated by diesel generators can cause pollution. However, using shore power can significantly reduce exhaust emissions. Therefore, promoting the use of shore power by ships is an important measure to protect the global environment. At the same time, port shore power load forecasting is an important part of port microgrid energy management. An accurate load forecast data is of great significance for formulating port microgrid power distribution plans, reducing port microgrid electricity costs, and improving the security of port microgrid systems.
[0003] However, the existing load forecasting technology for shore power systems has the following two problems: First, load forecasting technology is mainly focused on traditional power systems, but there is little load forecasting for shore power systems. With the promotion of shore power in the future and the continuous increase in shore power capacity, load forecasting for shore power systems has become urgent; second, when using LSTM networks for power load forecasting, the LSTM network structure and parameters will have an important impact on the forecast results. For example, the number of hidden layer nodes directly affects the model structure. The number of training times and learning rate will also affect the degree of overfitting of the model. At present, LSTM network parameters are mostly selected based on human experience, which often fails to achieve good forecasting results. Summary of the invention
[0004] The present invention is made to solve the above-mentioned problem, and aims to provide a shore power system load prediction method and system based on QPSO-LSTM network.
[0005] The present invention provides a shore power system load prediction method based on a QPSO-LSTM network, which has the following characteristics: step S1, after data cleaning and normalization preprocessing of the original shore power system load data, the data is divided into training set data and test set data; step S2, the training set data is input into the LSTM network layer for training, and the number of hidden layer nodes L, the learning rate l r The QPSO optimization layer is used to search for the optimal value and the number of network training times K, and the optimal value obtained each time is returned to the LSTM network layer to train the QPSO-LSTM network model; Step S3, the test set data is input into the trained QPSO-LSTM network model, and the final prediction result of the test set data is output by denormalization, and a case comparison analysis between the shore power system load prediction models based on different networks is performed; Step S4, the capability of the shore power system load prediction model based on the QPSO-LSTM network is evaluated according to the above results.
[0006] In the shore power system load prediction method based on the QPSO-LSTM network provided by the present invention, it can also have the following characteristics: wherein, in step S1, the specific process of preprocessing the original shore power system load data is as follows: step S1-1, collecting load data of 18 hours of continuous shore power operation from the shore power system, with a sampling frequency of one sample per minute, to obtain 1080 data samples; step S1-2, preprocessing and normalizing the data samples, removing unreasonable extreme values and replacing unreasonable data with data from the previous moment, and then normalizing all data to a range of 0-1 to obtain sample data; step S1-3, taking the first 70% of the sample data as training set data, and the last 30% as test set data.
[0007] In the shore power system load forecasting method based on the QPSO-LSTM network provided by the present invention, the following features may also be provided: wherein, in step 2, the core of the LSTM network layer is to add and delete the cell state through the gate structure, and an LSTM network contains three gates, namely, a forget gate, an input gate, and an output gate:
[0008] ① The forget gate is responsible for controlling the discarding of redundant information from the unit state information at the previous moment. The calculation formula of the forget gate is as follows:
[0009] f t =σ(W f [h t-1 ,x t ]+b f ) (1)
[0010] Among them, f t represents the output value of the forget gate at time t, σ is the sigmoid activation function, which mainly plays a gating role, and the output is 0 to 1, W f is the weight matrix of the forget gate, h t-1 represents the output and unit state at the previous moment, x t Indicates the input status at the current moment, b f is the bias term of the forget gate;
[0011] ②The input gate is based on h t-1 and x t Add new information to the memory unit. The calculation formula is as follows:
[0012] i t =σ(W i [h t-1 ,x t ]+b i ) (2)
[0013]
[0014] Among them, W i , is the weight matrix of the input gate, b i , is the bias term of the input gate, For the information that needs to be remembered, i t Enter for the current moment;
[0015] ③After the forget gate and output gate are calculated, the update gate updates the memory unit. The calculation formula is as follows:
[0016]
[0017] Among them, C t and C t-1 Respectively represent the unit status at the current moment and the previous moment, represents input gating, Represents the matrix element product;
[0018] ④The output gate determines which state information in the memory unit is used as output. The calculation formula is as follows:
[0019] o t =σ(W o [h t-1 ,x t ]+b o ) (5)
[0020]
[0021] Among them, t Represents the proportionality coefficient of the output information, h t Represents the output at the current moment, W o is the weight matrix of the output gate, b o is the bias term of the output gate, and tanh is the hyperbolic tangent activation function.
[0022] In the shore power system load forecasting method based on the QPSO-LSTM network provided by the present invention, it can also have the following characteristics: wherein, in step S2, the QPSO algorithm only updates the particle position formula without speed update, and its particle position is expressed by the following formula:
[0023]
[0024] Among them, β is the shrinkage expansion coefficient, u is a random number between (0,1), is the average optimal position of particles, Q t is a random point of the particle,
[0025] and Q t It is obtained by the following formula:
[0026]
[0027] Wherein, M is the population size, and α is a random number between (0, 1). In the shore power system load forecasting method based on QPSO-LSTM network provided by the present invention, it can also have the following characteristics: wherein the rotatable base includes support legs and a locking mechanism to ensure the stability of the device.
[0028] In the shore power system load prediction method based on the QPSO-LSTM network provided by the present invention, it can also have the following characteristics: wherein, in step S3, the shore power system load prediction models of different networks include: a shore power system load prediction model based on the QPSO-LSTM network trained using the same training set, a shore power system load prediction model based on the LSTM network, and a shore power system load prediction model based on the particle swarm algorithm to optimize the LSTM network.
[0029] The shore power system load prediction method based on the QPSO-LSTM network provided by the present invention may also have the following characteristics: wherein, in step S4, the root mean square error, the mean absolute error and the mean absolute percentage error are used as evaluation criteria for model prediction, and the calculation method thereof is:
[0030]
[0031] in, is the predicted value; i is the true value; N is the total number,
[0032] The smaller the values of the three evaluation indicators, the better the model prediction performance.
[0033] The present invention provides a shore power system load prediction system based on a QPSO-LSTM network, comprising: a preprocessing unit, which performs data cleaning and normalization preprocessing on the original shore power system load data, and divides the data into training set data and test set data; a training unit, which inputs the training set data into the LSTM network layer for training, and sets the number of hidden layer nodes L, the learning rate l r The QPSO optimization layer is used to search for the optimal value and the number of network training times K, and the optimal value obtained each time is returned to the LSTM network layer to train the QPSO-LSTM network model; the prediction department inputs the test set data into the trained QPSO-LSTM network model, and denormalizes and outputs the final prediction result of the test set data, and conducts case comparison analysis between shore power system load prediction models based on different networks; the evaluation department evaluates the capability of the shore power system load prediction model based on the QPSO-LSTM network according to the above results.
[0034] The present invention provides an electronic device having the following characteristics, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor runs the computer program to implement the shore power system load forecasting method based on the QPSO-LSTM network in the present invention.
[0035] The present invention provides a computer-readable storage medium, which has the following characteristics: the program is executed by a processor to implement the shore power system load forecasting method based on QPSO-LSTM network in the present invention.
[0036] The present invention provides a computer program product having the following features: the computer program is executed by a processor to implement the shore power system load forecasting method based on the QPSO-LSTM network in the present invention.
[0037] Compared with the prior art, the present invention has the following beneficial effects:
[0038] The QPSO algorithm is used to optimize some parameters of the LSTM network to avoid the subjective influence of artificial parameter selection. Then, the shore power system load forecasting model based on the QPSO-LSTM network is constructed according to the optimized optimal parameter combination. Compared with the shore power system load forecasting model based on the LSTM network, all indicators can be effectively improved. Thereby improving the prediction performance of the shore power system load forecasting. This shows that it is feasible to use the QPSO algorithm to optimize the parameters of the LSTM network in the load forecasting work for the shore power system. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 It is a technical flow chart of a shore power system load prediction method based on a QPSO-LSTM network in an embodiment of the present invention;
[0040] Figure 2 is a sample distribution diagram of the shore power system load data divided into training set data and test set data in an embodiment of the present invention;
[0041] Figure 3 It is a QPSO algorithm fitness change diagram in an embodiment of the present invention;
[0042] Figure 4 is a parameter variation diagram of the QPSO algorithm in an embodiment of the present invention;
[0043] Figure 5 It is a case analysis comparison diagram of the shore power system load prediction model based on the QPSO-LSTM network in an embodiment of the present invention. DETAILED DESCRIPTION
[0044] In order to make the technical means, creative features, objectives and effects achieved by the present invention easy to understand, the following embodiments and the accompanying drawings specifically illustrate the shore power system load prediction method and system based on the QPSO-LSTM network of the present invention.
[0045] This embodiment provides a shore power system load forecasting method based on a QPSO-LSTM network.
[0046] Figure 1 It is a technical flow chart of a shore power system load prediction method based on a QPSO-LSTM network in an embodiment of the present invention.
[0047] like Figure 1 As shown, the shore power system load forecasting method based on the QPSO algorithm and the LSTM network in this embodiment is based on the QPSO algorithm and the LSTM model, a QPSO-LSTM network is established and the above network is applied to the load forecasting work of the shore power system to obtain a shore power system load forecasting model based on the QPSO-LSTM network, and a case comparison analysis and evaluation of the model are carried out to evaluate its forecasting performance, which specifically includes the following steps:
[0048] Step S1, after data cleaning and normalization preprocessing of the original shore power system load data, the data is divided into training set data and test set data.
[0049] In this embodiment, the specific process of preprocessing the original shore power system load data is as follows:
[0050] Step S1-1, collecting load data of 18 hours of continuous shore power operation from the shore power system of a port in China, with a sampling frequency of one sample per minute, and obtaining 1080 data samples.
[0051] Step S1-2, in order to avoid the dominant role of certain features in the optimization process and make the optimization more fair and accurate, the collected data is preprocessed and normalized, unreasonable extreme values are eliminated, unreasonable data are replaced with data from the previous moment, and all data are normalized to the range of 0-1 to obtain sampling samples.
[0052] Figure 2 It is a sample distribution diagram of dividing the shore power system load data into training set data and test set data in an embodiment of the present invention.
[0053] Step S1-3, such as Figure 2 As shown in the figure, the first 70% of the sample data is used as a training set to train the network to obtain the optimal network parameters; the last 30% of the data is used as a test set to verify the prediction effect of the network.
[0054] Step S2: input the training set data into the LSTM network layer for training. When training the LSTM network layer, the number of hidden layer nodes L and the learning rate l are set. r The network training times K are optimized through the QPSO optimization layer, and the optimal value obtained each time is returned to the LSTM network layer to train the QPSO-LSTM network model.
[0055] In this embodiment, the QPSO algorithm is used to optimize the number of hidden layer nodes, learning rate and number of network training times of the LSTM network. The specific steps are as follows:
[0056] Step S2-1, initialize the LSTM network structure and hyperparameters: set the number of hidden layers to 2, the number of hidden layer nodes L1 and L2 to 28 and 151 respectively, and the number of training times to 29; the activation function uses the tanh function.
[0057] Step S2-2, using segmented learning rate, set the learning rate l at the beginning of training r It is 0.0064.
[0058] Step S2-3, the population size, iteration number, and spatial dimension of the initial QPSO particle swarm are set to 10, 10, and 4 respectively; the particle positions of the particles corresponding to the hidden layer nodes, learning rate, and network training times of the two hidden layers are in the range of [1,200], [1,200], [0.001,0.01], and [10,100] respectively. In particular, in order to ensure that the number of hidden layer nodes and the number of network training times are optimized in the integer space, the particle values are rounded at each iteration.
[0059] Step S2-4, train the LSTM network parameters according to the particle position and calculate the particle fitness. The mean square error of the training set is used as the particle fitness function f, which is expressed as:
[0060]
[0061] Where N is the number of samples in the training set; and x j are the predicted output value and true value of the jth training set sample respectively.
[0062] Step S2-5, based on the fitness value, determine the optimal solution of each particle and the current global optimal solution of the entire particle swarm, and update the particle position based on the following formulas (14)-(16):
[0063]
[0064] Among them, β is the shrinkage expansion coefficient; u is a random number between (0,1); is the average optimal position of particles; Qt is a random particle point.
[0065] and Q t It can be obtained by the following formula:
[0066]
[0067] Where M is the population size and α is a random number between (0,1).
[0068] Step S2-6, based on the change of fitness value and the maximum number of iterations, determine whether the iteration is terminated. If the termination condition is met, the optimal particle position is output as the LSTM network parameter. Otherwise, execute (10) and update the particle position to continue iterating until the termination condition is met.
[0069] Figure 3 is a diagram showing the fitness variation of the QPSO algorithm in an embodiment of the present invention.
[0070] Figure 4 Graph showing parameter changes of the QPSO algorithm in an embodiment of the present invention.
[0071] like Figure 3 As shown in , as the number of iterations increases, the particle fitness value gradually decreases. After 5 iterations, its value finally stabilizes to 0.0353. Figure 4 The optimal LSTM network parameters are: number of hidden layer nodes L1 = 157, L2 = 80, number of network training times K = 35, learning rate l r =0.007. The optimal network parameters are introduced into the LSTM network and trained using the training set data to obtain the QPSO-LSTM network model.
[0072] Step S3, input the test set into the trained QPSO-LSTM network model, and denormalize and output the final prediction result of the test set data. A case comparison analysis is performed using the shore power system load prediction model based on the LSTM network and the shore power system load prediction model based on the particle swarm algorithm (PSO) optimized LSTM (PSO-LSTM) network.
[0073] Figure 5 It is a case analysis comparison diagram of the shore power system load prediction model based on the QPSO-LSTM network in an embodiment of the present invention.
[0074] The parameter settings used by the two models used for case comparative analysis in this embodiment are the same as the corresponding parameter settings of the QPSO-LSMT network in step S2.
[0075] Step S4, evaluating the capability of the shore power system load forecasting model based on neural network through RMSE, MAE and MAPE.
[0076] In this embodiment, the RMSE of the shore power system load forecasting model based on the QPSO-LSTM network is 3000, the MAE is 1866, and the MAPE is 4.61%. The RMSE of the shore power system load forecasting model based on the PSO-LSTM network is 3131, the MAE is 2219, and the MAPE is 5.53%. The RMSE of the shore power system load forecasting model based on the LSTM network is 4063, the MAE is 2844, and the MAPE is 6.88%.
[0077] It can be seen that the shore power system load forecasting method based on the QPSO-LSTM network proposed in this embodiment has achieved a relatively ideal prediction effect in the non-stationary, nonlinear and violently fluctuating shore power system load scenario, indicating that this method is suitable for the load forecasting of the shore power system.
[0078] In summary, the shore power system load forecasting method based on quantum particle swarm optimization (Quantum-behaved ParticleSwarm Optimization, QPSO) and long short-term memory network (Long Short-Term Memory, LSTM) provided in this embodiment uses the QPSO algorithm to optimize the number of hidden layer nodes, training times and learning rate of the LSTM network, and solves the accuracy problem caused by the uncertainty of the traditional LSTM network structure and parameters, thereby constructing a shore power system load forecasting model based on the QPSO-LSTM network. And a case analysis is made to compare the model with the shore power system load forecasting model based on the traditional neural network. The results show that the method proposed in this embodiment has higher prediction performance, thereby being able to provide a better prediction method for power grid companies to conduct port shore power system load forecasting in the future.
[0079] This embodiment also provides a shore power system load prediction system based on a QPSO-LSTM network, including the following parts:
[0080] The preprocessing unit preprocesses the original shore power system load data using the method in step S1 above.
[0081] The training unit uses the method in step S2 above to input the training set data into the LSTM network layer for training to obtain a QPSO-LSTM network model.
[0082] The prediction unit outputs the final prediction result of the test set data using the method in the above step S3, and performs case comparison analysis between shore power system load prediction models based on different networks.
[0083] The evaluation unit uses the method in the above step S4 to evaluate the load prediction model capability of the shore power system based on the QPSO-LSTM network.
[0084] The above-mentioned embodiments are preferred examples of the present invention and are not intended to limit the protection scope of the present invention.
Claims
1. A shore power system load forecasting method based on QPSO-LSTM network, characterized in that: The following steps are involved: Step S1, after data cleaning and normalization preprocessing of the original shore power system load data, the data is divided into training set data and test set data; Step S2: input the training set data into the LSTM network layer for training, and set the number of hidden layer nodes L and the learning rate l r The network training times K are optimized through the QPSO optimization layer, and the optimal value obtained each time is returned to the LSTM network layer to train and obtain a QPSO-LSTM network model; Step S3, inputting the test set data into the trained QPSO-LSTM network model, denormalizing and outputting the final prediction result of the test set data, and performing case comparative analysis between shore power system load prediction models based on different networks; Step S4: evaluate the load forecasting model capability of the shore power system based on the QPSO-LSTM network according to the above results.
2. The shore power system load forecasting method based on QPSO-LSTM network according to claim 1 is characterized in that: in, In step S1, the specific process of preprocessing the original shore power system load data is as follows: Step S1-1, collecting load data of 18 hours of continuous shore power operation from the shore power system, with a sampling frequency of one sample per minute, and obtaining 1080 data samples; Step S1-2, preprocessing and normalizing the data samples, removing unreasonable extreme values and replacing unreasonable data with data from the previous moment, and then normalizing all data to a range of 0-1 to obtain sample data; Step S1-3, taking the first 70% of the sample data as training set data, and the last 30% as test set data.
3. The shore power system load forecasting method based on QPSO-LSTM network according to claim 1 is characterized in that: in, In step S2, the core of the LSTM network layer is to add and delete cell states through a gate structure. An LSTM network contains three gates, namely, a forget gate, an input gate, and an output gate: ① The forget gate is responsible for controlling the discarding of redundant information from the unit state information at the previous moment. The calculation formula of the forget gate is as follows: f t =σ(W f [h t-1 ,x t ]+b f )(1) Among them, f t represents the output value of the forget gate at time t, σ is the sigmoid activation function, which mainly plays a gating role, and the output is 0 to 1, W f is the weight matrix of the forget gate, h t-1 represents the output and unit state at the previous moment, x t Indicates the input status at the current moment, b f is the bias term of the forget gate; ②The input gate is based on h t-1 and x t Add new information to the memory unit. The calculation formula is as follows: i t =σ(W i [h t-1 ,x t ]+b i )(2) Among them, W i , is the weight matrix of the input gate, b i , is the bias term of the input gate, For the information that needs to be remembered, i t Enter for the current moment; ③ After the forget gate and the output gate are calculated, the update gate updates the memory unit. The calculation formula is as follows: Among them, C t and C t-1 Respectively represent the unit status at the current moment and the previous moment, represents input gating, Represents the matrix element product; ④ The output gate determines which state information in the memory unit is used as output. The calculation formula is as follows: the t =σ(W o [h t-1 ,x t ]+b o (5) Among them, t Represents the proportionality coefficient of the output information, h t Represents the output at the current moment, W o is the weight matrix of the output gate, b o is the bias term of the output gate, and tanh is the hyperbolic tangent activation function.
4. The shore power system load forecasting method based on QPSO-LSTM network according to claim 1 is characterized in that: in, In step S2, the QPSO algorithm only updates the particle position formula without velocity update, and the particle position is expressed as follows: Among them, β is the shrinkage expansion coefficient, u is a random number between (0,1), is the average optimal position of particles, Q t is a random point of the particle, B and Q t It is obtained by the following formula: Among them, M is the population size, and α is a random number between (0,1).
5. The shore power system load forecasting method based on QPSO-LSTM network according to claim 1 is characterized in that: in, In step S3, the shore power system load prediction model of different networks includes: The shore power system load forecasting model based on QPSO-LSTM network, the shore power system load forecasting model based on LSTM network and the shore power system load forecasting model based on particle swarm algorithm optimized LSTM network trained with the same training set.
6. The shore power system load forecasting method based on QPSO-LSTM network according to claim 1 is characterized in that: In step S4, the root mean square error, mean absolute error and mean absolute percentage error are used as evaluation criteria for model prediction, and the calculation method is as follows: in, is the predicted value; i is the true value; N is the total number, The smaller the values of the three evaluation indicators, the better the model prediction performance.
7. A shore power system load forecasting system based on QPSO-LSTM network, characterized in that: include: The preprocessing unit performs data cleaning and normalization preprocessing on the original shore power system load data, and then divides the data into training set data and test set data; The training unit inputs the training set data into the LSTM network layer for training, and sets the number of hidden layer nodes L and the learning rate l r The network training times K are optimized through the QPSO optimization layer, and the optimal value obtained each time is returned to the LSTM network layer to train and obtain a QPSO-LSTM network model; The prediction unit inputs the test set data into the trained QPSO-LSTM network model, denormalizes and outputs the final prediction result of the test set data, and performs case comparison analysis between shore power system load prediction models based on different networks; The evaluation department, based on the above results, evaluates the capability of the shore power system load forecasting model based on the QPSO-LSTM network.
8. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, The processor runs the computer program to implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: The program is executed by a processor to implement the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that: The computer program is executed by a processor to implement the method according to any one of claims 1 to 6.
Citation Information
Cited By
Ground source heat pump air conditioner load prediction method based on hybrid optimization and deep learning
CN121389391A
Source load prediction method and device suitable for light storage mobile power supply, medium and equipment
CN122740102A
