Reservoir water level prediction and early warning method based on improved particle swarm Conv1D-Attention optimization model

By improving the particle swarm Conv1D-Attention optimization model and combining the time factor and water level component, the problem of inability to predict reservoir water level changes in advance in the existing technology is solved, achieving accurate prediction of reservoir water level and extreme weather warning, and improving the efficiency of reservoir management. Security.

CN114781699BActive Publication Date: 2024-08-23FUJIAN ZHONGRUI NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210345951.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-31
Publication Date
2024-08-23
Estimated Expiration
2042-03-31

AI Technical Summary

Technical Problem

Existing reservoir water level dispatching technology cannot effectively utilize historical data and the influence relationship between different characteristic dimensions, and cannot predict the changing trend of reservoir water levels in advance, resulting in the inability to respond to extreme weather in advance.

Method used

The improved particle swarm Conv1D-Attention optimization model was used to build the Conv1D-Attention model through feature engineering and data reshaping. The improved particle swarm optimization algorithm was used to optimize the parameters of the model, and the time factor and water level component were combined to predict the reservoir water level.

Benefits of technology

It improves the accuracy of reservoir water level prediction, provides reliable extreme weather warning data, and ensures the safety of reservoir water levels in extreme weather.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114781699B
    Figure CN114781699B
Patent Text Reader

Abstract

The present invention relates to a reservoir water level prediction and early warning method based on an improved particle swarm Conv1D-Attention optimization model, comprising the following steps: step S1: obtaining reservoir water level related data, and preprocessing to obtain an initial data set; step S2: based on the initial data set, performing feature engineering processing to obtain a feature data set; step S3: dividing the feature data set into a training set and a test set, and performing data reshaping to reshape 2D data into 3D data; step S4: constructing a Conv1D-Attention model; step S5: optimizing the Conv1D-Attention model by adopting an improved PSO optimization algorithm; step S6: constructing and training an improved particle swarm Conv1D-Attention optimization model based on the optimal parameters obtained in step S6; step S7: predicting the reservoir water level by using the improved particle swarm Conv1D-Attention optimization model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of reservoir water level prediction and early warning, and in particular to a reservoir water level prediction and early warning method based on an improved particle swarm Conv1D-Attention optimization model. Background Art

[0002] The existing reservoir water level scheduling technology is based on the collected reservoir water level monitoring data and rainfall, and then relies on manual experience and simple mathematical derivation formulas to schedule the reservoir water level to the reservoir safe water level.

[0003] The historical water level of the reservoir, flood discharge, meteorological data, etc. are important influencing factors of the reservoir water level change. Relying on manual experience and simple mathematical derivation formulas, it is easy to ignore some important factors that affect the reservoir water level change. At the same time, it is impossible to explore and use historical data and the influence relationship between different feature dimensions, and it is impossible to grasp the future trend of reservoir water level changes in advance. Therefore, this method can only perform real-time scheduling of the reservoir water level, but cannot schedule the reservoir water level in advance to cope with future extreme weather. Summary of the invention

[0004] In view of this, the purpose of the present invention is to provide a reservoir water level prediction and early warning method based on an improved particle swarm Conv1D-Attention optimization model, which can accurately and effectively predict the reservoir water level and provide reliable data for extreme weather warnings.

[0005] To achieve the above object, the present invention adopts the following technical solution:

[0006] A reservoir water level prediction and early warning method based on an improved particle swarm Conv1D-Attention optimization model includes the following steps:

[0007] Step S1: Obtaining reservoir water level related data and preprocessing to obtain an initial data set;

[0008] Step S2: Based on the initial data set, feature engineering processing is performed to obtain a feature data set;

[0009] Step S3: Divide the feature data set into a training set and a test set, and reshape the data to reshape the 2D data into 3D data;

[0010] Step S4: Construct Conv1D-Attention model;

[0011] Step S5: Use the improved PSO optimization algorithm to optimize the Conv1D-Attention model;

[0012] Step S5: Based on the optimal parameters obtained in step S5, construct and train an improved particle swarm Conv1D-Attention optimization model;

[0013] Step S6: Predict the reservoir water level by optimizing the model based on the improved particle swarm Conv1D-Attention.

[0014] Furthermore, the reservoir water level related data includes collection time, reservoir water level, flood discharge and rainfall.

[0015] Furthermore, the preprocessing is specifically as follows:

[0016] Step S11: reducing the collection time of reservoir water level, flood discharge and rainfall to the same precision, and using the collection time as a keyword to connect the data;

[0017] Step S12: after the connection is completed, the data set is sorted by acquisition time in ascending order;

[0018] Step S13: Fill in the missing values ​​to obtain the initial data set.

[0019] Furthermore, the step S2 is specifically as follows:

[0020] Step S21: constructing a time-effect component based on the initial data set;

[0021] Step S22: Based on the initial data set, water level feature transformation is performed;

[0022] Step S23: normalize the data set to obtain a feature data set.

[0023] Furthermore, the functional expression of the time-effect component is constructed as follows:

[0024] f(β)=a1β+a2lnβ

[0025] Where a1 and a2 are coefficients, t is the cumulative number of days from the monitoring day to the start of observation. According to f(β) and the reservoir water level observation time, the time-effect component is constructed to obtain two time-effect factors, β and lnβ.

[0026] Furthermore, the water level characteristic transformation, the function expression of the characteristic transformation is as follows:

[0027]

[0028] The reservoir water level data collection time is T t (t=0, 1, 2, ..., n), T0~T n Reservoir water level during the period, Hi for Any non-empty subset of , W is the reservoir water level;

[0029] According to f(W), the reservoir water level characteristics are transformed to obtain W1, W2, and W3 respectively:

[0030]

[0031] Furthermore, the data reshaping is specifically as follows: assuming that the number of original data samples is samples, the features are time_effcent, rainfall, flood_Discharge, water_ago1Level, water_ago2Level, and water_Level, the 2D shape of the original data is (samples, features), and the 3D shape after reshaping is (samples, width, features). After reshaping, there are N=(samples-width+1) data units.

[0032] Furthermore, the Conv1D-Attention model includes an Input layer, a first Conv1D stacked layer, a second Conv1D stacked layer, a Flatten layer, and a Dense stacked layer;

[0033] The first Conv1D stacking layer consists of two Conv1D layers, one Attention layer, and one Maxpooling1D layer; the second Conv11D stacking layer consists of two Conv1D layers and one Maxpooling1D layer.

[0034] Furthermore, the Conv1D-Attention model is constructed as follows:

[0035] Step S41: read the data reshaped in step S3 into the Input layer of the Conv1D-Attention model;

[0036] Step S42: The first Conv1D stacked layer obtains the data in the Input layer, and uses the Conv1D convolutional layer with a convolution kernel of (4,3) to extract features from the data. After the extraction is completed, the data is input into the Conv1D convolutional layer with a convolution kernel of (3,3) to perform secondary feature extraction on the data;

[0037] The data after the secondary feature extraction is input into the Attention layer. The Attention layer will give corresponding weights to the data feature units according to the attention mechanism to mark the importance of different data feature units to the prediction target.

[0038] The maximum pooling layer obtains the data weighted by the Attention layer and performs maximum pooling. After pooling, it is input into the second Conv11D stacking layer.

[0039] Step S43: The second Conv11D stacked layer obtains the data processed in step S42 and inputs it into the second Conv1D stacked layer with a convolution kernel of (6,3) to further extract data features. After the extraction is completed, it is input into the Conv1D layer with a convolution kernel of (5,3) for final feature extraction, and performs maximum pooling. After the pooling is completed, it is input into the Flatten layer;

[0040] Step S44: Flatten the data after pooling using the Flatten layer, that is, convert the multi-dimensional input into one dimension;

[0041] Step S45: Obtain the data flattened by the Flatten layer and use the Dense stacking layer to specify the data shape of the prediction sequence output.

[0042] Furthermore, the step S5 uses an improved PSO optimization algorithm to optimize the four hyper parameters of the Conv1D-Attention model: sliding window width, number of neurons in the fully connected layer, learning rate, and batch_size, as follows:

[0043] Step S51: Set the number of iterations, population size, and search dimension of the improved PSO

[0044] Step S52: Obtain the Conv1D-Attention model, and replace the four hyperparameters of the model, namely, the sliding window width, the number of neurons in the fully connected layer, the learning rate, and the batch_size, with the unknown numbers c[0] to c[3]. After the replacement, set the model MSE to the return value;

[0045] Step S53: According to the hyperparameters that need to be optimized for the objective function, the initialization position and speed of each dimension of the population particles are limited, that is, the optimization range. After the limitation is completed, the initialization is performed, and the initialization parameters are assigned to the objective function c[0]~c[3], the Conv1D-Attention model is executed, and the MSE finally returned by the model is obtained;

[0046] Step S54: limit the search position and speed of each dimension of the population according to the objective function. After the setting is completed, obtain the hyperparameters of the particle searched for the MSE closest to zero in step S53, and record the position and speed of the particle;

[0047] Step S55: Perform the first round of iteration. When a particle with an MSE closer to zero appears, update the recorded hyperparameters, and re-record the particle position and velocity. Repeat until the preset requirements are met to obtain the optimal parameters.

[0048] Compared with the prior art, the present invention has the following beneficial effects:

[0049] 1. The present invention uses the CAC (Conv1D-Attention-Conv1D) architecture, and adds an attention mechanism on the basis of Conv1D feature extraction, thereby performing Conv1D feature extraction again. After two feature extractions, more important information for predicting reservoir water levels is effectively obtained;

[0050] 2. In the process of training the improved particle swarm Conv1D-Attention optimization model, the present invention mines the timeliness factor that can reflect the change of the reservoir water level on the time axis and the water level component that can reflect the change relationship of the historical water level according to the data collection time and the historical reservoir water level, and incorporates the timeliness factor and the water level component into the model for training, which effectively improves the prediction accuracy of the model;

[0051] 3. The present invention can accurately and effectively predict reservoir water levels and provide reliable data for early warning of extreme weather. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 The method flow chart of the present invention is

[0053] Figure 2 It is a remodeling process in one embodiment of the present invention;

[0054] Figure 3 It is the Conv1D+Attention model architecture in one embodiment of the present invention;

[0055] Figure 4 It is an improved PSO optimization framework in one embodiment of the present invention. DETAILED DESCRIPTION

[0056] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.

[0057] Please refer to Figure 1 The present invention provides a reservoir water level prediction and early warning method based on an improved particle swarm Conv1D-Attention optimization model, comprising the following steps:

[0058] Step S1: Obtaining reservoir water level related data and preprocessing to obtain an initial data set;

[0059] Step S2: Based on the initial data set, feature engineering processing is performed to obtain a feature data set;

[0060] Step S3: Divide the feature data set into a training set and a test set, and reshape the data to reshape the 2D data into 3D data;

[0061] Step S4: Construct Conv1D-Attention model;

[0062] Step S5: Use the improved PSO optimization algorithm to optimize the Conv1D-Attention model;

[0063] Step S5: Based on the optimal parameters obtained in step S5, construct and train an improved particle swarm Conv1D-Attention optimization model;

[0064] Step S6: Predict the reservoir water level by optimizing the model based on the improved particle swarm Conv1D-Attention.

[0065] In this embodiment, the reservoir water level related data includes collection time, reservoir water level, flood discharge and rainfall.

[0066] In this embodiment, the preprocessing is specifically as follows:

[0067] Step S11: reducing the collection time of reservoir water level, flood discharge and rainfall to the same precision, and using the collection time as a keyword to connect the data;

[0068] Step S12: after the connection is completed, the data set is sorted by acquisition time in ascending order;

[0069] Step S13: Fill in the missing values ​​to obtain the initial data set.

[0070] Preferably, since data changes are greatly affected by the previous day, missing values ​​are filled with the previous value of the missing value.

[0071] In this embodiment, step S2 is specifically as follows:

[0072] Construct the time-effect component. The time-effect component describes the change of the reservoir water level over time. It is an expression of the change of the reservoir water level caused by comprehensive factors and is the most complex factor affecting the change of the reservoir water level. The constructed function expression is as follows:

[0073] f(β)=a1β+a2lnβ

[0074] Where a1 and a2 are coefficients, t is the cumulative number of days from the monitoring day to the start of observation. According to f(β) and the observation time of reservoir water level, the time-effect component is constructed to obtain two time-effect factors, β and lnβ.

[0075] Water level characteristic transformation: It describes the relationship between the reservoir water level over time and its historical reservoir water level. It is a pre-factor of reservoir water level change and reflects the trend and speed of water level change. The functional expression of its characteristic transformation is as follows:

[0076]

[0077] The reservoir water level data collection time is T t (t=0, 1, 2, ..., n), T0~T n Reservoir water level during the period, H i for Any non-empty subset of , W is the reservoir water level. According to f(W), the reservoir water level characteristics are transformed to obtain W1, W2, and W3 respectively:

[0078]

[0079] Because the collected data values ​​are large, the values ​​and units of different features are different, so the data values ​​need to be compressed to save network computing resources and eliminate the deviation caused by the dimension. Since the reservoir water level data is relatively concentrated and there are fewer outliers, the maximum and minimum values ​​are used for normalization. The function expression is as follows;

[0080]

[0081] where x ij is the value of a single data, min(X j ) is the minimum value of the jth feature, max(X j ) is the j-th feature maximum value.

[0082] In order to test the generalization ability of the model, the data set needs to be divided into a training set and a test set, where the first 70% of the data is used as the training model and the last 30% is used as the test model.

[0083] In this embodiment, the above data is read in. The data is in 2D shape, and the PSO-Conv1D model improved based on the attention mechanism can only read 3D data. Therefore, it is necessary to reshape the 2D data into 3D data. The detailed reshaping process is shown in the figure below:

[0084] In the figure, the number of original data samples is samples, and the features are time_effcent, rainfall, flood_Discharge, water_ago1Level, water_ago2Level, and water_Level. The original data has a 2D shape of (samples, features), and after reshaping, its 3D shape is (samples, width, features). After reshaping, there are N = (samples-width+1) data units.

[0085] refer to Figure 3 In this embodiment, the Conv1D-Attention model includes an Input layer, a first Conv1D stacked layer, a second Conv1D stacked layer, a Flatten layer, and a Dense stacked layer; the first Conv1D stacked layer consists of two Conv1D layers, one Attention layer, and one Maxpooling1D layer; the second Conv11D stacked layer consists of two Conv1D layers and one Maxpooling1D layer.

[0086] Furthermore, the Conv1D-Attention model is constructed as follows:

[0087] Step S41: read the data reshaped in step S3 into the Input layer of the Conv1D-Attention model;

[0088] Step S42: The first Conv1D stacked layer obtains the data in the Input layer, and uses the Conv1D convolutional layer with a convolution kernel of (4,3) to extract features from the data. After the extraction is completed, the data is input into the Conv1D convolutional layer with a convolution kernel of (3,3) to perform secondary feature extraction on the data;

[0089] The data after the secondary feature extraction is input into the Attention layer. The Attention layer will give corresponding weights to the data feature units according to the attention mechanism to mark the importance of different data feature units to the prediction target.

[0090] The maximum pooling layer obtains the data weighted by the Attention layer and performs maximum pooling. After pooling, it is input into the second Conv11D stacking layer.

[0091] Step S43: The second Conv11D stacked layer obtains the data processed in step S42 and inputs it into the second Conv1D stacked layer with a convolution kernel of (6,3) to further extract data features. After the extraction is completed, it is input into the Conv1D layer with a convolution kernel of (5,3) for final feature extraction, and performs maximum pooling. After the pooling is completed, it is input into the Flatten layer;

[0092] Step S44: Flatten the data after pooling using the Flatten layer, that is, convert the multi-dimensional input into one dimension;

[0093] Step S45: Obtain the data flattened by the Flatten layer and use the Dense stacking layer to specify the data shape of the prediction sequence output.

[0094] refer to Figure 4 In this embodiment, step S5 uses the improved PSO optimization algorithm to optimize the four hyper parameters of the Conv1D-Attention model, namely, the sliding window width, the number of neurons in the fully connected layer, the learning rate, and the batch_size, as follows:

[0095] Step S51: Set the number of iterations, population size, and search dimension of the improved PSO

[0096] Step S52: Obtain the Conv1D-Attention model, and replace the four hyperparameters of the model, namely, the sliding window width, the number of neurons in the fully connected layer, the learning rate, and the batch_size, with the unknown numbers c[0] to c[3]. After the replacement, set the model MSE to the return value;

[0097] Step S53: According to the hyperparameters that need to be optimized for the objective function, the initialization position and speed of each dimension of the population particles are limited, that is, the optimization range. After the limitation is completed, the initialization is performed, and the initialization parameters are assigned to the objective function c[0]~c[3], the Conv1D-Attention model is executed, and the MSE finally returned by the model is obtained;

[0098] Step S54: limit the search position and speed of each dimension of the population according to the objective function. After the setting is completed, obtain the hyperparameters of the particle searched for the MSE closest to zero in step S53, and record the position and speed of the particle;

[0099] Step S55: Perform the first round of iteration. When a particle with an MSE closer to zero appears, update the recorded hyperparameters, and re-record the particle position and velocity. Repeat until the preset requirements are met to obtain the optimal parameters.

[0100] In this embodiment, preferably, the improved PSO adopts a new inertia weight iteration method, and the function expression is as follows:

[0101]

[0102] Among them, iter is the current iteration number, iter max is the final number of iterations, ω max is the maximum inertia weight, ω min is the minimum inertia weight, σ is the expansion coefficient, the value range is (0, +∞), and it is generally set to 5; θ is the deformation coefficient, the value range is (-1, +∞), and it is generally set to 0.

[0103] Formula (1) uses the tangent function to map the number of iterations to the entire real number interval;

[0104] Formula (2) is derived from the variation of the sigmoid function, which retains some properties of the sigmoid function and can map the real number H in formula (1) to a set weight value range. The scaling factor σ can control the shape of the function. The smaller the value, the smoother the decrease of the inertia weight.

[0105] Formula (3) can change the shape of the function by adjusting the deformation coefficient θ. When the value is in the interval (-1, 0), the nodes with rapidly decreasing inertia weights are delayed, and the PSO algorithm pays more attention to the global optimization ability, and the corresponding local convergence ability will be reduced. When the value is in the interval (0, +∞), the nodes with rapidly decreasing inertia weights are advanced. At this time, the PSO algorithm pays more attention to the local convergence ability, and it is easier to fall into the local optimum.

[0106] When σ=5 and θ=0, the inertia weight ω change curve is formed;

[0107] In this embodiment, based on the CPSO (chaotic particle swarm algorithm) particle mutation method, a new mutation discrimination method is proposed, and its specific process is as follows:

[0108] When ω<0.9ω max +0.1ω min , the position of the best particle in the mutated population is changed to make it jump out of the current local optimum. The mutation method is as follows:

[0109]

[0110] in, is a random number in the interval [0, 1], iter max is the maximum number of iterations, iter is the current number of iterations, G iter is the global historical optimal position after iteration iter times.

[0111] When ω<0.1ω max +0.9ω min, mutate the position of the worst particle in the population, make it jump to the vicinity of its historical optimal point, and find the local optimal point. The mutation method is as follows:

[0112]

[0113] in, is a random number in the interval [0, 1], iter max is the maximum number of iterations, iter is the current number of iterations, P i is the historical optimal position of the particle after iteration iter times.

[0114] In this embodiment, the optimal hyperparameters are brought into the model, and the training set is input for model verification to verify the generalization ability of the model. The trained and verified model is saved to the cloud or locally for use in subsequent projects.

[0115] Embodiment 1:

[0116] In this embodiment, Kafka is used to read the reservoir monitoring data. The producer produces and pushes the messages read from the stream data to the Broker by calling the python API related to Kafka. The consumer uses the corresponding partition allocation strategy to pull the stream data from the broker through the pull operation.

[0117] Load the improved particle swarm Conv1D-Attention optimization model stored in the cloud or trained locally. After the model is loaded, get the data pulled out by the pull operation and input it into the model to predict the reservoir water level.

[0118] According to the predicted value of the reservoir water level, it is compared with the reservoir water level management standard. If the predicted water level is within the normal range, the gate can be opened normally; if the predicted water level is not within the normal range, it is compared with the reservoir water level management early warning standard, and the reservoir parameter information and early warning level are returned. The reservoir water level is dispatched according to the returned reservoir parameters such as rainfall, flood discharge, reservoir water level, early warning level and other parameters to control the reservoir water level within a safe range. After the dispatch is completed, the process ends.

[0119] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the present invention.

Claims

1. A reservoir water level prediction and early warning method based on improved particle swarm Conv1 D-Attention optimization model, It is characterized in that The following steps are involved: Step S1: Obtaining reservoir water level related data and preprocessing to obtain an initial data set; Step S2: Based on the initial data set, feature engineering processing is performed to obtain a feature data set; Step S3: Divide the feature data set into a training set and a test set, and reshape the data to reshape the 2D data into 3D data; Step S4: Construct Conv1D-Attention model; Step S5: Use the improved PSO optimization algorithm to optimize the Conv1D-Attention model; Step S6: Based on the optimal parameters obtained in step S5, construct and train an improved particle swarm Conv1D-Attention optimization model; Step S7: predicting the reservoir water level by optimizing the model based on the improved particle swarm Conv1D-Attention; The step S2 is specifically as follows: Step S21: constructing a time-effect component based on the initial data set; Step S22: Based on the initial data set, water level feature transformation is performed; Step S23: normalizing the data set to obtain a feature data set; The functional expression of the time-effect component is as follows: f(β)=a 1 b+a 2 lnβ where a 1 , a 2 is the coefficient, t' is the cumulative number of days from the monitoring day to the start of observation; according to f(β) and the reservoir water level observation time, the time-effect component is constructed to obtain two time-effect factors, β and lnβ; The water level characteristic transformation, The function expression of its feature transformation is as follows: The reservoir water level data collection time is T t (t=0, 1, 2, ..., n), T 0 ~T n Reservoir water level during the period, H i for Any non-empty subset of , W is the reservoir water level; According to f(W), the reservoir water level characteristics are transformed to obtain W 1 ,W 2 ,W 3 They are: The Conv1D-Attention model includes an Input layer, a first Conv1D stacked layer, a second Conv1D stacked layer, a Flatten layer, and a Dense stacked layer; The first Conv1D stacking layer consists of two Conv1D layers, one Attention layer, and one Maxpooling1D layer; the second Conv1D stacking layer consists of two Conv1D layers and one Maxpooling1D layer; The Conv1D-Attention model is constructed as follows: Step S41: read the data reshaped in step S3 into the Input layer of the Conv1D-Attention model; Step S42: The first Conv1D stacked layer obtains the data in the Input layer, and uses the Conv1D convolutional layer with a convolution kernel of (4,3) to extract features from the data. After the extraction is completed, the data is input into the Conv1D convolutional layer with a convolution kernel of (3,3) to perform secondary feature extraction on the data; The data after secondary feature extraction is input into the Attention layer. The Attention layer will give corresponding weights to the data feature units according to the attention mechanism to mark the importance of different data feature units to the prediction target. The maximum pooling layer obtains the data given weights by the Attention layer and performs maximum pooling. After pooling, it is input into the second Conv1D stacking layer. Step S43: The second Conv1D stacked layer obtains the data processed in step S42 and inputs it into the second Conv1D stacked layer with a convolution kernel of (6,3) to further extract data features. After the extraction is completed, it is input into the Conv1D with a convolution kernel of (5,3) for final feature extraction, and performs maximum pooling. After the pooling is completed, it is input into the Flatten layer; Step S44: Flatten the data after pooling using the Flatten layer, that is, convert the multi-dimensional input into one dimension; Step S45: Obtain the data flattened by the Flatten layer and use the Dense stacking layer to specify the data shape of the prediction sequence output.

2. According to claim 1, the reservoir water level prediction and early warning method based on the improved particle swarm Conv1D-Attention optimization model, It is characterized in that The reservoir water level related data include collection time, reservoir water level, flood discharge and rainfall.

3. The reservoir water level prediction and early warning method based on the improved particle swarm Conv1D-Attention optimization model according to claim 2, It is characterized in that The preprocessing is specifically as follows: Step S11: reducing the collection time of reservoir water level, flood discharge and rainfall to the same precision, and using the collection time as a keyword to connect the data; Step S12: after the connection is completed, the data set is sorted by acquisition time in ascending order; Step S13: fill in the missing values ​​to obtain the initial data set.

4. The reservoir water level prediction and early warning method based on the improved particle swarm Conv1D-Attention optimization model according to claim 1, It is characterized in that The data reshaping is specifically as follows: assuming that the number of original data samples is samples, the features features are time_effcent, rainfall, flood_Discharge, water_ago1Level, water_ago2Level, and water_Level, the original data 2D shape is (samples, features), and the reshaped 3D shape is (samples, width, features). After reshaping, there are N = (samples-width+1) data units.

5. The reservoir water level prediction and early warning method based on the improved particle swarm Conv1D-Attention optimization model according to claim 1, It is characterized in that The step S5 uses the improved PSO optimization algorithm to optimize the four hyper parameters of the Conv1D-Attention model: sliding window width, number of neurons in the fully connected layer, learning rate, and batch_size, as follows: Step S51: setting the number of iterations, population size, and search dimension of the improved PSO; Step S52: Obtain the Conv1D-Attention model, and replace the four hyperparameters of the model, namely, the sliding window width, the number of neurons in the fully connected layer, the learning rate, and the batch_size, with the unknown numbers c[0] to c[3]. After the replacement, set the model MSE to the return value; Step S53: According to the hyperparameters that need to be optimized for the objective function, the initialization position and speed of each dimension of the population particles are limited, that is, the optimization range; after the limitation is completed, initialization is performed, and the initialization parameters are assigned to the objective function c[0]~c[3], the Conv1D-Attention model is executed, and the MSE finally returned by the model is obtained; Step S54: limit the search position and speed of each dimension of the population according to the objective function. After the setting is completed, obtain the hyperparameters of the particle searched for the MSE closest to zero in step S53, and record the position and speed of the particle; Step S55: Perform the first round of iteration. When a particle with an MSE closer to zero appears, update the recorded hyperparameters, and re-record the particle position and velocity. Repeat until the preset requirements are met to obtain the optimal parameters.