CN115271186B - Reservoir water level prediction and early warning method based on delay factor and PSO RNN Attention model - Google Patents

Reservoir water level prediction and early warning method based on delay factor and PSO RNN Attention model Download PDF

Info

Publication number
CN115271186B
CN115271186B CN202210840373.4A CN202210840373A CN115271186B CN 115271186 B CN115271186 B CN 115271186B CN 202210840373 A CN202210840373 A CN 202210840373A CN 115271186 B CN115271186 B CN 115271186B
Authority
CN
China
Prior art keywords
water level
reservoir
data
rnn
model
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210840373.4A
Other languages
Chinese (zh)
Other versions
CN115271186A (en
Inventor
马森标
黄正鹏
陈宇龙
陈友武
黄祖海
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujian Zhongrui Network Co ltd
Original Assignee
Fujian Zhongrui Network Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujian Zhongrui Network Co ltd filed Critical Fujian Zhongrui Network Co ltd
Priority to CN202210840373.4A priority Critical patent/CN115271186B/en
Publication of CN115271186A publication Critical patent/CN115271186A/en
Application granted granted Critical
Publication of CN115271186B publication Critical patent/CN115271186B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/04Forecasting or optimisation specially adapted for administrative or management purposes, e.g. linear programming or "cutting stock problem"
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/004Artificial life, i.e. computing arrangements simulating life
    • G06N3/006Artificial life, i.e. computing arrangements simulating life based on simulated virtual individual or collective life forms, e.g. social simulations or particle swarm optimisation [PSO]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/049Temporal neural networks, e.g. delay elements, oscillating neurons or pulsed inputs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q50/00Information and communication technology [ICT] specially adapted for implementation of business processes of specific business sectors, e.g. utilities or tourism
    • G06Q50/06Energy or water supply
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02ATECHNOLOGIES FOR ADAPTATION TO CLIMATE CHANGE
    • Y02A10/00TECHNOLOGIES FOR ADAPTATION TO CLIMATE CHANGE at coastal zones; at river basins
    • Y02A10/40Controlling or monitoring, e.g. of flood or hurricane; Forecasting, e.g. risk assessment or mapping

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Health & Medical Sciences (AREA)
  • General Physics & Mathematics (AREA)
  • Economics (AREA)
  • General Health & Medical Sciences (AREA)
  • Biophysics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Software Systems (AREA)
  • Mathematical Physics (AREA)
  • General Engineering & Computer Science (AREA)
  • Computing Systems (AREA)
  • Molecular Biology (AREA)
  • Strategic Management (AREA)
  • Human Resources & Organizations (AREA)
  • Evolutionary Computation (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Biomedical Technology (AREA)
  • Artificial Intelligence (AREA)
  • General Business, Economics & Management (AREA)
  • Marketing (AREA)
  • Tourism & Hospitality (AREA)
  • Operations Research (AREA)
  • Primary Health Care (AREA)
  • Development Economics (AREA)
  • Game Theory and Decision Science (AREA)
  • Water Supply & Treatment (AREA)
  • Public Health (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Quality & Reliability (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention relates to a reservoir water level prediction and early warning method based on a delay factor and a PSO RNN Attention model. The method calculates the time delay factor based on the numerical relation between the water levels of the upper reservoir, further constructs the time delay water level characteristic, and effectively inputs the influence of the upstream water level (flood discharge amount) on the water level of the reservoir into the model. Based on an RNN (recurrent neural network) and Attention mechanism composite model, historical water level data, rainfall and flood discharge are used for training the model, and PSO optimization algorithm is used for optimizing RNN-Attention model super-parameters. The model fully utilizes the reservoir and upstream rainwater condition data, realizes the prediction of future water level, has high prediction accuracy, and can realize the real-time monitoring and early warning of the dam by combining the Kafka module and the early warning module.

Description

Reservoir water level prediction and early warning method based on delay factor and PSO RNN Attention model
Technical Field
The invention relates to the technical field of reservoir water level prediction and early warning, in particular to a reservoir water level prediction and early warning method based on a delay factor and a PSO RNN Attention model.
Background
The reservoir is very important in water resource management and scheduling, has important significance for flood control and development and utilization of water resources, and is one of important works for ensuring reservoir safety by controlling the reservoir water level in a reasonable interval.
The existing reservoir health monitoring system adopts a sensor to monitor the rainwater condition data of the reservoir in real time, and then determines the opening and closing degree of the gate through manual experience judgment or simple mathematical formula deduction. The method not only does not predict the future water level, but also consumes huge resources to collect data to be directly stored in the database, and the database is maintained by continuously inputting resources, so that the value in the reservoir rainwater condition data is not fully mined, and serious waste of the resources is caused. For extreme weather, the weather forecast can only be used for knowing that the unstable factors are too many, and in sudden flood climate, in order to avoid dam collapse, the reservoir is always opened to drain water, so that reservoir flood is caused, and even casualties are caused in serious cases.
Therefore, most of the existing reservoir water level scheduling technologies are based on real-time water level of reservoirs acquired by sensors, and the future water level is judged by means of artificial experience and a simple mathematical derivation formula in combination with weather forecast to perform real-time scheduling of reservoir water levels.
Disclosure of Invention
The invention aims to provide a reservoir water level prediction and early warning method based on a delay factor and a PSO RNN Attention model, which fully utilizes reservoir and upstream rainwater condition data to realize prediction of future water level, has high prediction accuracy, and can realize real-time monitoring and early warning of a dam by combining a Kafka module and an early warning module.
In order to achieve the above purpose, the technical scheme of the invention is as follows: a reservoir water level prediction and early warning method based on a delay factor and a PSO RNN Attention model is characterized in that a water level delay factor is constructed based on reservoir and upstream related measuring point rainwater condition data, an RNN-Attention reservoir water level prediction model is established, and a PSO optimization algorithm is used for optimizing super parameters of the RNN-Attention reservoir water level prediction model, so that prediction and early warning of reservoir water level are achieved. The method comprises the following implementation steps:
step 1, calculating a water level delay factor;
step 2, inputting water level, flood discharge amount and rainfall data;
step 3, data preprocessing;
step 4, constructing a water level component;
step 5, eliminating dimension and numerical value differences among the data;
step 6, data division and remodeling;
step 7, constructing delay characteristics of upstream related measuring points;
step 8, building an RNN-Attention reservoir water level prediction model;
step 9, optimizing the super parameters of the RNN-Attention reservoir water level prediction model by adopting a PSO optimization algorithm to obtain an optimized PSO RNN-Attention reservoir water level prediction model;
and step 10, evaluating and storing the PSO RNN-Attention reservoir water level prediction model optimized in the step 9, and then utilizing the PSO RNN-Attention reservoir water level prediction model to realize the prediction and early warning of the reservoir water level.
Compared with the prior art, the invention has the following beneficial effects:
1. the method for calculating the delay characteristics of the upstream relevant water level (flood discharge amount) based on solving the delay factors can effectively obtain the time of the water level (flood discharge amount) of the upstream relevant measuring point acting on the reservoir, and greatly improves the accuracy of the water level prediction model.
2. The method takes an RNN-Attention reservoir water level prediction model as a core, establishes a water level prediction module, combines a Kafka module and an early warning module, realizes a reservoir water level real-time prediction early warning function, and solves the problems of high artificial experience judgment error and inaccurate calculation prediction of a simple formula.
3. According to the method, the RNN algorithm suitable for time sequence prediction is used for predicting the water level, two RNN layers are constructed, so that the model has nonlinear multidimensional prediction capability, and Attention weight distribution is completed by introducing an Attention mechanism, so that the accuracy of prediction is improved.
4. The improved PSO algorithm is used for optimizing the RNN-Attention model super-parameters, so that the time for searching the super-parameters by the RNN-Attention model is greatly reduced, and compared with the common PSO optimization algorithm, the prediction accuracy of the whole model is effectively improved.
Drawings
FIG. 1 is a flow chart of the method of the present invention.
FIG. 2 is a schematic view of a reservoir, upstream station, sluice.
FIG. 3 is a schematic representation of data remodeling.
FIG. 4 is a diagram of an RNN-Attention mechanism model constructed by the invention.
Fig. 5 is a flowchart of PSO algorithm optimization.
Fig. 6 is a graph of inertial weight ω variation.
FIG. 7 is a flow chart of real-time prediction for an embodiment of the method of the present invention.
Fig. 8 is a schematic diagram of a PSO iteration process according to an example of the present invention.
FIG. 9 is a graph showing a test set predicted value and a true value fit according to an embodiment of the present invention.
Detailed Description
The technical scheme of the invention is specifically described below with reference to the accompanying drawings.
The reservoir water level prediction early warning method based on the delay factor and the PSO RNNATTENTion model is characterized in that the water level delay factor is constructed based on the rainwater condition data of the reservoir and upstream related measuring points, an RNN-Attention reservoir water level prediction model is built, and the PSO optimization algorithm is used for optimizing the super parameters of the RNN-Attention reservoir water level prediction model, so that the prediction early warning of the reservoir water level is realized.
The following is a specific implementation procedure of the present invention.
Based on the existing reservoir and upstream related measuring point rainwater condition data, a water level delay factor is constructed, an RNN-Attention reservoir water level prediction model is established, a PSO optimization algorithm is used for optimizing model super-parameters, and the overall flow is shown in figure 1.
Step 1, calculating a water level delay factor
The method comprises the steps of inputting water level and flood discharge amount data of a reservoir and each relevant measuring point at the upstream of the reservoir, eliminating dimensional influences among different value fields and unit data by using a z-score standardization mode, dividing the data into a plurality of pieces of data according to fixed monitoring time intervals, respectively constructing delay factors according to each piece of data of the reservoir water level, enabling the delay factors to represent the number of unit interval monitoring time passing by the upstream water level (flood discharge amount) to act on the reservoir, requiring alignment solution, taking the upstream delay water level characteristic constructed by the delay factors as independent variables, constructing a multiple linear regression model for fitting by taking the reservoir water level data as the independent variables, describing that the fitting error is smaller, the closer the fitting error is, the closer the delay factors are to the true value, solving the delay factors closest to the true value by using a controlled variable optimizing method, and completing construction of the delay factors. FIG. 2 is a schematic view of a reservoir, upstream station, sluice.
Step 1.1, inputting upstream related measuring point water level (flood discharge amount) and reservoir water level data
The input data are water level and flood discharge amount data of the reservoir and related upstream measuring points, and the initial acquisition time, the acquisition interval and the end acquisition time are required to be consistent. The specific data formats are shown in Table 1:
TABLE 1
Step 1.2, z-score normalization
In order to eliminate the dimensional influence among different value ranges and unit data, the input data is subjected to z-score standardization processing. The calculation formula is as follows:
where x represents the number of dataThe volume, mu represents the mean value of the data,representing the standard deviation of the data.
Step 1.3, constructing a water level delay factor
The delay factor represents how many unit intervals the upstream water level (flood discharge) is in the reservoir for monitoring time, which needs to be solved. The delay factor is constructed in the following way:
the reservoir data is divided into a plurality of pieces of data according to fixed time intervals, and the dividing mode is as follows:
wherein W is T All water level data representing the reservoir in the period T;representing the reservoir at t i The water level at the moment, i epsilon|1, a|; />Representing all water level data of the j-th segment after division, wherein j is epsilon|1 and n|;
the delay factor is constructed by using the water level (flood discharge amount) data of the upstream related measuring points, and the specific construction mode is as follows:
wherein W represents water level, flood discharge is represented if the upstream related measuring point is a dam or a sluice, k represents k upstream measuring points related to a reservoir, T i Represents the divided monitoring time of the ith section, t k A delay factor representing the kth upstream measuring point, namely, the kth upstream measuring point data is delayed by t k Monitoring unit time;
step 1.4, constructing a linear regression model
And constructing a multiple linear regression model by taking the upstream delay water level (flood discharge amount) characteristic constructed by the delay factors as independent variables and reservoir water level data as dependent variables to perform training fitting, wherein the smaller the fitting error is, the closer the two are, and the closer the delay factors are to the true value.
Step 1.5, minimizing the fitting error of the linear regression model by using the PSO algorithm
Based on the linear regression model in the step 1.4, using a PSO algorithm, and carrying out iterative optimization by taking a time delay factor as an optimizing variable and a fitting error as an objective function on the premise of not changing the super parameters of the linear regression model. The method comprises the following steps:
and optimizing the delay factor of each relevant upstream measuring point of the reservoir by using a PSO algorithm, wherein an objective function of the PSO is set as the MSE of a multiple linear regression model, and parameters of the PSO model, namely inertia weight, learning factors, particle number and particle swarm search dimension are set. And initializing the position of the particle to be 0, correcting the speed direction, and optimizing the delay factor of each relevant upstream measuring point. The dimension of particle optimization is the delay factor of each relevant upstream measuring point.
Embedding a multiple linear regression model into a PSO model, setting the super parameters of the model to be optimized as dimensions corresponding to particle swarms, iterating after setting, and selecting a group with the minimum MSE (mean square error) after optimizing iteration, namely, a delay factor closest to a true value.
Step 2, inputting water level, flood discharge and rainfall data
And inputting data such as reservoir water level, flood discharge amount, rainfall amount and the like in the reservoir monitoring database and collecting time thereof. The specific data formats are shown in Table 2:
TABLE 2
Wherein m is<n,i<j,t m Represents the initial acquisition time of the waterlevel data, t n Represents the final acquisition time, w, of the waterlevel data m Represents t m Time-corresponding waterlevel acquisition data, r i Represents t i And collecting data by the corresponding rain fall.
Step 3, data preprocessing
Step 3.1, time alignment
Reservoir monitoring database data are respectively acquired for each sensor, the time points of each data acquisition are difficult to unify, even the acquisition intervals are also not uniform, and subsequent analysis cannot be performed. The data is resampled, and the acquisition interval and the acquisition time point of the data are unified. The data after time alignment are shown in Table 3:
TABLE 3 Table 3
Step 3.2, missing value handling
Filling the data with the missing value either the previous value or the next value.
Step 4, constructing a water level component
Water level characteristic transformation: the relationship between reservoir level and its historical reservoir level over time is described as a pre-factor to reservoir level change, reflecting the trend and speed of level change. In order to mine the time sequence among different water level sequences, the characteristic transformation aiming at the water level characteristics of the reservoir is as follows:
wherein the water level data acquisition time of the reservoir is T t (t=0,1,2,…,n),Is T 0 ~T n Reservoir level, H of time period i Is->W is the reservoir level;
reservoir level characterization according to f (W)Transformed to W 1 、W 2 、W 3 The method comprises the following steps of:
step 5, eliminating dimension and numerical value differences among the data
If the data has a sample which deviates from the total sample by a large amount, the z-score is used for standardization, otherwise, the max-min is used for standardization (specifically, if the reservoir water level has the characteristic of tending to the safe water level, namely, the reservoir water level data is stable, the max-min is used for standardization treatment on the reservoir water level data).
z-score normalization formula:
where x represents the individual value of the data, μ represents the mean value of the data,representing the standard deviation of the data.
max-min normalization formula:
wherein X is the observed value of the feature, X min Is the minimum value of the feature, X max Is the maximum value of the feature.
Step 6, data partitioning and remodelling
Step 6.1, data partitioning
Data are divided into training and testing sets, with the first 70% as training set and the second 30% as testing set.
Step 6.2, data remodeling
And windowing the divided data, and reshaping the data into a 3D format capable of being input into a model.
The window width (width) of 3 and the time step of 1 is shown in fig. 3, where the window width is incorporated into the super-parameters of PSO optimization. The data shape before remodeling is (samples, features), and the shape after remodeling is (samples-width+1, width, features).
Step 7, constructing the delay characteristics of upstream related measuring points
And (3) constructing the delay characteristics of the upstream related measuring points according to the delay factors obtained in the step (1).
The concrete construction mode is as follows:
independent variable X of reservoir q The water level data of (2) are:
the relevant upstream water level delay characteristics are:
wherein W represents water level, if gate control water yield is provided at the upstream related measuring point, the water level can represent flood discharge, k represents k upstream measuring points related to the reservoir, T i Represents the divided monitoring time of the ith section, t k A delay factor representing the kth upstream monitoring point, namely, the kth upstream monitoring point data is delayed by t k Each monitoring unit time.
Step 8, building an RNN-Attention model
The structural diagram of the RNN-Attention mechanism model built in the method is shown in figure 4.
Step 8.1, input layer
Converting the reshaped 3D data into tensors at the input layer (inputs) with unchanged shape, each X representing data within a window, time ordered X 1 ,X 2 ,X 3 ,…,X n
Step 8.2 RNN layer (1)
Each hidden neuron of the input layer data input into the RNN layer (1) in time sequence is trained, and an activation function is set to LeakyReLU.
Step 8.3 Dropout layer (1)
Probability deactivation of hidden neurons of RNN layer (1), prevention of overfitting, output of vector matrix set
Step 8.4 RNN layer (2)
The model can deal with the nonlinear problem, the vector matrix in the step 8.3 is assembledTraining is performed in hidden neurons of the input RNN layer (2), and the activation function is still LeakyReLU.
Step 8.5 Dropout layer (2)
Probability deactivation of hidden neurons of RNN layer (2), outputting a set of vector matrices
Step 8.6, attention layer
Acquiring the vector matrix set in step 8.5Weights are calculated for the Dense layer of softmax using an activation function, assigned by the multiple layer to the vector matrix set +.>Obtaining a vector matrix set containing attention weights
Step 8.7 Flatten layer
Acquiring the vector matrix set in step 8.6Disassembling and splicing the two-dimensional vector F into a plurality of one-dimensional vectors n
Step 8.8, dense layer
Acquiring vector F in step 8.7 n As input to the Dense layer neuron, the activation function is set to linear, and finally the predicted value sequence Y (Y 1 ,y 2 ,y 3 ,…)。
Step 9, PSO optimizing RNN-attribute model super parameter
The PSO algorithm is used to optimize the super parameters of the RNN-Attention model, and the specific optimization flow chart is shown in FIG. 5.
Step 9.1, using variable to replace RNN-attribute model part hyper-parameters
The window width, the number of neurons of the RNN layer (1), the number of neurons of the Dropout layer (1), the number of neurons of the RNN layer (2), the Dropout layer (2), the learning rate and the batch_size in the RNN-Attention model are replaced by variables.
Step 9.2, setting the value range of the particles
Setting the value ranges of seven particles:
window width: the minimum is 1, and the maximum does not exceed the total data amount.
Number of neurons: at a minimum of 1 and generally at a maximum of no more than 1024.
Dropout rate: at least 0 and at most 0.5.
Learning rate: at least 0 and at most 0.5.
batch_size: the minimum is 1, and the maximum does not exceed the total data amount.
Step 9.3, initializing particle position, velocity
Randomly initializing the particle position in the particle value range, wherein the particle speed initializing range is [ - (value range maximum-minimum), (value range maximum-minimum) ].
Step 9.4, inputting the position of the particle into the RNN-Attention model, returning to MSE
And replacing variables in the RNN-Attention model by using particle positions, training the model by using a training set, verifying the model by using test set data, calculating MSE of a predicted value and a true value of the test set, and outputting the MSE.
Step 9.5, initializing the global optimum position and the particle historic optimum position
And recording the particle position with the lowest MSE as a global optimal position, and recording all the current positions of the particles as the historical optimal position of the particles.
Step 9.6 updating inertial weight, particle velocity and position
The method is based on the variation of the sigmoid function, and combines a trigonometric function to improve PSO global searching and local searching strategies. In the iterative process, the strategy can effectively balance PSO global searching capability and local searching capability, and the weight updating expression is as follows:
wherein the item is the current iteration number, item max For the final iteration number ω max For maximum inertial weight, ω min The minimum inertial weight, σ, is the expansion coefficient, the value range (0, + -infinity), typically 5, θ is the deformation coefficient, and the value range (-1, + -infinity), typically 0.
When σ=5 and θ=0, the resulting inertial weight ω change curve is shown in fig. 6.
PSO is initialized to a group of random particles, namely a random solution, and an optimal solution is found through iteration; in each iteration, the particle is obtained by tracking two "extrema", i.e., pbest i And gbest i To update itself; after finding the two optimal values, the velocity of each particle is updated according to the above formula, and the updated velocity is used to update the position of the particle:
v i =ω×v i +c 1 ×rand()×(pbest i -x i )+c 2 ×rand()×(gbest i -x i )
x i =x i +v i
where i=1, 2,3, … …, N is the total number of particles in the random particle population; v i Is the velocity of the particles, maximum value v max ,v max A value greater than 0, v i Greater than v max V is then i =v max The method comprises the steps of carrying out a first treatment on the surface of the rand () is a random number between (0, 1); x is x i Is the current position of the particle; c 1 、c 2 As a learning factor, 2 is usually taken; omega is an inertia factor, the value of which is non-negative, the value of which is larger, the global optimizing capability is strong, the local optimizing capability is weak, and the value of which is smaller, the global optimizing capability is weak, and the local optimizing capability is strong;
step 9.7, calculating the MSE of the updated particles in the model
And 9.4, replacing variables in the RNN-Attention model by using particle positions, using a training set training model, verifying the model by using test set data, calculating MSE of a predicted value and a true value of the test set, and outputting the MSE.
Step 9.8, updating the global optimal position and the particle historical optimal position
If the current particle is smaller than the MSE of the particle history optimal position, updating the individual optimal position; and if the MSE of the current population optimal individual is smaller than that of the global optimal position, updating the global optimal position.
Step 9.9, judging whether the maximum iteration number is reached
Judging whether the maximum iteration times are reached, and if so, outputting a global optimal position; otherwise, step 9.10 is performed.
Step 9.10, variation population optimal particle position
Determining whether the current omega is less than 0.9 omega max +0.1ω min If the value is smaller than the position of the particle with the optimal loss function value in the variation population, otherwise, the step 9.11 is carried out. The variation mode is as follows:
wherein,is [0,1]Random numbers within an interval, iter max For the maximum iteration number, iter is the current iteration number, G iter Is the global historical optimal position when iterating the item times.
Step 9.11 variation of the position of the worst particles of the population
Determining whether the current omega is less than 0.1 omega max +0.9ω min If the value is smaller than the position of the particle with the worst loss function value in the variation population, otherwise, the step 9.11 is carried out. The variation mode is as follows:
wherein,is [0,1]Random numbers within an interval, iter max For the maximum number of iterations, iter is the current number of iterations,the optimal position of the particle history when iterating the item times.
Step 9.12, repeatedly executing the steps 9.6-9.10
And repeatedly executing the steps 9.6-9.10 until the maximum iteration number is reached, and outputting the sought global optimal parameters.
Step 10, reservoir water level prediction model based on RNN-Attention algorithm
And (3) inputting the global optimal parameter combination obtained in the step (9) PSO into an RNN-Attention model, and training the RNN-Attention model by using training set data to obtain a reservoir water level prediction model based on an RNN-Attention algorithm.
Step 11, model evaluation
Inputting the test set data into the reservoir water level prediction model based on the RNN-Attention algorithm obtained in the step 10 to obtain a predicted value, and using MSE, MAE, RMSE, R 2 The model is evaluated by the index.
Step 12, model application
And storing the reservoir water level prediction model which meets the application standard after evaluation and is based on the RNN-Attention algorithm to the cloud or local so that the model can be directly called in subsequent projects. The flow of real-time prediction using this model is shown in fig. 7.
Step 12.1, kafka Module
And reading reservoir rainwater condition data acquired by the sensor by using Kafka.
The producer produces and pushes a message read from the stream data to the Broker by calling the kafka-related python api.
And the consumer pulls the stream data from the brooker through a pull operation by a corresponding partition allocation strategy and transmits the stream data into the water level prediction module.
Step 12.2, water level prediction Module
And (3) preprocessing the real-time data output in the step (12.1), inputting the preprocessed real-time data into a reservoir water level prediction model to obtain real-time prediction data, and storing the prediction data into a reservoir monitoring database.
Step 12.3, early warning module
And (3) judging the water level condition according to the real-time prediction data in the step (12.2), wherein the water level condition is not early-warned in the safety zone, and the water level condition is early-warned when the water level condition exceeds or falls below the safety zone, and the opening and closing degree of the reservoir gate is adjusted according to the early-warning condition.
Fruit display
1. Optimum parameters
The present example uses Particle Swarm Optimization (PSO) to optimize 7 super parameters of the RNN-Attention composite model, the optimal parameters are shown in Table 4 below:
TABLE 4 Table 4
2. Iterative image
The present example uses Particle Swarm Optimization (PSO) to optimize 7 super parameters based on RNN-Attention composite model. The MSE based on the RNN-Attention composite model is used as an evaluation index, namely the MSE is converged to 0, and the smaller the loss is in the iteration process, the better the super-parameter is. The iterative process is shown in fig. 8.
Fig. 8 is the result of 80 iterations with 25 particles, and it can be seen that the fitness is smaller, i.e. the MSE is closer to 0, indicating that the super-parameters found by the PSO are better. After 41 iterations, the PSO found the optimal super-parameters.
3. Fitting chart of test set
Reservoir level prediction was performed using a PSO-RNN-Attention based composite model, the test set fitting of which is shown in FIG. 9.
4. Evaluation index
Using MAE (mean absolute error), MSE (mean square error), RMSE (root mean square error), R 2 (determining coefficients) evaluation model, evaluation results are shown in table 5:
TABLE 5
Reservoir level prediction is carried out by using PSO-RNN-Attention based composite model, and R is known from a table 2 = 0.968570, close to 1, indicating that the model has a good predictive effect; the closer the value is to 0, the better the model fit is explained by mse= 0.524703. Mae= 0.297870, which indicates that n (n=1, 2,3 …) predictions were made, and that the model produced errors stabilized around 0.297870 meters.
The above is a preferred embodiment of the present invention, and all changes made according to the technical solution of the present invention belong to the protection scope of the present invention when the generated functional effects do not exceed the scope of the technical solution of the present invention.

Claims (5)

1. A reservoir water level prediction and early warning method based on a delay factor and a PSO RNN Attention model is characterized in that the water level delay factor is constructed based on reservoir and upstream related measuring point rainwater condition data, an RNN-Attention reservoir water level prediction model is established, and a PSO optimization algorithm is used for optimizing super parameters of the RNN-Attention reservoir water level prediction model, so that prediction and early warning of reservoir water level are realized; the method comprises the following implementation steps:
step 1, calculating a water level delay factor;
step 2, inputting water level, flood discharge amount and rainfall data;
step 3, data preprocessing;
step 4, constructing a water level component;
step 5, eliminating dimension and numerical value differences among the data;
step 6, data division and remodeling;
step 7, constructing delay characteristics of upstream related measuring points;
step 8, building an RNN-Attention reservoir water level prediction model;
step 9, optimizing the super parameters of the RNN-Attention reservoir water level prediction model by adopting a PSO optimization algorithm to obtain an optimized PSO RNN-Attention reservoir water level prediction model;
step 10, evaluating and storing the PSO RNN-Attention reservoir water level prediction model optimized in the step 9, and then utilizing the PSO RNN-Attention reservoir water level prediction model to realize the prediction and early warning of reservoir water level;
the step 1 is specifically implemented as follows:
step 1.1, inputting reservoir water level data and water level data of relevant measuring points at the upstream of a reservoir;
step 1.2, z-score normalization: the input water level data is subjected to z-score standardization processing, and the calculation formula is as follows:
where x represents the individual value of the water level data, μ represents the mean value of the water level data,standard deviation representing water level data;
step 1.3, constructing a water level delay factor:
dividing the reservoir water level data into a plurality of pieces of data according to a fixed time interval, wherein the dividing mode is as follows:
a,n∈Z * and->
Wherein W is T All water level data representing the reservoir in the period T;representing the reservoir at t i The water level at the moment, i epsilon|1, a|;representing all water level data of the j-th segment after division, wherein j is epsilon|1 and n|;
the delay factor is constructed by using water level data of relevant measuring points at the upstream of the reservoir, and the concrete construction mode is as follows:
wherein W represents water level, flood discharge is represented if the upstream related measuring point is a dam or a sluice, k represents k upstream measuring points related to a reservoir, T i Represents the divided monitoring time of the ith section, t k A delay factor representing the kth upstream measuring point, namely, the kth upstream measuring point data is delayed by t k Monitoring unit time;
step 1.4, constructing a linear regression model:
taking the upstream delay water level characteristic constructed by the delay factors as an independent variable, taking reservoir water level data as a dependent variable, building a multiple linear regression model for training and fitting, and indicating that the smaller the fitting error is, the closer the two are, and the closer the delay factors are to the true value;
step 1.5, using PSO algorithm to minimize linear regression model fitting error:
based on the multiple linear regression model in the step 1.4, using a PSO algorithm, and carrying out iterative optimization by taking a delay factor as an optimizing variable and a fitting error as an objective function on the premise of not changing the super parameters of the multiple linear regression model; the method comprises the following steps:
optimizing delay factors of each relevant upstream measuring point of the reservoir by using a PSO algorithm, wherein an objective function of the PSO model is set as MSE of a multiple linear regression model, and parameters of the PSO model, namely inertia weight, learning factors, particle number and particle swarm search dimension are set; initializing the position of the particle to be 0, setting the speed direction to be positive, and optimizing the delay factor of each relevant upstream measuring point; the dimension of particle optimization is the delay factor of each relevant upstream measuring point;
embedding a multiple linear regression model into a PSO model, setting super parameters of the model to be optimized as dimensions corresponding to particle swarms, iterating after setting, and selecting a group with the minimum MSE (mean square error) after optimizing iteration is completed, namely, a delay factor closest to a true value;
the step 4 is specifically implemented as follows:
water level characteristic transformation: the relation between the reservoir water level and the historical reservoir water level is described, is a prepositive factor of reservoir water level change, and reflects the trend and speed of water level change; in order to mine the time sequence among different water level sequences, the characteristic transformation aiming at the water level characteristics of the reservoir is as follows:
wherein the water level data acquisition time of the reservoir is T t (t=0,1,2,…,n),Is T 0 ~T n Reservoir level, H of time period i Is->W is the reservoir level;
according to f (W), reservoir water level characteristic transformation is carried out to obtain W 1 、W 2 、W 3 The method comprises the following steps of:
the step 7 is specifically implemented as follows:
constructing delay characteristics of upstream related measuring points according to the delay factors obtained in the step 1; the concrete construction mode is as follows:
independent variable X of reservoir q The water level data of (2) are:
the relevant upstream water level delay characteristics are:
wherein W represents the water level, k represents k upstream measuring points related to the reservoir, T i Represents the divided monitoring time of the ith section, t k A delay factor representing the kth upstream measuring point, namely, the kth upstream measuring point data is delayed by t k Monitoring unit time;
the step 9 is specifically implemented as follows:
step 9.1, replacing partial super parameters of the RNN-Attention reservoir water level prediction model by using variables:
replacing the window width, the number of RNN layer 1 neurons, the number of Dropout layer 1 neurons, the number of RNN layer 2 neurons, the Dropout layer 2 neurons, the learning rate and the batch_size in the RNN-Attention reservoir water level prediction model with variables;
step 9.2, setting the value ranges of seven particles:
window width: the minimum is 1, and the maximum is not more than the total data amount;
number of neurons: a minimum of 1 and a maximum of no more than 1024;
dropout rate: at least 0 and at most 0.5;
learning rate: at least 0 and at most 0.5;
batch_size: the minimum is 1, and the maximum is not more than the total data amount;
step 9.3, initializing particle position and speed:
randomly initializing the particle position in the particle value range, wherein the particle speed initialization range is [ - (value range maximum-minimum), (value range maximum-minimum) ];
step 9.4, inputting the positions of the particles into an RNN-Attention reservoir water level prediction model, and returning to MSE:
replacing variables in the RNN-Attention reservoir water level prediction model by using particle positions, using a training set training model, verifying the model by using test set data, calculating MSE of a test set predicted value and a true value, and outputting;
step 9.5, initializing a global optimal position and a particle history optimal position:
recording the particle position with the lowest MSE as the global optimal position, and recording all the current positions of the particles as the historical optimal position of the particles;
step 9.6, updating inertia weight, particle speed and position:
based on the variation of the sigmoid function, the global search and the local search strategy of the PSO optimization algorithm are improved by combining a trigonometric function, and the weight updating expression of the improved PSO optimization algorithm is as follows:
wherein the item is the current iteration number, item max For the final iteration number, t max Is iter max Time of time omega max For maximum inertial weight, ω min The minimum inertia weight, sigma is a telescopic coefficient, the value range (0, + -infinity), theta is a deformation coefficient, and the value range (-1, + -infinity);
PSO is initialized to a group of random particles, namely a random solution, and an optimal solution is found through iteration; in each iteration, the particle is obtained by tracking two "extrema", i.e., pbest i And gbest i To update itself; after finding the two optimal values, the velocity of each particle is updated according to the above formula, and the updated velocity is used to update the position of the particle:
v i =ω×v i +c 1 ×rand()×(pbest i -x i )+c 2 ×rand()×(gbest i -x i )
x i =x i +v i
where i=1, 2,3, … …, N is the total number of particles in the random particle population; v i Is the velocity of the particles; rand () is a random number between (0, 1); x is x i Is the current position of the particle; c 1 、c 2 Is a learning factor; omega is an inertia factor, the value of which is non-negative, the value of which is larger, the global optimizing capability is strong, the local optimizing capability is weak, and the value of which is smaller, the global optimizing capability is weak, and the local optimizing capability is strong;
step 9.7, calculating MSE of the updated particles in the model:
9.4, replacing variables in the RNN-Attention reservoir water level prediction model by particle positions, using a training set training model, using a test set data verification model, calculating MSE of a test set predicted value and a true value, and outputting;
step 9.8, updating the global optimal position and the particle history optimal position:
if the current particle is smaller than the MSE of the particle history optimal position, updating the individual optimal position; if the MSE of the current population optimal individual is smaller than that of the global optimal position, updating the global optimal position;
step 9.9, judging whether the maximum iteration number is reached:
judging whether the maximum iteration times are reached, and if so, outputting a global optimal position; otherwise, executing the step 9.10;
step 9.10, mutating optimal particle positions of the population:
determining whether the current omega is less than 0.9 omega max +0.1ω min If the value is smaller than the position of the particle with the optimal loss function value in the variation population, otherwise, the step 9.11 is carried out; the variation mode is as follows:
wherein,is [0,1]Random numbers within an interval, iter max For the maximum iteration number, iter is the current iteration number, G iter The global history optimal position when iterating the item times;
step 9.11, mutating the position of the worst particles of the population:
determining whether the current omega is less than 0.1 omega max +0.9ω min If the value is smaller than the position of the particle with the worst loss function value in the variation population, otherwise, the step 9.11 is carried out; the variation mode is as follows:
wherein,is [0,1]Random numbers within an interval, iter max For the maximum iteration number, iter is the current iteration number, P i tier The optimal position of the particle history when iterating the item times;
step 9.12, repeatedly executing the steps 9.6-9.10:
and repeatedly executing the steps 9.6-9.10 until the maximum iteration number is reached, and outputting the sought global optimal parameters.
2. The reservoir water level prediction and early warning method based on the delay factor and the PSO RNN Attention model as claimed in claim 1, wherein the step 3 is specifically implemented as follows:
step 3.1, time alignment:
resampling water level, flood discharge amount and rainfall data in the reservoir monitoring database input in the step 2 and acquisition time thereof, and unifying acquisition intervals and acquisition time points of the data;
step 3.2, missing value processing: filling the data with the missing value either the previous value or the next value.
3. The reservoir water level prediction and early warning method based on the delay factor and the PSO RNN Attention model as claimed in claim 1, wherein the step 5 is specifically implemented as follows:
if the reservoir water level has the characteristic of tending to the safe water level, namely the reservoir water level data is relatively stable, normalizing the reservoir water level data by using max-min normalization;
max-min normalization formula:
wherein X is the observed value of the feature, X min Is the minimum value of the feature, X max Is the maximum value of the feature.
4. The reservoir water level prediction and early warning method based on the delay factor and the PSO RNN Attention model as claimed in claim 1, wherein the step 6 is specifically implemented as follows:
step 6.1, data division:
dividing data into a training set and a testing set, wherein the first 70% is used as the training set, and the second 30% is used as the testing set;
step 6.2, data remolding:
and windowing the divided data, and remolding the data into a 3D format which can be input into an RNN-Attention reservoir water level prediction model.
5. The reservoir water level prediction early warning method based on the delay factor and the PSO RNN Attention model according to claim 1 is characterized in that in step 8, the built RNN-Attention reservoir water level prediction model structure sequentially comprises an input layer, an RNN layer 1, a Dropout layer 1, an RNN layer 2, a Dropout layer 2, an Attention layer, a flame layer and a Dense layer.
CN202210840373.4A 2022-07-18 2022-07-18 Reservoir water level prediction and early warning method based on delay factor and PSO RNN Attention model Active CN115271186B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210840373.4A CN115271186B (en) 2022-07-18 2022-07-18 Reservoir water level prediction and early warning method based on delay factor and PSO RNN Attention model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210840373.4A CN115271186B (en) 2022-07-18 2022-07-18 Reservoir water level prediction and early warning method based on delay factor and PSO RNN Attention model

Publications (2)

Publication Number Publication Date
CN115271186A CN115271186A (en) 2022-11-01
CN115271186B true CN115271186B (en) 2024-03-15

Family

ID=83767668

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210840373.4A Active CN115271186B (en) 2022-07-18 2022-07-18 Reservoir water level prediction and early warning method based on delay factor and PSO RNN Attention model

Country Status (1)

Country Link
CN (1) CN115271186B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115828757B (en) * 2022-12-12 2024-02-23 福建中锐汉鼎数字科技有限公司 Flood discharge hysteresis characteristic structure and selection method for drainage basin water level prediction
CN116403372B (en) * 2023-04-26 2024-06-11 上海勘测设计研究院有限公司 Reservoir flood discharge early warning method
CN117726043B (en) * 2024-02-05 2024-05-03 中水君信工程勘察设计有限公司 Automatic reservoir water condition measuring and forecasting method

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102032935A (en) * 2010-12-07 2011-04-27 杭州电子科技大学 Soft measurement method for sewage pumping station flow of urban drainage converged network
CN109711636A (en) * 2019-01-09 2019-05-03 南京工业大学 River water level prediction method based on chaotic firefly and gradient lifting tree model
CN110414742A (en) * 2019-08-02 2019-11-05 大连海事大学 A kind of freshwater line intelligent Forecasting of more gaging station linkages
CN110909413A (en) * 2019-12-09 2020-03-24 山东大学 Concrete panel rock-fill dam horizontal displacement prediction accuracy method and system
CN111222698A (en) * 2020-01-06 2020-06-02 重庆邮电大学 Long-and-short-term memory network-based ponding water level prediction method for Internet of things
CN112733997A (en) * 2021-01-14 2021-04-30 河海大学 Hydrological time series prediction optimization method based on WOA-LSTM-MC
CN113139700A (en) * 2020-11-30 2021-07-20 中科三清科技有限公司 River flow prediction method, device, equipment and storage medium
CN114184252A (en) * 2021-12-08 2022-03-15 武汉崧岳科技有限公司 Ship lift up-and-down stream approach channel reciprocating flow observation water level prediction early warning platform
CN114219131A (en) * 2021-11-24 2022-03-22 江西省水利科学院 Watershed runoff prediction method based on LSTM
CN114386693A (en) * 2022-01-11 2022-04-22 福建中锐网络股份有限公司 Reservoir water level prediction early warning method based on PSO-LSTM-Attention model
CN114386692A (en) * 2022-01-11 2022-04-22 福建中锐网络股份有限公司 Reservoir water level prediction early warning method based on PSO-CNN-LSTM
CN114648170A (en) * 2022-04-08 2022-06-21 福建中锐网络股份有限公司 Reservoir water level prediction early warning method and system based on hybrid deep learning model

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102032935A (en) * 2010-12-07 2011-04-27 杭州电子科技大学 Soft measurement method for sewage pumping station flow of urban drainage converged network
CN109711636A (en) * 2019-01-09 2019-05-03 南京工业大学 River water level prediction method based on chaotic firefly and gradient lifting tree model
CN110414742A (en) * 2019-08-02 2019-11-05 大连海事大学 A kind of freshwater line intelligent Forecasting of more gaging station linkages
CN110909413A (en) * 2019-12-09 2020-03-24 山东大学 Concrete panel rock-fill dam horizontal displacement prediction accuracy method and system
CN111222698A (en) * 2020-01-06 2020-06-02 重庆邮电大学 Long-and-short-term memory network-based ponding water level prediction method for Internet of things
CN113139700A (en) * 2020-11-30 2021-07-20 中科三清科技有限公司 River flow prediction method, device, equipment and storage medium
CN112733997A (en) * 2021-01-14 2021-04-30 河海大学 Hydrological time series prediction optimization method based on WOA-LSTM-MC
CN114219131A (en) * 2021-11-24 2022-03-22 江西省水利科学院 Watershed runoff prediction method based on LSTM
CN114184252A (en) * 2021-12-08 2022-03-15 武汉崧岳科技有限公司 Ship lift up-and-down stream approach channel reciprocating flow observation water level prediction early warning platform
CN114386693A (en) * 2022-01-11 2022-04-22 福建中锐网络股份有限公司 Reservoir water level prediction early warning method based on PSO-LSTM-Attention model
CN114386692A (en) * 2022-01-11 2022-04-22 福建中锐网络股份有限公司 Reservoir water level prediction early warning method based on PSO-CNN-LSTM
CN114648170A (en) * 2022-04-08 2022-06-21 福建中锐网络股份有限公司 Reservoir water level prediction early warning method and system based on hybrid deep learning model

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
《梯级水电站短期水位预测与调控策略研究》;郭爽;《硕士电子期刊出版信息》;20220315(第3期);全文 *

Also Published As

Publication number Publication date
CN115271186A (en) 2022-11-01

Similar Documents

Publication Publication Date Title
CN115271186B (en) Reservoir water level prediction and early warning method based on delay factor and PSO RNN Attention model
CN109243172B (en) Traffic flow prediction method for optimizing LSTM neural network based on genetic algorithm
CN110084367B (en) Soil moisture content prediction method based on LSTM deep learning model
CN110414788B (en) Electric energy quality prediction method based on similar days and improved LSTM
CN113554466B (en) Short-term electricity consumption prediction model construction method, prediction method and device
CN108388962B (en) Wind power prediction system and method
CN109143408B (en) Dynamic region combined short-time rainfall forecasting method based on MLP
CN113325721B (en) Model-free adaptive control method and system for industrial system
CN113705877A (en) Real-time monthly runoff forecasting method based on deep learning model
CN115860177A (en) Photovoltaic power generation power prediction method based on combined machine learning model and application thereof
CN114648170A (en) Reservoir water level prediction early warning method and system based on hybrid deep learning model
CN114386693B (en) Reservoir water level prediction and early warning method based on PSO-LSTM-Attention model
Dong et al. Short-term building cooling load prediction model based on DwdAdam-ILSTM algorithm: A case study of a commercial building
CN113469427A (en) Convolution LSTM-based photovoltaic power station day-ahead power generation amount prediction method and system
CN113988210A (en) Method and device for restoring distorted data of structure monitoring sensor network and storage medium
CN118469352B (en) Deep learning driven power grid line loss dynamic prediction and optimization control method
CN116341613A (en) Ultra-short-term photovoltaic power prediction method based on Informar encoder and LSTM
CN113053113A (en) PSO-Welsch-Ridge-based anomaly detection method and device
CN115755219A (en) Flood forecast error real-time correction method and system based on STGCN
CN115481788A (en) Load prediction method and system for phase change energy storage system
CN115423146A (en) Self-adaptive runoff forecasting method based on multi-factor nearest neighbor sampling regression and support vector machine
CN114648095A (en) Air quality concentration inversion method based on deep learning
CN117578441A (en) Method for improving power grid load prediction precision based on neural network
CN118017482A (en) Flexible climbing capacity demand analysis method based on prediction error feature extraction
CN116960962A (en) Mid-long term area load prediction method for cross-area data fusion

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant