Reservoir water temperature machine learning prediction method considering vertical-discharged water temperature linkage of reservoir area

By constructing a dual-task LSTM model, which shares features and extracts vertical and downstream water temperatures in parallel, the problem of insufficient dynamic boundary adaptability and generalization ability of reservoir water temperature prediction methods is solved, and efficient and accurate water temperature prediction is achieved.

CN121743773APending Publication Date: 2026-03-27CHINA HYDROELECTRIC ENGINEERING CONSULTING GROUP CHENGDU RESEARCH HYDROELECTRIC INVESTIGATION DESIGN AND INSTITUTE
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-30
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing methods for predicting reservoir water temperature are ill-suited to dynamic boundary conditions. Single-task machine learning models do not consider the cascading relationship between vertical water temperature in the reservoir area and downstream water temperature, resulting in insufficient generalization ability and low prediction efficiency.

Method used

A dual-task LSTM model is constructed. Common time-series features of vertical water temperature and outflow water temperature in the reservoir area are extracted through a shared feature extraction module. A weighted fusion loss function is used for collaborative optimization to achieve synchronous and efficient prediction of the two types of water temperatures.

Benefits of technology

It strengthens physical process constraints, improves prediction fidelity and efficiency, simplifies model structure, optimizes generalization ability, adapts to complex dynamic scenarios, and supports diverse engineering needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121743773A_ABST
    Figure CN121743773A_ABST
Patent Text Reader

Abstract

The invention relates to a reservoir water resource management technology, discloses a reservoir water temperature machine learning prediction method considering reservoir area vertical-discharged water temperature linkage, and solves the problems that numerical simulation in an existing reservoir water temperature prediction method is difficult to adapt to a dynamic boundary; and a machine learning single-task model does not consider the cascade relationship between the vertical water temperature and the discharged water temperature of the reservoir area, so that the generalization ability is insufficient, and the prediction efficiency is low. According to the scheme, firstly, monitoring data related to the water temperature of the reservoir are collected and preprocessed, and a data set is obtained; then, constructing an LSTM model architecture of'shared feature extraction + dual-task output '; then training the dual-task LSTM model by using the data set; in practical application, historical time sequence data of the preprocessed water temperature correlation indexes are input, and vertical water temperature data and discharged water temperature data in a future time period are obtained based on the trained double-task LSTM model.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to reservoir water resource management technology, and in particular to a reservoir water temperature machine learning prediction method considering reservoir vertical-discharge water temperature linkage. BACKGROUND

[0002] As a key water conservancy project for comprehensive utilization of water resources regulation, flood control, power generation, irrigation and water supply, the water temperature distribution characteristics of reservoirs directly affect the ecological environment and water resource utilization efficiency of the river basin. The construction of dams changes the hydraulic characteristics of natural river channels, slows down the flow velocity of the reservoir area, increases the water depth, and forms a clear vertical temperature gradient under the action of thermal stratification, i.e., the vertical water temperature stratification phenomenon in the reservoir area. This stratification structure not only affects the water quality evolution inside the reservoir area, but also causes the discharged water temperature to exhibit characteristics that are completely different from those of natural river channels through the dispatching mode of the reservoir water intake. In spring and summer, the discharged water temperature is lower than the natural water temperature, and in autumn and winter, it is higher than the natural water temperature.

[0003] Water temperature is a core control factor of biological chemical and physiological processes in river ecosystems, and abnormal changes in reservoir water temperature can cause a series of ecological and environmental problems. For example, low-temperature water discharged in summer can destroy the spawning environment of downstream fish, leading to delayed spawning and decreased hatching rate, and thus affecting the population structure of fish; the stable thermocline formed by the vertical water temperature stratification in the reservoir area can provide suitable conditions for the growth of algae, increasing the risk of algae outbreaks and threatening drinking water safety and ecological balance in the reservoir area. Therefore, accurate prediction of the vertical water temperature in the reservoir area and the discharged water temperature is of great significance for providing scientific basis for reservoir water temperature regulation, alleviating the negative effects of abnormal water temperature on the ecosystem, and ensuring ecological safety in the river basin.

[0004] Currently, reservoir water temperature regulation decisions mainly rely on numerical simulation results during the design phase of the reservoir. Traditional numerical simulation methods are based on static boundary conditions (such as fixed inflow, inflow water temperature, meteorological conditions, and discharge) in a typical year to construct the model. Although these methods can reflect the water temperature distribution under specific working conditions, they are difficult to adapt to the dynamic changes in boundary conditions during actual reservoir operation, leading to deviations between the actual water temperature regulation effect and the expected effect. In addition, numerical simulation methods involve complex fluid mechanics and thermodynamics equation solving, and the calculation process is time-consuming, which cannot quickly respond to the demand for water temperature prediction under dynamic boundaries.

[0005] To solve the limitations of traditional numerical simulation methods, researchers have begun to explore reservoir water temperature rapid prediction techniques based on machine learning algorithms, and have developed single-task prediction models for reservoir vertical water temperature and discharged water temperature. However, existing machine learning methods have obvious defects: they ignore the inherent physical correlation of reservoir water temperature changes, only model the response relationship between boundary conditions and a single water temperature indicator (vertical water temperature or discharged water temperature), and do not fully exploit the cascading influence mechanism of boundary conditions-reservoir vertical water temperature-discharged water temperature - that is, the distribution of reservoir vertical water temperature directly determines the water temperature at the depth of the water intake, which in turn affects the discharged water temperature. This single-task modeling approach lacks constraints on intermediate physical processes, resulting in weak adaptability to complex conditions and insufficient generalization performance, making it difficult to maintain stable prediction accuracy in different reservoirs or different operating scenarios.

[0006] Therefore, there is still room for improvement in dynamic adaptability, prediction efficiency and generalization ability of existing reservoir water temperature prediction methods, and a technical solution that takes into account the correlation between reservoir vertical water temperature and discharged water temperature and achieves efficient and accurate simultaneous prediction is urgently needed to meet the engineering needs of actual reservoir water temperature regulation. SUMMARY

[0007] The technical problem to be solved by the present application is to provide a reservoir water temperature machine learning prediction method considering the linkage of reservoir vertical-discharged water temperature, which solves the problems of insufficient generalization ability and low prediction efficiency caused by the inability of numerical simulation to adapt to dynamic boundaries and the lack of consideration of the cascading relationship between reservoir vertical water temperature and discharged water temperature in single-task machine learning models.

[0008] The technical solution adopted by the present application to solve the above technical problem is:

[0009] A reservoir water temperature machine learning prediction method considering the linkage of reservoir vertical-discharged water temperature, comprising the following steps:

[0010] S1. Collecting reservoir water temperature related monitoring data and performing preprocessing to obtain a dataset;

[0011] S2. Building a double-task LSTM model, the model including an input layer, a shared feature extraction module and a double-task output module, the input layer receiving standardized input sequences, the shared feature extraction module extracting common time series features in the input sequences that are effective for both types of water temperature prediction, and the double-task output module constructing a vertical water temperature prediction branch and a discharged water temperature prediction branch based on common features to realize double-task parallel output;

[0012] S3. Training the built double-task LSTM model based on the dataset;

[0013] S4. Input the pre-processed water temperature correlation index historical time series data, and obtain the vertical water temperature data and the outflow water temperature data in the future time period based on the trained double-task LSTM model.

[0014] Further, in step S1, the reservoir water temperature related monitoring data includes reservoir vertical water temperature data and outflow water temperature data as prediction label values, and water temperature correlation index data as input features, including reservoir operation index data and meteorological condition data.

[0015] The reservoir operation index data includes inflow water temperature, inflow flow, outflow flow and / or reservoir water level; and the meteorological condition data includes air temperature, dew point, wind speed, wind direction and / or solar radiation.

[0016] Further, the reservoir vertical water temperature data is the water temperature data at D monitoring depths in the reservoir area, in the format of time series [T, D], wherein T is the total number of time steps, and D is the number of data in a single time step, i.e. the number of monitoring depths.

[0017] The outflow water temperature data is single-point water temperature data at the water intake of the reservoir, in the format of time series [T, 1].

[0018] The data format of the water temperature correlation index data is time series [T, F], wherein F is the number of correlation indexes.

[0019] Further, in step S1, the pre-processing includes missing value processing, data sequence construction, data set division and standardization processing.

[0020] The missing value processing adopts linear interpolation or mean filling method to complete the missing values in the input features and the prediction labels.

[0021] The data sequence construction adopts sliding window method to construct the input and output sequences of the model, sets the historical window length look_back and the prediction step predict_step, the input sequence takes the input features at the i-th to i+look_back-1-th time steps, in the format of [look_back, F]; the reservoir vertical water temperature output sequence takes the vertical water temperature data at the i+look_back-th to i+look_back+predict_steps-1-th time steps, in the format of [predict_steps, D]; and the outflow water temperature output sequence takes the outflow water temperature data at the i+look_back-th to i+look_back+predict_steps-1-th time steps, in the format of [predict_steps, 1].

[0022] The data set division is performed in time sequence, and the proportions of the training set, the validation set and the test set are 6:2:2.

[0023] The standardization processing is based on the training set data to construct a Z-score standardizer to standardize the input features, the vertical water temperature label and the outflow water temperature label respectively.

[0024] Further, in the double-task LSTM model constructed in step S2, the shared feature extraction module includes a batch normalization sublayer, a shared LSTM sublayer and a Dropout regularization sublayer; the batch normalization sublayer performs batch normalization processing on the data transmitted by the input layer; the shared LSTM sublayer sets 2-3 layers of LSTM network hidden layers, the dimension value range of each layer of LSTM network hidden layer is 64-256, and each layer is set to return sequence return_sequences=True, so that the LSTM sublayer outputs the complete feature sequence of each time step, and the output dimension is [look_back,hidden_size], wherein hidden_size is the hidden layer dimension; the Dropout regularization sublayer is set after each shared LSTM sublayer, and the dropout rate dropout_rate takes a value of 0.2-0.3.

[0025] Further, in the double-task LSTM model constructed in step S2, the vertical water temperature prediction branch in the double-task output module is connected to a fully connected layer at the output end of the shared feature extraction module, the input dimension of the fully connected layer is [look_back,hidden_size], the features of the last predict_steps time steps are extracted for mapping calculation, and the output dimension is set to [predict_steps,D] to obtain the vertical water temperature prediction value; the outflow water temperature prediction branch is set in parallel with the vertical water temperature prediction branch, the input dimension of the fully connected layer thereof is [look_back,hidden_size], the features of the last predict_steps time steps are extracted for mapping, and the output dimension is set to [predict_steps,1] to obtain the outflow water temperature prediction value.

[0026] Further, in step S3, the double-task LSTM model constructed based on the data set is trained, including:

[0027] The training set is used to train the model, the model parameters are optimized through the validation set, and finally the test set is used to test the model performance; a double-task fusion loss function is used in the training process, and the formula is:

[0028] ;

[0029] Wherein, Loss( ) is a loss calculation function of a single task, and a mean square error is used. 、 is a double-task weight coefficient, satisfying Y1_true and Y2_true are true values of the vertical water temperature in the reservoir area and the discharged water temperature, i.e., prediction label values;

[0030] Y1_pred and Y2_pred are prediction values of the vertical water temperature in the reservoir area and the discharged water temperature.

[0031] Further, the model parameter optimization through the verification set comprises: through a trial-and-error method, a grid search or a Bayesian optimization method, key hyperparameters are optimized with the prediction accuracy of the verification set as a target, the hyperparameters to be optimized include: a historical window length look_back, a prediction step predict_steps and a shared LSTM layer hidden layer dimension hidden_size, and finally, a hyperparameter combination that minimizes the MAE and RMSE of the verification set is determined, so that an optimized double-task LSTM model is obtained.

[0032] The present application has the following advantages:

[0033] (1) Strengthening the physical process constraint and improving the prediction fidelity:

[0034] The present application fully excavates the cascading correlation of the boundary condition, i.e., the vertical water temperature in the reservoir area and the discharged water temperature, and through a double-task fusion loss function, the prediction errors of the two types of water temperatures are mutually constrained, so that the model is more in line with the actual physical mechanism of the water temperature change, the deviation between the prediction result and the actual working condition is effectively reduced, and the prediction value is more in line with the actual evolution law of the reservoir water temperature.

[0035] (2) Simplifying the model structure and reducing the training complexity:

[0036] The present application adopts an architecture design of shared feature extraction + double-task output, extracts common time sequence features required for the prediction of the two types of water temperatures through a shared LSTM module, avoids the redundant design of constructing single-task models for the vertical water temperature and the discharged water temperature respectively, greatly reduces the total amount of model parameters, and reduces the data demand and the training cost.

[0037] (3) Double-task parallel prediction, improving the prediction efficiency:

[0038] The model in the present application can synchronously output the prediction results of the vertical water temperature at multiple depths in the reservoir area and the discharged water temperature, and does not need to run different models twice for separate prediction, compared with the traditional single-task prediction method, the prediction efficiency is improved by more than 30%, and the real-time scheduling demand of the reservoir can be quickly responded.

[0039] (4) Optimizing the generalization ability and adapting to complex dynamic scenarios:

[0040] The shared feature extraction module in the model of this invention introduces batch standardization and Dropout regularization mechanisms to effectively suppress model overfitting. At the same time, by fully utilizing the inherent correlation between the two types of water temperature through dual-task collaborative optimization, the model can better adapt to the dynamic changes of boundary parameters such as inflow and meteorological conditions, and maintain stable prediction accuracy under different reservoir types and different operating conditions.

[0041] (5) Supports flexible adaptation to meet diverse engineering needs:

[0042] The weight coefficients in the dual-task fusion loss function of this invention can be flexibly adjusted according to the actual engineering priorities. For example, when downstream water temperature prediction is more critical to downstream ecological protection, its weight can be increased to prioritize ensuring the accuracy of downstream water temperature prediction; if reservoir water quality control needs to be taken into account, a balanced weight configuration can be adopted. This makes the model adaptable to diverse application scenarios such as reservoir ecological scheduling, water quality control, and irrigation water supply, thus enhancing its practicality. Attached Figure Description

[0043] Figure 1 This is a flowchart of the reservoir water temperature machine learning prediction method that considers the linkage between vertical and downstream water temperature in the reservoir area, as described in this invention.

[0044] Figure 2 The predicted label water temperature data collected in this embodiment of the invention includes the vertical water temperature distribution in front of the dam and the downstream water temperature distribution, wherein the vertical water temperature in front of the dam consists of water depths of 1m, 5m, 10m, 15m, 25m, 35m, 45m, 55m, and 65m.

[0045] Figure 3 This is a diagram of the dual-task LSTM model architecture for predicting vertical and downstream water temperatures, designed in an embodiment of the present invention.

[0046] Figure 4 This is a scatter plot of the predicted and actual values ​​of vertical water temperature in the validation set for the model in this embodiment of the invention.

[0047] Figure 5 This is a scatter plot of the predicted and actual values ​​of the discharge water temperature in the validation set, as shown in the embodiment of the present invention.

[0048] Figure 6 This is a scatter plot of the predicted and actual values ​​of vertical water temperature in the test set, as shown in the embodiment of the present invention.

[0049] Figure 7 This is a scatter plot of the predicted and actual values ​​of the discharge water temperature in the test set, as shown in this embodiment of the invention. Detailed Implementation

[0050] This invention aims to provide a machine learning method for predicting reservoir water temperature that considers the linkage between vertical and outflow water temperatures. It addresses the problems of existing reservoir water temperature prediction methods, such as the difficulty of numerical simulation adapting to dynamic boundaries and the insufficient generalization ability and low prediction efficiency of single-task machine learning models that fail to consider the cascading relationship between vertical and outflow water temperatures. The core idea is to construct a dual-task LSTM artificial neural network model with shared feature extraction based on the cascading correlation characteristics of vertical and outflow water temperatures. Through collaborative optimization, it achieves simultaneous, efficient, and accurate prediction of both types of water temperatures.

[0051] Specifically, the technical means employed by this invention to achieve the above-mentioned core ideas include:

[0052] (1) In view of the shortcomings of existing methods that ignore the cascade relationship between boundary conditions, vertical water temperature in the reservoir area and outflow water temperature, the two types of water temperature prediction are integrated into a dual task instead of being modeled independently, based on the physical nature that the vertical water temperature distribution in the reservoir area directly determines the outflow water temperature at the intake. This makes the model prediction more in line with the actual water temperature evolution law.

[0053] (2) Design a core architecture of shared feature extraction + dual task output. By using a shared LSTM network module to extract common time series features that are effective for both types of water temperature prediction from input features such as inflow and air temperature, parameter redundancy is reduced. At the same time, vertical water temperature and outflow water temperature prediction branches are set in parallel to achieve simultaneous output of two types of key water temperature data in one model run, taking into account both prediction efficiency and correlation.

[0054] (3) Construct a weighted fusion loss function to incorporate the prediction errors of the two types of water temperatures into a unified optimization objective. Enhance the model’s understanding of the physical process through mutual constraints and improve prediction accuracy. At the same time, support flexible adjustment of the weight coefficients of the two tasks. It can be adapted to different prediction scenarios according to engineering needs, taking into account both versatility and practicality.

[0055] In practical implementation, the implementation process of the reservoir water temperature machine learning prediction method considering the linkage between vertical and downstream water temperature provided by this invention is as follows: Figure 1 It includes the following steps:

[0056] S1. Collection and preprocessing of reservoir water temperature related monitoring data:

[0057] The purpose of this step is to collect monitoring data related to reservoir water temperature and preprocess the data into a complete, reasonable dataset suitable for the LSTM model construction requirements in step S2. More specifically, this step includes the following sub-steps:

[0058] S1.1 Collect reservoir water temperature related monitoring data, including the vertical water temperature data and outflow water temperature data of the reservoir area as the predicted label values ​​of the model in step S2, as well as the input feature values ​​of the model in step S2. Among them, the vertical water temperature data (Y1) is the water temperature data of D monitoring depths in the vertical direction of the reservoir area, in the format of time series [T,D] (T is the total number of time steps, and D is the number of data in a single time step); the outflow water temperature data (Y2) is the single-point water temperature data of the reservoir intake, in the format of [T,1]; the input feature values ​​(X) include, but are not limited to, F-type indicators that affect the reservoir water temperature, such as inflow water temperature, inflow rate, outflow rate, reservoir water level, air temperature, dew point, wind speed, wind direction, and solar radiation, in the format of time series [T,F].

[0059] S1.2 Data preprocessing includes the following steps:

[0060] a) The first step in monitoring data preprocessing is to handle missing values ​​by using linear interpolation or mean imputation to fill in the missing values ​​in the input features and predicted label data.

[0061] b) The second step in monitoring data preprocessing involves constructing data sequences. The sliding window method is used to construct the input and output sequences of the LSTM model. The historical window length look_back and the prediction step size predict_step are set. The input sequence takes the input features from the i-th to i+look_back-1 time steps, in the format [look_back,F]. The vertical water temperature output sequence of the reservoir area takes the vertical water temperature data from the i+look_back to i+look_back+predict_steps-1 time steps, in the format [predict_steps,D]. The discharge water temperature output sequence takes the discharge water temperature data from the i+look_back to i+look_back+predict_steps-1 time steps, in the format [predict_steps,1].

[0062] c) The third step of monitoring data preprocessing is to divide the data obtained in S1.3 into training set (60%), validation set (20%) and test set (20%) in chronological order.

[0063] d) The fourth step in monitoring data preprocessing is to standardize the data. Based on the training set data, a standardizer (Z-score) is constructed to standardize the input feature X, vertical water temperature label Y1, and downstream water temperature label Y2 respectively, so as to avoid the difference in units affecting the model training.

[0064] S2. Construct a dual-task LSTM model:

[0065] The purpose of this step is to construct an LSTM model architecture based on the preprocessed S1 dataset, featuring "shared feature extraction + dual-task output," to achieve simultaneous prediction of vertical water temperature and outflow water temperature in the reservoir area. More specifically, this step includes the following sub-steps:

[0066] S2.1 Constructing the Model Input Layer: The input layer receives the standardized input sequence constructed in S1.2. The input dimension matches the input sequence format, i.e., [look_back, F], to ensure that the preprocessed data can be successfully passed into the model for feature extraction.

[0067] S2.2 Building a Shared Feature Extraction Module: This module is used to extract common time series features from the input sequence that are effective for both types of water temperature prediction, specifically including:

[0068] a) Batch Normalization Sublayer: The input data is processed by batch normalization (BatchNorm1d). By normalizing the data distribution, the convergence speed of the model in the subsequent training process is accelerated, and the problem of low training efficiency caused by data distribution differences is avoided.

[0069] b) Shared LSTM sub-layers: Set up 2-3 layers of LSTM network as the core feature extraction unit. The hidden_size dimension of each LSTM hidden layer ranges from 64 to 256, which can be adjusted according to the data scale and prediction accuracy requirements. Each layer is set to return_sequences=True, so that the LSTM sub-layer outputs the feature sequence of each time step with the dimension [look_back, hidden_size], instead of only outputting the features of the last time step, providing complete time dimension feature support for the subsequent dual task output.

[0070] c) Dropout Regularization Sublayer: After each layer shares an LSTM sublayer, a Dropout layer is added with dropout_rate set to 0.2~0.3. By randomly dropping some neuron connections, the overfitting phenomenon that may occur during model training is suppressed, and the generalization ability of the model is improved.

[0071] S2.3 Design of a Dual-Task Output Module: This module, based on the common features output by the shared feature extraction module, constructs prediction branches for vertical water temperature and downstream water temperature respectively, achieving parallel output of dual tasks. Specifically, it includes:

[0072] a) Vertical water temperature prediction branch: A fully connected layer is connected to the output of the shared feature extraction module. The input dimension of the fully connected layer is [look_back, hidden_size], and the output dimension is set to [predict_steps, D]. Only the features of the last predict_steps time steps in the shared feature sequence are extracted for mapping calculation. The final output is a predicted value (Y1_pred) that matches the format of the vertical water temperature output sequence in S1.2.

[0073] b) Downstream water temperature prediction branch: This branch is set up in parallel with the vertical water temperature prediction branch. It is also connected to a fully connected layer at the output of the shared feature extraction module. The input dimension of this fully connected layer is [look_back, hidden_size], and the output dimension is set to [predict_steps, 1]. Similarly, it extracts the features of the last predict_steps time steps in the shared feature sequence and maps them to output a predicted value (Y2_pred) that matches the format of the downstream water temperature output sequence in S1.2.

[0074] S2.4 Define the dual-task fusion loss function: To achieve collaborative optimization of the two types of water temperature prediction tasks, a weighted fusion total loss function is constructed, as shown in the following formula:

[0075] ;

[0076] Where Loss() is the loss calculation function for a single task, using mean squared error (MSE); , For dual-task weight coefficients, satisfying It can achieve balanced optimization of the two types of tasks according to actual engineering needs. For example, when the priority of downstream water temperature prediction is higher than that of vertical water temperature, it can be set as follows: , By default .

[0077] S3. Training and optimization of dual-task LSTM models:

[0078] The purpose of this step is to train the dual-task LSTM model constructed in S2 based on the training and validation sets partitioned by S1, and to improve the model's prediction accuracy and generalization ability through hyperparameter tuning and training strategy optimization, thereby obtaining the optimal model that meets the needs of practical applications. More specifically, this step includes the following sub-steps:

[0079] S3.1 Model Compilation Configuration: The Adam optimizer is used as the optimization algorithm for model training. The initial learning rate is adjusted according to the data volume. When the data volume is large, the learning rate can be appropriately increased. The typical range is 0.0001~0.001. The Total_Loss defined in S2.4 is used as the target loss function for model compilation to complete the parameter configuration before model training.

[0080] S3.2 Setting training control parameters and callback functions:

[0081] a) Basic training parameter settings: Set the batch size (batch_size) to 32~64 (32 when the data volume is small, and 64 when the data volume is large), and the number of training epochs (epochs) to 50~200 (initially set to 200, and training is dynamically terminated through a callback function).

[0082] b) Add a training callback function:

[0083] i) Early Stop Callback Function: Monitors the change in Total_Loss of the validation set. When patience = 10~20 (i.e., the Total_Loss of the validation set has no decreasing trend within 10~20 consecutive epochs), it automatically stops model training and restores the model weights when the Total_Loss of the validation set is at its minimum during training, thus avoiding overfitting due to overtraining.

[0084] ii) Learning rate decay callback function (ReduceLROnPlateau): Monitors the validation set Total_Loss. When Total_Loss of the validation set does not decrease for 5 consecutive epochs, the current learning rate is halved. The minimum learning rate is set to 0.000001 to prevent the model from failing to converge to the optimal solution due to an excessively high learning rate in the later stages of training.

[0085] S3.3 Execute the model training process: Input the training set (input sequence + dual-task prediction label) divided in S1.2 into the compiled model, and use the validation set as the accuracy monitoring data during the training process. Start the model training, and automatically execute the callback function set in S3.2 during the training process to dynamically adjust the training state until the training is terminated.

[0086] S3.4 Model Hyperparameter Tuning: With the prediction accuracy of the validation set as the target (using mean absolute error (MAE) and root mean square error (RMSE) as evaluation metrics), key hyperparameters are optimized through trial and error, grid search, or Bayesian optimization. The hyperparameters to be optimized include: historical window length (look_back), prediction step size (predict_steps), and hidden layer dimension (hidden_size) of the shared LSTM layer. Finally, the combination of hyperparameters that minimizes the MAE and RMSE of the validation set is determined, resulting in the optimized dual-task LSTM model.

[0087] S4. Model Prediction and Evaluation:

[0088] The purpose of this step is to use the optimized dual-task LSTM model (S3) to predict the test set data partitioned by S1, output the water temperature prediction results through inverse standardization and accuracy evaluation, and verify the model's practicality. More specifically, this step includes the following sub-steps:

[0089] S4.1 Execute Model Prediction Inference: The test set input sequence, which has been standardized by S1.2, is fed into the dual-task LSTM model optimized by S3. The model automatically performs feature extraction and dual-task prediction calculation, and simultaneously outputs the vertical water temperature prediction sequence (Y1_pred, format [predict_steps,D]) and the downstream water temperature prediction sequence (Y2_pred, format [predict_steps,1]) of the test set.

[0090] S4.2 Destandardization of Prediction Results: The standardizer constructed in S1.2 (corresponding to input feature X, vertical water temperature Y1, and downstream water temperature Y2, respectively) is called to perform destandardization calculation on Y1_pred and Y2_pred output from S4.1. Through the inverse operation of the standardization formula (original value = predicted standardized value × standard deviation + mean), the prediction result is restored from the standardized dimensionless value to the true water temperature value (unit: ℃), ensuring that the output result meets the requirements of the actual engineering data format.

[0091] S4.3 Prediction Result Accuracy Evaluation: Based on the true labels of the test set in S1.2 (true value of vertical water temperature Y1_true, true value of outflow water temperature Y2_true) and the predicted values ​​after destandardization in S4.2 (Y1_pred, Y2_pred), the accuracy index of the two types of water temperature prediction is calculated using mean absolute error (MAE) and root mean square error (RMSE). The calculation results are used to verify whether the model prediction accuracy meets the actual engineering requirements. If the accuracy does not meet the standards, return to step S3 to re-adjust hyperparameters or optimize the model structure.

[0092] Based on the above steps, a dual-task LSTM model that meets the actual engineering needs can be obtained. After being deployed in a real-world application scenario, it can perform prediction tasks. That is, by inputting preprocessed historical time-series data of water temperature correlation indicators, the vertical water temperature data and downstream water temperature data for future time periods can be obtained based on the trained dual-task LSTM model.

[0093] Example:

[0094] This embodiment uses a reservoir as the research object, collecting daily average monitoring data from the reservoir for 3795 days, from January 2, 2011 to May 23, 2021, to train a dual-task LSTM model. The implementation process of this embodiment is as follows:

[0095] S1. Collection and preprocessing of reservoir water temperature-related data:

[0096] S1.1 Collect relevant monitoring data on reservoir water temperature:

[0097] The data involved in this embodiment includes the daily average vertical water temperature upstream of the dam, the outflow water temperature, the inflow water temperature, the inflow rate, the outflow rate, the reservoir water level, the air temperature, the dew point, the wind speed, the wind direction, and the solar radiation from January 2, 2011 to May 23, 2021. All data were provided by the reservoir management office of this embodiment, and the data source is the standardized monitoring equipment deployed by the reservoir management office, specifically including:

[0098] Input feature data (X): covering 9 categories of indicators, including inflow temperature (inflow_temp), inflow rate (inflow_q), outflow rate (outflow_q), reservoir water level (water_level), air temperature (air_temp), dew point (dew_temp), wind speed (wind_speed), wind direction (wind_dir), and solar radiation (solar), with the data format being [3795,9].

[0099] Predictive label data, including vertical water temperature data of the reservoir area and downstream water temperature data, is distributed as follows: Figure 2 As shown, the specific acquisition method and data format are as follows:

[0100] Vertical water temperature data in the reservoir area (Y1): The vertical temperature chain was monitored by a floating device fixed 200m in front of the dam. Temperature probes were placed at water depths of 1m, 5m, 10m, 15m, 25m, 35m, 45m, 55m and 65m, for a total of 9 monitoring depths. The data format is [3795,9].

[0101] Downstream water temperature data (Y2): Temperature probe monitoring data at 50m downstream of the dam, data format is [3795,1].

[0102] S2.2 Data Preprocessing:

[0103] First, the missing values ​​in the collected data are processed. Since there are few missing values, linear interpolation is used to complete the data. Then, the sliding window method was used to construct the sequence, setting the historical window length look_back=30 and the prediction step size predict_step=7. This means that the vertical water temperature of the reservoir area and the outflow water temperature for the next 7 days are predicted using 30 days of historical data. The input feature values ​​consist of 9 categories: inflow water temperature, inflow rate, outflow rate, reservoir water level, air temperature, dew point, wind speed, wind direction, and solar radiation. The data sequence format for each time step is [30, 9]. The vertical water temperature data of the reservoir area is obtained from 9 temperature probes, and its data sequence format for each time step is [7, 9]. The outflow water temperature data is obtained from 1 temperature probe downstream of the dam, and its data sequence format for each time step is [7, 1]. Then, the data is divided into a training set (60%), a validation set (20%), and a test set (20%) according to the time sequence. Finally, the data is standardized. A standardizer is constructed based on the training set data, that is, the mean and standard deviation of the training set data are used to standardize the training set, validation set, and test set data respectively. The formula is: ;

[0104] In the formula, For data that needs to be standardized, The mean of this type of data in the training set. The standard deviation of this type of data in the training set. for Standardized data.

[0105] S2. Dual-task LSTM model construction:

[0106] The construction process of a dual-task LSTM model is as follows: Figure 3 As shown, the details are as follows:

[0107] S2.1 Model Input Layer:

[0108] The input layer receives the standardized input sequence with the input dimension set to [30,9], consistent with the input sequence format, to ensure that the data is successfully passed to the subsequent feature extraction module.

[0109] S2.2 Shared Feature Extraction Module:

[0110] Batch standardization sublayer: The BatchNorm1d layer is used to standardize the input data, normalize the data distribution, and accelerate model convergence.

[0111] Shared LSTM sublayers: Two LSTM layers are set as the core feature extraction units. The hidden layer dimension of each layer is hidden_size=128. Each layer is set return_sequences=True and the output dimension is [30,128], preserving the complete time dimension features.

[0112] Dropout Regularization Sublayer: Add a Dropout layer after each LSTM sublayer, setting dropout_rate=0.25 to randomly drop some neuron connections and suppress overfitting.

[0113] S2.3 Dual-Task Output Module:

[0114] Vertical water temperature prediction branch: A fully connected layer is connected to the output of the shared feature extraction module. The input dimension is [30, 128]. The features of the last 7 time steps are extracted for mapping calculation. The output dimension is set to [7, 9] to match the format of the vertical water temperature output sequence.

[0115] Downstream water temperature prediction branch: Set in parallel with the vertical water temperature prediction branch, the fully connected layer has an input dimension of [30, 128] and an output dimension of [7, 1]. The feature maps of the last 7 time steps are extracted to output the predicted downstream water temperature value.

[0116] S2.4 Dual-Task Fusion Loss Function:

[0117] The total loss function using weighted fusion is adopted to take into account the collaborative optimization of the two types of water temperature prediction tasks, and the formula is as follows:

[0118] ;

[0119] To achieve a balanced optimization of both vertical water temperature and outflow water temperature tasks, the following approach is adopted: .

[0120] S3. Model Training and Optimization:

[0121] S3.1 model compilation configuration:

[0122] The Adam optimizer was used, with an initial learning rate of 0.0005 and Total_Loss as the target loss function to complete the model training parameter configuration.

[0123] S3.2 Training Control Parameters and Callback Function Settings:

[0124] Basic training parameters: batch size = 64, number of training epochs = 200.

[0125] Callback function:

[0126] Early Stop Callback Function: Monitors the validation set Total_Loss, patience=15, and stops training when there is no decrease for 15 consecutive epochs, restoring the optimal model weights.

[0127] The learning rate decay callback function (ReduceLROnPlateau) halves the learning rate when the validation set Total_Loss does not decrease for 5 consecutive epochs. The minimum learning rate is set to 0.000001.

[0128] S3.3 Model Training and Hyperparameter Tuning:

[0129] The training set input sequence and dual-task labels are fed into the model, and the training accuracy is monitored using the validation set. The training process is executed, and a callback function is triggered to dynamically adjust the training state. Using the mean absolute error (MAE) and root mean square error (RMSE) of the validation set as targets, a grid search method is used to optimize the key hyperparameters, ultimately determining the optimal hyperparameter combination: look_back=30, predict_steps=7, hidden_size=128.

[0130] The scatter distribution of the actual and predicted vertical water temperature values ​​in the reservoir area is verified as follows: Figure 4 As shown, the actual and predicted values ​​of the discharged water temperature are as follows: Figure 5 As shown, the mean MAE of the vertical water temperature prediction in the validation set reservoir area is 1.45℃, and the mean RMSE is 1.76℃; the MAE of the downstream water temperature prediction in the validation set is 1.19℃, and the RMSE is 1.42℃.

[0131] S4. Model Prediction and Evaluation:

[0132] S4.1 Model Predictive Inference:

[0133] The standardized test set input sequence is fed into the optimized dual-task LSTM model. The model automatically performs feature extraction and dual-task prediction calculation, and simultaneously outputs the vertical water temperature prediction sequence (Y1_pred, format [7,9]) and the downstream water temperature prediction sequence (Y2_pred, format [7,1]).

[0134] S4.2 Prediction Results Destandardization:

[0135] The normalizer built during the training phase is invoked, and the predicted normalized values ​​are restored to the true water temperature values ​​(unit: °C) through inverse operation. The inverse operation formula is as follows: .

[0136] S4.3 Prediction Result Accuracy Assessment:

[0137] Based on the actual labels and denormalized predicted values ​​of the test set, the prediction accuracy was evaluated using MAE and RMSE. The scatter distribution of the actual and predicted values ​​of the vertical water temperature in the test set reservoir is shown below. Figure 6 As shown, the actual and predicted values ​​of the discharged water temperature are as follows: Figure 7 As shown, the average MAE of the vertical water temperature prediction in the test set reservoir area was 1.87℃, and the average RMSE was 2.20℃; the MAE of the downstream water temperature prediction in the test set was 1.68℃, and the RMSE was 1.95℃.

[0138] The prediction errors for both types of water temperature on the test set were small and similar to those on the validation set, meeting the accuracy requirements for water temperature prediction in practical engineering applications and verifying the reliability of the method of the present invention.

[0139] Although embodiments of the present invention have been described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the present invention, and all such changes and alterations shall not depart from the protection scope of the present invention.

Claims

1. A machine learning method for predicting reservoir water temperature considering the linkage between vertical and downstream water temperature in the reservoir area, characterized in that, Includes the following steps: S1. Collect and preprocess relevant monitoring data on reservoir water temperature to obtain a dataset; S2. Construct a dual-task LSTM model, which includes an input layer, a shared feature extraction module, and a dual-task output module. The input layer receives a standardized input sequence. The shared feature extraction module extracts common time series features from the input sequence that are effective for both types of water temperature prediction. The dual-task output module constructs a vertical water temperature prediction branch and a downstream water temperature prediction branch based on the common features to achieve parallel output of the dual tasks. S3. Train the constructed dual-task LSTM model based on the dataset; S4. Input the historical time series data of the preprocessed water temperature correlation index, and obtain the vertical water temperature data and downstream water temperature data for future time periods based on the trained dual-task LSTM model.

2. The reservoir water temperature machine learning prediction method considering the linkage between vertical and downstream water temperature in the reservoir area, as described in claim 1, is characterized in that... In step S1, the reservoir water temperature related monitoring data includes the vertical water temperature data of the reservoir area and the downstream water temperature data, which serve as the predicted label values, as well as the water temperature related index data, which serve as the input features, including reservoir operation index data and meteorological condition data. The reservoir operation index data include inflow water temperature, inflow rate, outflow rate and / or reservoir water level; the meteorological condition data include air temperature, dew point, wind speed, wind direction and / or solar radiation.

3. The reservoir water temperature machine learning prediction method considering the linkage between vertical and downstream water temperature in the reservoir area, as described in claim 2, is characterized in that... The vertical water temperature data of the reservoir area consists of water temperature data at D monitoring depths in the vertical direction of the reservoir area, in the format of a time series [T,D], where T is the total number of time steps and D is the number of data points in a single time step, i.e. the number of monitoring depths; The discharged water temperature data are single-point water temperature data at the reservoir intake, and the data format is time series [T,1]. The data format of the water temperature correlation index data is a time series [T,F], where F is the number of correlation indexes.

4. The reservoir water temperature machine learning prediction method considering the linkage between vertical and downstream water temperature in the reservoir area, as described in claim 1, is characterized in that... In step S1, the preprocessing includes: handling missing values, constructing data sequences, partitioning the dataset, and standardizing the data. The missing value processing uses linear interpolation or mean imputation to fill in the missing values ​​in the input features and predicted labels. The data sequence construction employs a sliding window method to construct the model's input and output sequences. The historical window length `look_back` and the prediction step size `predict_step` are set. The input sequence takes the input features from time step i to i+look_back-1, in the format [look_back,F]. The reservoir vertical water temperature output sequence takes the vertical water temperature data from time step i+look_back to i+look_back+predict_steps-1, in the format [predict_steps,D]. The outflow water temperature output sequence takes the outflow water temperature data from time step i+look_back to i+look_back+predict_steps-1, in the format [predict_steps,1]. The dataset was divided in chronological order, with the ratio of training set, validation set and test set being 6:2:

2. The standardization process involves constructing a Z-score standardizer based on the training set data to standardize the input features, vertical water temperature labels, and downstream water temperature labels, respectively.

5. The reservoir water temperature machine learning prediction method considering the linkage between vertical and downstream water temperature in the reservoir area, as described in claim 1, is characterized in that... In the dual-task LSTM model constructed in step S2, the shared feature extraction module includes a batch normalization sub-layer, a shared LSTM sub-layer, and a Dropout regularization sub-layer. The batch normalization sub-layer performs batch normalization processing on the data input from the input layer. The shared LSTM sub-layer sets 2-3 LSTM network hidden layers, with the dimension of each LSTM network hidden layer ranging from 64 to 256, and each layer sets return_sequences=True, so that the LSTM sub-layer outputs the complete feature sequence at each time step, with an output dimension of [look_back, hidden_size], where hidden_size is the dimension of the hidden layer. The Dropout regularization sub-layer is set after each shared LSTM sub-layer, with a dropout rate of 0.2-0.

3.

6. The reservoir water temperature machine learning prediction method considering the linkage between vertical and downstream water temperature in the reservoir area, as described in claim 5, is characterized in that... In the dual-task LSTM model constructed in step S2, the vertical water temperature prediction branch in the dual-task output module is connected to a fully connected layer at the output of the shared feature extraction module. The input dimension of this fully connected layer is [look_back, hidden_size]. It extracts the features of the last predict_steps time steps for mapping calculation, and sets the output dimension to [predict_steps, D] to obtain the vertical water temperature prediction value. The outflow water temperature prediction branch is set in parallel with the vertical water temperature prediction branch. Its fully connected layer has an input dimension of [look_back, hidden_size]. It extracts the features of the last predict_steps time steps for mapping, and sets the output dimension to [predict_steps, 1] to obtain the outflow water temperature prediction value.

7. The reservoir water temperature machine learning prediction method considering the linkage between vertical and downstream water temperature in the reservoir area, as described in claim 4, is characterized in that... In step S3, the constructed dual-task LSTM model is trained based on the dataset, including: The model is trained using the training set, optimized using the validation set, and finally tested using the test set. A dual-task fusion loss function is used during training, with the following formula: ; Where Loss() is the loss calculation function for a single task, using mean squared error; , For dual-task weight coefficients, satisfying Y1_true and Y2_true are the actual values ​​of the vertical water temperature and the outflow water temperature in the reservoir area, respectively, i.e., the predicted label values. Y1_pred and Y2_pred are the predicted values ​​of the vertical water temperature and the outflow water temperature in the reservoir area, respectively.

8. The reservoir water temperature machine learning prediction method considering the linkage between vertical and downstream water temperature in the reservoir area, as described in claim 7, is characterized in that... The optimization of model parameters using the validation set includes: targeting the prediction accuracy of the validation set, optimizing key hyperparameters through trial and error, grid search, or Bayesian optimization. The hyperparameters to be optimized include: historical window length look_back, prediction step size predict_steps, and hidden layer dimension hidden_size of the shared LSTM layer. Finally, the combination of hyperparameters that minimizes the MAE and RMSE of the validation set is determined, resulting in the optimized dual-task LSTM model.