A runoff prediction method and system based on coupling of WRF-Hydro and transformer

CN120849818BActive Publication Date: 2026-09-08FUJIAN WANFU INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510717586.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-30
Publication Date
2026-09-08
Estimated Expiration
2045-05-30

AI Technical Summary

Technical Problem

[0003]方法一:通过物理驱动的水文模型进行模拟预测,该水文模型通过对降水、地形、土地利用等参数建模,能够提供一定精度的流量预测;但该水文模型对参数的敏感性较高,如曼宁系数、土壤渗透率等参数的微小变化都会显著影响预测结果,且水文模型调参复杂、不具备强泛化能力,受限于参数设定、初始条件不确定性等问题,其在实际复杂地形区域或异常天气(如短时强降水)情况下的预测误差大,缺乏对观测值的自适应学习能力

Benefits of technology

[0078]1. A runoff prediction model is created using a parameter server based on sequentially connected WRF-Hydro and Transformer components. The loss function of the runoff prediction model is set, and the model is deployed to several worker nodes in the same cluster as the parameter server, serving as local models for each worker node. Next, a large amount of historical runoff monitoring data from different watersheds is acquired. After preprocessing the historical runoff monitoring data, a dataset is constructed. This dataset is divided into several data subsets and sent to each worker node. The worker node divides the received data subsets into training, validation, and test sets to train, validate, and test the local model. The gradient parameters of the tested local model are obtained, encrypted, and uploaded to the parameter server. The algorithm decrypts the encrypted parameters to obtain the gradient parameters, aggregates the gradient parameters to obtain the global gradient, and updates the parameters of the runoff prediction model using the global gradient to complete distributed training. Then, the Transformer in the runoff prediction model with updated parameters is compressed, and the runoff prediction model is encapsulated and deployed. Runoff prediction is then performed through the deployed runoff prediction model. In other words, runoff prediction is performed by coupling the WRF-Hydro and Transformer runoff prediction models, effectively combining the advantages of both. This allows the runoff prediction model to better cope with complex terrain areas and abnormal weather, has the ability to adaptively learn from observations, and fully considers the physical consistency of the hydrological system, thereby greatly improving the accuracy, stability, and interpretability of runoff prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120849818B_ABST
    Figure CN120849818B_ABST
Patent Text Reader

Abstract

The application provides a runoff prediction method and system based on coupling of WRF-Hydro and Transformer in the technical field of runoff prediction, and the method comprises the following steps: S1, a parameter server creates a runoff prediction model based on WRF-Hydro and Transformer and deploys the model to a plurality of working nodes; S2, a large amount of historical runoff monitoring data is acquired to construct a data set; S3, the data set is divided into a plurality of data subsets and sent to the working nodes; S4, the working nodes train, verify and test local models through the data subsets; S5, the working nodes acquire gradient parameters of the local models that pass the test, encrypt the gradient parameters into encrypted parameters and upload the encrypted parameters to the parameter server; S6, the parameter server decrypts the encrypted parameters to obtain the gradient parameters, aggregates all the gradient parameters to obtain global gradient parameters and updates parameters of the runoff prediction model; and S7, the runoff prediction model is used to perform runoff prediction. The application has the advantages that the accuracy, stability and interpretability of runoff prediction are greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of runoff prediction technology, and in particular to a runoff prediction method and system based on the coupling of WRF-Hydro and Transformer. Background Technology

[0002] Runoff forecasting, as a core component of quantitative research on hydrological cycle processes, is not only a fundamental technical support for modern water resources planning and management, but also plays an irreplaceable role in key areas such as flood control and disaster reduction, water conservancy project scheduling, and ecological flow control. With the intensification of global climate change and the combined effects of human activities, the spatiotemporal heterogeneity of watershed hydrological processes has significantly increased, posing higher accuracy requirements and more complex scenario adaptability challenges to runoff forecasting technology. Traditionally, two methods exist for runoff forecasting:

[0003] Method 1: Simulation and prediction using a physics-driven hydrological model. This model can provide a certain accuracy in flow prediction by modeling parameters such as precipitation, topography, and land use. However, this hydrological model is highly sensitive to parameters. For example, small changes in parameters such as Manning coefficient and soil permeability can significantly affect the prediction results. In addition, the hydrological model is complex to tune and lacks strong generalization ability. Due to limitations in parameter settings and uncertainties in initial conditions, its prediction error is large in actual complex terrain areas or in abnormal weather conditions (such as short-term heavy precipitation). It also lacks the ability to adaptively learn from observations.

[0004] Method 2: Deep learning-based prediction methods predict runoff by capturing long-term temporal dependence features. Although this method can improve prediction accuracy, it often ignores the physical consistency of the hydrological system, resulting in a lack of interpretability and physical constraints in the results.

[0005] Therefore, how to provide a runoff prediction method and system based on the coupling of WRF-Hydro and Transformer to improve the accuracy, stability and interpretability of runoff prediction has become an urgent technical problem to be solved. Summary of the Invention

[0006] The technical problem to be solved by the present invention is to provide a runoff prediction method and system based on WRF-Hydro and Transformer coupling, so as to improve the accuracy, stability and interpretability of runoff prediction.

[0007] In a first aspect, the present invention provides a runoff prediction method based on WRF-Hydro and Transformer coupling, comprising the following steps:

[0008] Step S1: The parameter server creates a runoff prediction model based on the sequentially connected WRF-Hydro and Transformer, sets the loss function of the runoff prediction model, and deploys the runoff prediction model to several working nodes in the same cluster as the parameter server as the local model of each working node.

[0009] Step S2: Obtain a large amount of historical runoff monitoring data from different watersheds, and construct a dataset after preprocessing the historical runoff monitoring data.

[0010] Step S3: Divide the dataset into several data subsets and send each data subset to a working node.

[0011] Step S4: The working node divides the received data subset into a training set, a validation set, and a test set, and uses the training set, validation set, and test set to train, validate, and test the local model respectively.

[0012] Step S5: The working node obtains the gradient parameters of the local model that has passed the test, encrypts the gradient parameters into encrypted parameters, and uploads the encrypted parameters to the parameter server.

[0013] Step S6: The parameter server decrypts the received encrypted parameters to obtain gradient parameters, aggregates the gradient parameters to obtain a global gradient, and updates the parameters of the runoff prediction model through the global gradient to complete distributed training.

[0014] Step S7: Compress the Transformer in the runoff prediction model after parameter update, then encapsulate and deploy the runoff prediction model, and perform runoff prediction through the deployed runoff prediction model.

[0015] Furthermore, in step S1, the WRF-Hydro is used to simulate the input runoff monitoring data to obtain a first runoff prediction result; the Transformer is used to infer the runoff monitoring data and the first runoff prediction result to obtain a second runoff prediction result.

[0016] The Transformer is built based on an encoder and a decoder;

[0017] The encoder is constructed based on a spatiotemporal multi-head self-attention layer, a spatiotemporal convolutional layer, a 3D terrain feature extraction layer, and a cross-modal feature fusion layer. The spatiotemporal multi-head self-attention layer extracts temporal dependency features and meteorological factor correlation features from the input runoff monitoring data using parallel-deployed temporal attention heads and variable attention heads, respectively. The spatiotemporal convolutional layer extracts the runoff feature matrix from the temporal dependency features and meteorological factor correlation features using cascaded 1D temporal convolutions and 2D spatial convolutions. The 3D terrain feature extraction layer extracts the terrain feature matrix from the input runoff monitoring data using a 3D dilated convolutional network. The cross-modal feature fusion layer fuses the runoff feature matrix and the terrain feature matrix using a gated cross-attention pyramid to obtain fused features.

[0018] The decoder is used to learn the fused features and the first runoff prediction result through a residual learning strategy, and output the second runoff prediction result.

[0019] The formula for the loss function is:

[0020] LOSS=ɑ*MSE(Y obs Y pred )+β*MSE(Y WRF Y pred );

[0021] Where LOSS represents the loss value of the loss function; Y obs Y represents the actual runoff value; pred Indicates the second runoff prediction result; Y WRF This represents the first runoff prediction result; α and β both represent weighting coefficients; MSE() represents the mean square error function.

[0022] Furthermore, step S2 specifically includes:

[0023] Acquire a large amount of historical runoff monitoring data from different watersheds. The historical runoff monitoring data includes at least the watershed location, watershed name, geospatial data, meteorological data, monitoring time, WRF-Hydro initialization parameters, and actual runoff value.

[0024] The geospatial data includes at least digital elevation models, land use types, soil types, slopes, river network structures, sub-basin divisions, vegetation cover, albedo, and LAI.

[0025] The meteorological data includes at least precipitation, air temperature, wind speed, specific humidity, shortwave radiation, longwave radiation, and surface air pressure;

[0026] The WRF-Hydro initialization parameters include at least the surface Manning coefficient, the channel Manning coefficient, soil hydraulic parameters, infiltration and runoff generation parameters, groundwater parameters, and the initial soil state.

[0027] The historical runoff monitoring data shall be preprocessed in at least the following ways: data cleaning, format standardization, missing value filling, and time series alignment.

[0028] The preprocessed historical runoff monitoring data are segmented based on a sliding time window. The historical runoff monitoring data of the first 72 hours are labeled as input data, and the historical runoff monitoring data of the last 24 hours are labeled as output data to construct a dataset.

[0029] Step S3 specifically involves:

[0030] The dataset is divided into several data subsets based on the number of worker nodes. Each data subset is encrypted using a homomorphic encryption algorithm and then sent to a worker node via the gRPC protocol.

[0031] Furthermore, step S4 specifically includes:

[0032] The worker node divides the received data subset into a training set, a validation set, and a test set in a ratio of 7:1.5:1.5. The local model is trained using the training set, and differential privacy constraints are incorporated during the training process until the loss value of the loss function is less than a preset loss threshold.

[0033] The trained local model is validated using the validation set to determine if the prediction accuracy is greater than a preset accuracy threshold. If not, the validation fails, and the training set is expanded for continued training. If yes, the validation passes, and:

[0034] The validated local model is tested using the test set to determine whether the confidence level is greater than a preset confidence threshold. If not, the test fails, and the training set is expanded to continue training; if yes, the test passes, and training ends.

[0035] Step S5 specifically involves:

[0036] The worker node acquires the gradient parameters of the tested local model, encrypts the gradient parameters into first-level encrypted data using the AES256 algorithm, converts the first-level encrypted data into hexadecimal data, swaps the letter A with the number 3 and the letter B with the number 8 in the hexadecimal data to obtain second-level encrypted data, encrypts the second-level encrypted data into encrypted parameters using the RC6 algorithm, and uploads the encrypted parameters to the parameter server in real time via the gRPC protocol.

[0037] Furthermore, step S6 specifically includes:

[0038] The parameter server receives the encrypted parameters uploaded by each working node, decrypts the encrypted parameters into secondary encrypted data using the RC6 algorithm, swaps the letter A and the number 3 in the secondary encrypted data, swaps the letter B and the number 8 to obtain hexadecimal data, converts the hexadecimal data into primary encrypted data, and decrypts the primary encrypted data into gradient parameters using the AES256 algorithm.

[0039] The parameter server performs a weighted average of the gradient parameters to aggregate them into a global gradient, and updates the parameters of the runoff prediction model using the global gradient to complete distributed training.

[0040] Step S7 specifically involves:

[0041] The Transformer in the runoff prediction model after parameter updates is compressed using knowledge distillation technology. The runoff prediction model is then encapsulated and deployed. An API interface for accessing the deployed runoff prediction model is set, and the runoff prediction is executed by calling the deployed runoff prediction model through the API interface.

[0042] Secondly, the present invention provides a runoff prediction system based on WRF-Hydro and Transformer coupling, comprising the following modules:

[0043] The runoff prediction model creation module is used by the parameter server to create a runoff prediction model based on the sequentially connected WRF-Hydro and Transformer, set the loss function of the runoff prediction model, and deploy the runoff prediction model to several working nodes in the same cluster as the parameter server as local models of each working node.

[0044] The dataset construction module is used to acquire a large amount of historical runoff monitoring data from different watersheds, and to construct the dataset after preprocessing the historical runoff monitoring data.

[0045] The dataset partitioning module is used to divide the dataset into several data subsets and send each data subset to a working node.

[0046] The local model training module is used by the worker node to divide the received data subset into a training set, a validation set, and a test set, and to train, validate, and test the local model using the training set, validation set, and test set, respectively.

[0047] The gradient parameter encryption upload module is used for the worker node to obtain the gradient parameters of the local model that has passed the test, encrypt the gradient parameters into encrypted parameters, and upload the encrypted parameters to the parameter server.

[0048] The parameter update module is used to decrypt the received encrypted parameters to obtain gradient parameters, aggregate the gradient parameters to obtain a global gradient, and update the parameters of the runoff prediction model through the global gradient to complete distributed training.

[0049] The runoff prediction module is used to compress the Transformer in the runoff prediction model after parameter updates, then encapsulate and deploy the runoff prediction model, and perform runoff prediction through the deployed runoff prediction model.

[0050] Furthermore, in the runoff prediction model creation module, the WRF-Hydro is used to simulate the input runoff monitoring data to obtain a first runoff prediction result; the Transformer is used to infer the runoff monitoring data and the first runoff prediction result to obtain a second runoff prediction result.

[0051] The Transformer is built based on an encoder and a decoder;

[0052] The encoder is constructed based on a spatiotemporal multi-head self-attention layer, a spatiotemporal convolutional layer, a 3D terrain feature extraction layer, and a cross-modal feature fusion layer. The spatiotemporal multi-head self-attention layer extracts temporal dependency features and meteorological factor correlation features from the input runoff monitoring data using parallel-deployed temporal attention heads and variable attention heads, respectively. The spatiotemporal convolutional layer extracts the runoff feature matrix from the temporal dependency features and meteorological factor correlation features using cascaded 1D temporal convolutions and 2D spatial convolutions. The 3D terrain feature extraction layer extracts the terrain feature matrix from the input runoff monitoring data using a 3D dilated convolutional network. The cross-modal feature fusion layer fuses the runoff feature matrix and the terrain feature matrix using a gated cross-attention pyramid to obtain fused features.

[0053] The decoder is used to learn the fused features and the first runoff prediction result through a residual learning strategy, and output the second runoff prediction result.

[0054] The formula for the loss function is:

[0055] LOSS=ɑ*MSE(Y obs Y pred )+β*MSE(Y WRF Y pred );

[0056] Where LOSS represents the loss value of the loss function; Y obs Y represents the actual runoff value; pred Indicates the second runoff prediction result; Y WRFThis represents the first runoff prediction result; α and β both represent weighting coefficients; MSE() represents the mean square error function.

[0057] Furthermore, the dataset construction module is specifically used for:

[0058] Acquire a large amount of historical runoff monitoring data from different watersheds. The historical runoff monitoring data includes at least the watershed location, watershed name, geospatial data, meteorological data, monitoring time, WRF-Hydro initialization parameters, and actual runoff value.

[0059] The geospatial data includes at least digital elevation models, land use types, soil types, slopes, river network structures, sub-basin divisions, vegetation cover, albedo, and LAI.

[0060] The meteorological data includes at least precipitation, air temperature, wind speed, specific humidity, shortwave radiation, longwave radiation, and surface air pressure;

[0061] The WRF-Hydro initialization parameters include at least the surface Manning coefficient, the channel Manning coefficient, soil hydraulic parameters, infiltration and runoff generation parameters, groundwater parameters, and the initial soil state.

[0062] The historical runoff monitoring data shall be preprocessed in at least the following ways: data cleaning, format standardization, missing value filling, and time series alignment.

[0063] The preprocessed historical runoff monitoring data are segmented based on a sliding time window. The historical runoff monitoring data of the first 72 hours are labeled as input data, and the historical runoff monitoring data of the last 24 hours are labeled as output data to construct a dataset.

[0064] The dataset partitioning module is specifically used for:

[0065] The dataset is divided into several data subsets based on the number of worker nodes. Each data subset is encrypted using a homomorphic encryption algorithm and then sent to a worker node via the gRPC protocol.

[0066] Furthermore, the local model training module is specifically used for:

[0067] The worker node divides the received data subset into a training set, a validation set, and a test set in a ratio of 7:1.5:1.5. The local model is trained using the training set, and differential privacy constraints are incorporated during the training process until the loss value of the loss function is less than a preset loss threshold.

[0068] The trained local model is validated using the validation set to determine if the prediction accuracy is greater than a preset accuracy threshold. If not, the validation fails, and the training set is expanded for continued training. If yes, the validation passes, and:

[0069] The validated local model is tested using the test set to determine whether the confidence level is greater than a preset confidence threshold. If not, the test fails, and the training set is expanded to continue training; if yes, the test passes, and training ends.

[0070] The gradient parameter encryption upload module is specifically used for:

[0071] The worker node acquires the gradient parameters of the tested local model, encrypts the gradient parameters into first-level encrypted data using the AES256 algorithm, converts the first-level encrypted data into hexadecimal data, swaps the letter A with the number 3 and the letter B with the number 8 in the hexadecimal data to obtain second-level encrypted data, encrypts the second-level encrypted data into encrypted parameters using the RC6 algorithm, and uploads the encrypted parameters to the parameter server in real time via the gRPC protocol.

[0072] Furthermore, the parameter update module is specifically used for:

[0073] The parameter server receives the encrypted parameters uploaded by each working node, decrypts the encrypted parameters into secondary encrypted data using the RC6 algorithm, swaps the letter A and the number 3 in the secondary encrypted data, swaps the letter B and the number 8 to obtain hexadecimal data, converts the hexadecimal data into primary encrypted data, and decrypts the primary encrypted data into gradient parameters using the AES256 algorithm.

[0074] The parameter server performs a weighted average of the gradient parameters to aggregate them into a global gradient, and updates the parameters of the runoff prediction model using the global gradient to complete distributed training.

[0075] The runoff prediction module is specifically used for:

[0076] The Transformer in the runoff prediction model after parameter updates is compressed using knowledge distillation technology. The runoff prediction model is then encapsulated and deployed. An API interface for accessing the deployed runoff prediction model is set, and the runoff prediction is executed by calling the deployed runoff prediction model through the API interface.

[0077] The advantages of this invention are:

[0078] 1. A runoff prediction model is created using a parameter server based on sequentially connected WRF-Hydro and Transformer components. The loss function of the runoff prediction model is set, and the model is deployed to several worker nodes in the same cluster as the parameter server, serving as local models for each worker node. Next, a large amount of historical runoff monitoring data from different watersheds is acquired. After preprocessing the historical runoff monitoring data, a dataset is constructed. This dataset is divided into several data subsets and sent to each worker node. The worker node divides the received data subsets into training, validation, and test sets to train, validate, and test the local model. The gradient parameters of the tested local model are obtained, encrypted, and uploaded to the parameter server. The algorithm decrypts the encrypted parameters to obtain the gradient parameters, aggregates the gradient parameters to obtain the global gradient, and updates the parameters of the runoff prediction model using the global gradient to complete distributed training. Then, the Transformer in the runoff prediction model with updated parameters is compressed, and the runoff prediction model is encapsulated and deployed. Runoff prediction is then performed through the deployed runoff prediction model. In other words, runoff prediction is performed by coupling the WRF-Hydro and Transformer runoff prediction models, effectively combining the advantages of both. This allows the runoff prediction model to better cope with complex terrain areas and abnormal weather, has the ability to adaptively learn from observations, and fully considers the physical consistency of the hydrological system, thereby greatly improving the accuracy, stability, and interpretability of runoff prediction.

[0079] 2. By introducing a deep learning residual learning strategy into the Transformer, the dependence on WRF-Hydro parameters is reduced, improving the robustness of the runoff prediction model; by fully utilizing historical runoff monitoring data to model nonlinear time-series characteristics through the Transformer, the predictive response capability under sudden events is significantly improved; by combining WRF-Hydro, the structural advantages of the physical model are preserved, while physical consistency constraints are introduced through residual learning strategy and multi-task loss function, balancing accuracy and interpretability.

[0080] 3. WRF-Hydro analyzes hydrological processes (such as precipitation, evaporation, and surface runoff) based on physical mechanisms, while Transformer excels at capturing nonlinear relationships in time series. The complementarity of the two can enhance the model's ability to model complex hydrological dynamics. WRF-Hydro provides spatial distribution features (such as topography and soil moisture), while Transformer captures long-term time series dependencies through a self-attention mechanism, solving the gradient decay problem in long-range prediction of traditional LSTM / GRU. The physical equation constraints of WRF-Hydro can reduce the dependence of deep learning models on the amount of data, and still maintain high prediction stability in watersheds with scarce data.

[0081] 4. By splitting the dataset into multiple working nodes, local models can be trained in parallel using cluster computing resources, significantly shortening training time; through gradient encryption upload and global aggregation, collaborative model training is achieved without sharing the original data, making it suitable for cross-institutional collaboration scenarios; the parameter server allocates data subsets according to the computing capabilities of each node, avoiding single-node bottlenecks and improving the utilization rate of cluster resources.

[0082] 5. By integrating historical data from different watersheds, the runoff prediction model learns common patterns across watersheds, enhancing its ability to predict migration to previously unseen watersheds; unified preprocessing is performed to address the heterogeneity of data from different watersheds, reducing the impact of noise on the runoff prediction model.

[0083] 6. By coupling the physical mechanism of the WRF-Hydro hydrological model with the temporal modeling capability of Transformer, a runoff prediction model with deep spatiotemporal feature fusion was constructed, which significantly improved the prediction accuracy and cross-basin generalization capability of complex hydrological dynamics. By adopting a distributed training architecture combined with a gradient encryption aggregation mechanism, the training time was greatly shortened while ensuring the privacy and security of multi-source data. Furthermore, the deployment cost was reduced through model compression technology, achieving efficient and lightweight real-time prediction. This provides a highly reliable and low-latency end-to-end solution for scenarios such as water resource management and flood warning.

[0084] 7. WRF-Hydro, as a physical model, provides the first runoff prediction result based on hydrological mechanisms, ensuring that the prediction result conforms to physical laws; Transformer, as a data-driven model, captures complex nonlinear relationships through deep learning to generate the second runoff prediction result, correcting the local bias of the physical model; the collaboration of the two models not only retains the reliability of the physical model, but also utilizes the flexibility of the data-driven model to improve the robustness of the prediction.

[0085] 8. The loss function integrates the observation error (MSE(Yobs,Ypred)) and the WRF-Hydro prediction error (MSE(YWRF,Ypred)). By balancing the contributions of the physical model and the data-driven model through the weighting coefficients α and β, it avoids overfitting or underfitting caused by a single model dominating the model.

[0086] 9. Capture the temporal evolution of runoff (e.g., peak delay) through temporal attention heads; mine the dynamic correlation between meteorological factors (e.g., precipitation, temperature) and runoff through variable attention heads to achieve multivariate coupled analysis; extract local temporal patterns (e.g., short-term rainfall impulse response) through 1D temporal convolution; capture watershed spatial heterogeneity (e.g., the influence of terrain slope on runoff) through 2D spatial convolution, and design a hierarchical expression that takes into account both temporal and spatial characteristics; and expand the receptive field by using a three-dimensional dilated convolutional network and adjusting the porosity to efficiently capture the spatial constraints of large-scale terrain features (e.g., watershed elevation, river network) on runoff, avoiding the limitations of traditional 2D convolution for modeling three-dimensional terrain data (DEM).

[0087] 10. The gated cross-attention pyramid dynamically adjusts the fusion weights of runoff features and terrain features through gating units to suppress noise interference (such as outliers in terrain data); the pyramid structure enables multi-scale feature fusion (such as matching global terrain contours with local runoff features), enhancing the model's ability to model complex terrain-runoff relationships.

[0088] 11. Gradient parameters are encrypted using AES256+RC6 dual algorithms and subjected to character substitution (e.g. This prevents the leakage of intermediate parameters and meets the requirements of high-security scenarios.

[0089] 12. Differential privacy constraints are introduced during the training phase to prevent the model from overfitting sensitive data by adding noise and to enhance generalization ability; a dynamic expansion mechanism for the validation set (automatically expanding the training set when the prediction accuracy is insufficient) and a confidence threshold test (only passing if the confidence is greater than the threshold) ensure the reliability of the model.

[0090] 13. By coupling the WRF-Hydro hydrophysical model with the Transformer deep learning algorithm, we achieve synergistic optimization of physical laws and data-driven approaches. Combining a distributed federated learning architecture (parameter server-worker node cluster) and multi-level encryption mechanisms (AES256+RC6+character permutation), we ensure the privacy and security of multi-basin data while accurately capturing the complex correlation between meteorology, topography, and runoff using spatiotemporal multi-head attention, 3D terrain feature extraction, and gated cross-modal fusion techniques. Through dynamic loss weight adjustment, differential privacy constraints, and knowledge distillation compression, we significantly improve the model's robustness, anti-overfitting ability, and lightweight deployment efficiency. Furthermore, by leveraging sliding time window data segmentation, residual learning decoders, and standardized API interface design, we achieve high-precision long-term time-series prediction, cross-basin generalization capabilities, and seamless integration with business systems. This comprehensively solves the bottleneck problems of traditional methods in terms of accuracy, security, computational efficiency, and engineering implementation. Attached Figure Description

[0091] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0092] Figure 1 This is a flowchart of a runoff prediction method based on the coupling of WRF-Hydro and Transformer according to the present invention.

[0093] Figure 2 This is a schematic diagram of the structure of a runoff prediction system based on the coupling of WRF-Hydro and Transformer according to the present invention. Detailed Implementation

[0094] The overall idea of ​​the technical solution in this application is as follows: Runoff prediction is performed by coupling the WRF-Hydro and Transformer runoff prediction models, which effectively integrates the advantages of both models. This allows the runoff prediction model to better cope with complex terrain areas and abnormal weather, has the ability to adaptively learn from observations, and fully considers the physical consistency of the hydrological system, so as to improve the accuracy, stability and interpretability of runoff prediction.

[0095] Please refer to Figures 1 to 2 As shown, a preferred embodiment of the runoff prediction method based on WRF-Hydro and Transformer coupling of the present invention includes the following steps:

[0096] Step S1: The parameter server creates a runoff prediction model based on the sequentially connected WRF-Hydro and Transformer, sets the loss function of the runoff prediction model, and deploys the runoff prediction model to several working nodes in the same cluster as the parameter server as the local model of each working node.

[0097] Step S2: Obtain a large amount of historical runoff monitoring data from different watersheds, and construct a dataset after preprocessing the historical runoff monitoring data.

[0098] Step S3: Divide the dataset into several data subsets and send each data subset to a working node.

[0099] Step S4: The working node divides the received data subset into a training set, a validation set, and a test set, and uses the training set, validation set, and test set to train, validate, and test the local model respectively.

[0100] Step S5: The working node obtains the gradient parameters of the local model that has passed the test, encrypts the gradient parameters into encrypted parameters, and uploads the encrypted parameters to the parameter server.

[0101] Step S6: The parameter server decrypts the received encrypted parameters to obtain gradient parameters, aggregates the gradient parameters to obtain a global gradient, and updates the parameters of the runoff prediction model through the global gradient to complete distributed training.

[0102] Step S7: Compress the Transformer in the runoff prediction model after parameter update, then encapsulate and deploy the runoff prediction model, and perform runoff prediction through the deployed runoff prediction model.

[0103] WRF-Hydro analyzes hydrological processes (such as precipitation, evaporation, and surface runoff) based on physical mechanisms, while Transformer excels at capturing nonlinear relationships in time series. The complementarity of the two can enhance the model's ability to model complex hydrological dynamics. WRF-Hydro provides spatial distribution features (such as topography and soil moisture), while Transformer captures long-term time series dependencies through a self-attention mechanism, solving the gradient decay problem in long-range prediction of traditional LSTM / GRU. The physical equation constraints of WRF-Hydro can reduce the dependence of deep learning models on the amount of data, and still maintain high prediction stability in watersheds with scarce data.

[0104] By splitting the dataset into multiple worker nodes, local models can be trained in parallel using cluster computing resources, significantly shortening training time. Through gradient encryption upload and global aggregation, collaborative model training without sharing the original data is achieved, making it suitable for cross-institutional collaboration scenarios. The parameter server allocates data subsets according to the computing power of each node, avoiding single-node bottlenecks and improving the utilization rate of cluster resources.

[0105] By integrating historical data from different watersheds, the runoff prediction model learns common patterns across watersheds, enhancing its ability to predict migration to previously unseen watersheds. Unified preprocessing is performed to address the heterogeneity of data from different watersheds, reducing the impact of noise on the runoff prediction model.

[0106] By coupling the physical mechanism of the WRF-Hydro hydrological model with the temporal modeling capability of Transformer, a runoff prediction model with deep spatiotemporal feature fusion was constructed, which significantly improved the prediction accuracy and cross-basin generalization capability of complex hydrological dynamics. By adopting a distributed training architecture combined with a gradient encryption aggregation mechanism, the training time was greatly shortened while ensuring the privacy and security of multi-source data. Furthermore, the deployment cost was reduced through model compression technology, achieving efficient and lightweight real-time prediction. This provides a highly reliable and low-latency end-to-end solution for scenarios such as water resource management and flood warning.

[0107] In step S1, the WRF-Hydro is used to simulate the input runoff monitoring data to obtain a first runoff prediction result; the Transformer is used to infer the runoff monitoring data and the first runoff prediction result to obtain a second runoff prediction result.

[0108] WRF-Hydro, as the physical model, provides the first runoff prediction result based on hydrological mechanisms, ensuring that the prediction result conforms to physical laws; Transformer, as the data-driven model, captures complex nonlinear relationships through deep learning to generate the second runoff prediction result, correcting the local bias of the physical model; the collaboration of the two models not only retains the reliability of the physical model, but also utilizes the flexibility of the data-driven model to improve the robustness of the prediction.

[0109] The Transformer is built based on an encoder and a decoder;

[0110] The encoder is constructed based on a spatiotemporal multi-head self-attention layer, a spatiotemporal convolutional layer, a 3D terrain feature extraction layer, and a cross-modal feature fusion layer. The spatiotemporal multi-head self-attention layer extracts temporal dependency features and meteorological factor correlation features from the input runoff monitoring data using parallel-deployed temporal attention heads and variable attention heads, respectively. The spatiotemporal convolutional layer extracts the runoff feature matrix from the temporal dependency features and meteorological factor correlation features using cascaded 1D temporal convolutions and 2D spatial convolutions. The 3D terrain feature extraction layer extracts the terrain feature matrix from the input runoff monitoring data using a 3D dilated convolutional network. The cross-modal feature fusion layer fuses the runoff feature matrix and the terrain feature matrix using a gated cross-attention pyramid to obtain fused features.

[0111] The decoder is used to learn the fused features and the first runoff prediction result through a residual learning strategy, and output the second runoff prediction result.

[0112] The formula for the loss function is:

[0113] LOSS=ɑ*MSE(Y obs Y pred )+β*MSE(Y WRF Y pred );

[0114] Where LOSS represents the loss value of the loss function; Y obs Y represents the actual runoff value; pred Indicates the second runoff prediction result; Y WRF This represents the first runoff prediction result; α and β both represent weighting coefficients; MSE() represents the mean square error function.

[0115] The loss function integrates the observation error (MSE(Yobs,Ypred)) and the WRF-Hydro prediction error (MSE(YWRF,Ypred)), and avoids overfitting or underfitting caused by a single model by using the contributions of the weighting coefficients α and β from the equilibration physical model and the data-driven model.

[0116] By introducing a deep learning residual learning strategy into the Transformer, the dependence on WRF-Hydro parameters is reduced, improving the robustness of the runoff prediction model. By fully utilizing historical runoff monitoring data to model nonlinear time-series characteristics through the Transformer, the predictive response capability under sudden events is significantly improved. By combining WRF-Hydro, the structural advantages of the physical model are preserved, while physical consistency constraints are introduced through residual learning strategy and multi-task loss function, balancing accuracy and interpretability.

[0117] This approach captures the temporal evolution of runoff (e.g., peak lag) through temporal attention heads; mines the dynamic correlation between meteorological factors (e.g., precipitation, temperature) and runoff through variable attention heads, enabling multivariate coupled analysis; extracts local temporal patterns (e.g., short-term rainfall impulse response) through 1D temporal convolution; captures watershed spatial heterogeneity (e.g., the impact of terrain slope on runoff) through 2D spatial convolution, and designs a hierarchical expression that takes into account both spatiotemporal characteristics; and employs a 3D dilated convolutional network to expand the receptive field through dilation of the dilation rate, efficiently capturing the spatial constraints of large-scale terrain features (e.g., watershed elevation, river network) on runoff, thus avoiding the limitations of traditional 2D convolution for 3D terrain data (DEM) modeling.

[0118] The gated cross-attention pyramid dynamically adjusts the fusion weights of runoff and terrain features through gating units to suppress noise interference (such as outliers in terrain data); the pyramid structure enables multi-scale feature fusion (such as matching global terrain contours with local runoff features), enhancing the model's ability to model complex terrain-runoff relationships.

[0119] Step S2 specifically involves:

[0120] Acquire a large amount of historical runoff monitoring data from different watersheds. The historical runoff monitoring data includes at least the watershed location, watershed name, geospatial data, meteorological data, monitoring time, WRF-Hydro initialization parameters, and actual runoff value.

[0121] The geospatial data includes at least a digital elevation model (DEM), land use type, soil type (such as FAO or STATSGO classification), slope, river network structure, sub-basin division, vegetation cover, albedo, and LAI (leaf area index).

[0122] The meteorological data includes at least precipitation, air temperature, wind speed, specific humidity, shortwave radiation, longwave radiation, and surface air pressure;

[0123] The WRF-Hydro initialization parameters include at least the surface Manning coefficient (OV_ROUGH surface roughness), the channel Manning coefficient (MANNING channel roughness), soil hydraulic parameters (DKSAT (saturated hydraulic conductivity), BEXP (soil porosity distribution index), SMCMAX (saturated soil water content)), infiltration and runoff generation parameters (REFKDT (infiltration adjustment factor), RETDEPRTFAC (surface water retention depth coefficient)), groundwater parameters (LKSATFAC (lateral saturated hydraulic conductivity scaling factor)), and initial soil conditions (SMCREF (reference soil moisture), SMCMAX (maximum water holding capacity)).

[0124] The historical runoff monitoring data shall be preprocessed in at least the following ways: data cleaning, format standardization, missing value filling, and time series alignment.

[0125] The preprocessed historical runoff monitoring data are segmented based on a sliding time window. The historical runoff monitoring data of the first 72 hours are labeled as input data, and the historical runoff monitoring data of the last 24 hours are labeled as output data to construct a dataset.

[0126] Step S3 specifically involves:

[0127] The dataset is divided into several data subsets based on the number of worker nodes. Each data subset is encrypted using a homomorphic encryption algorithm and then sent to a worker node via the gRPC protocol.

[0128] Step S4 specifically involves:

[0129] The worker node divides the received data subset into a training set, a validation set, and a test set in a ratio of 7:1.5:1.5. The local model is trained using the training set, and differential privacy constraints are incorporated during the training process until the loss value of the loss function is less than a preset loss threshold.

[0130] The trained local model is validated using the validation set to determine if the prediction accuracy is greater than a preset accuracy threshold. If not, the validation fails, and the training set is expanded for continued training. If yes, the validation passes, and:

[0131] The validated local model is tested using the test set to determine whether the confidence level is greater than a preset confidence threshold. If not, the test fails, and the training set is expanded to continue training; if yes, the test passes, and training ends.

[0132] Differential privacy constraints are introduced during the training phase to prevent the model from overfitting sensitive data by adding noise and to enhance generalization ability; a dynamic expansion mechanism for the validation set (automatically expanding the training set when the prediction accuracy is insufficient) and a confidence threshold test (only passing if the confidence score is greater than the threshold) ensure the reliability of the model.

[0133] Step S5 specifically involves:

[0134] The worker node acquires the gradient parameters of the tested local model, encrypts the gradient parameters into first-level encrypted data using the AES256 algorithm, converts the first-level encrypted data into hexadecimal data, swaps the letter A with the number 3 and the letter B with the number 8 in the hexadecimal data to obtain second-level encrypted data, encrypts the second-level encrypted data into encrypted parameters using the RC6 algorithm, and uploads the encrypted parameters to the parameter server in real time via the gRPC protocol.

[0135] The gradient parameters are encrypted using AES256+RC6 dual algorithms and subjected to character substitution (e.g.) This prevents the leakage of intermediate parameters and meets the requirements of high-security scenarios.

[0136] Step S6 specifically involves:

[0137] The parameter server receives the encrypted parameters uploaded by each working node, decrypts the encrypted parameters into secondary encrypted data using the RC6 algorithm, swaps the letter A and the number 3 in the secondary encrypted data, swaps the letter B and the number 8 to obtain hexadecimal data, converts the hexadecimal data into primary encrypted data, and decrypts the primary encrypted data into gradient parameters using the AES256 algorithm.

[0138] The parameter server performs a weighted average of the gradient parameters to aggregate them into a global gradient, and updates the parameters of the runoff prediction model using the global gradient to complete distributed training.

[0139] Step S7 specifically involves:

[0140] The Transformer in the runoff prediction model after parameter updates is compressed using knowledge distillation technology. The runoff prediction model is then encapsulated and deployed. An API interface for accessing the deployed runoff prediction model is set, and the runoff prediction is executed by calling the deployed runoff prediction model through the API interface.

[0141] By coupling the WRF-Hydro hydrophysical model with the Transformer deep learning algorithm, synergistic optimization of physical laws and data-driven approaches is achieved. Combining a distributed federated learning architecture (parameter server-worker node cluster) and multi-level encryption mechanisms (AES256+RC6+character permutation), the privacy and security of multi-basin data are ensured. At the same time, spatiotemporal multi-head attention, 3D terrain feature extraction, and gated cross-modal fusion techniques are used to accurately capture the complex correlation between meteorology, topography, and runoff. Through dynamic loss weight adjustment, differential privacy constraints, and knowledge distillation compression, the robustness, anti-overfitting ability, and lightweight deployment efficiency of the model are significantly improved. Furthermore, by leveraging sliding time window data segmentation, residual learning decoder, and standardized API interface design, high-precision long-term time-series prediction, cross-basin generalization ability, and seamless integration with business systems are achieved, comprehensively solving the bottleneck problems of traditional methods in terms of accuracy, security, computational efficiency, and engineering implementation.

[0142] A preferred embodiment of the runoff prediction system based on WRF-Hydro and Transformer coupling of the present invention includes the following modules:

[0143] The runoff prediction model creation module is used by the parameter server to create a runoff prediction model based on the sequentially connected WRF-Hydro and Transformer, set the loss function of the runoff prediction model, and deploy the runoff prediction model to several working nodes in the same cluster as the parameter server as local models of each working node.

[0144] The dataset construction module is used to acquire a large amount of historical runoff monitoring data from different watersheds, and to construct the dataset after preprocessing the historical runoff monitoring data.

[0145] The dataset partitioning module is used to divide the dataset into several data subsets and send each data subset to a working node.

[0146] The local model training module is used by the worker node to divide the received data subset into a training set, a validation set, and a test set, and to train, validate, and test the local model using the training set, validation set, and test set, respectively.

[0147] The gradient parameter encryption upload module is used for the worker node to obtain the gradient parameters of the local model that has passed the test, encrypt the gradient parameters into encrypted parameters, and upload the encrypted parameters to the parameter server.

[0148] The parameter update module is used to decrypt the received encrypted parameters to obtain gradient parameters, aggregate the gradient parameters to obtain a global gradient, and update the parameters of the runoff prediction model through the global gradient to complete distributed training.

[0149] The runoff prediction module is used to compress the Transformer in the runoff prediction model after parameter updates, then encapsulate and deploy the runoff prediction model, and perform runoff prediction through the deployed runoff prediction model.

[0150] WRF-Hydro analyzes hydrological processes (such as precipitation, evaporation, and surface runoff) based on physical mechanisms, while Transformer excels at capturing nonlinear relationships in time series. The complementarity of the two can enhance the model's ability to model complex hydrological dynamics. WRF-Hydro provides spatial distribution features (such as topography and soil moisture), while Transformer captures long-term time series dependencies through a self-attention mechanism, solving the gradient decay problem in long-range prediction of traditional LSTM / GRU. The physical equation constraints of WRF-Hydro can reduce the dependence of deep learning models on the amount of data, and still maintain high prediction stability in watersheds with scarce data.

[0151] By splitting the dataset into multiple worker nodes, local models can be trained in parallel using cluster computing resources, significantly shortening training time. Through gradient encryption upload and global aggregation, collaborative model training without sharing the original data is achieved, making it suitable for cross-institutional collaboration scenarios. The parameter server allocates data subsets according to the computing power of each node, avoiding single-node bottlenecks and improving the utilization rate of cluster resources.

[0152] By integrating historical data from different watersheds, the runoff prediction model learns common patterns across watersheds, enhancing its ability to predict migration to previously unseen watersheds. Unified preprocessing is performed to address the heterogeneity of data from different watersheds, reducing the impact of noise on the runoff prediction model.

[0153] By coupling the physical mechanism of the WRF-Hydro hydrological model with the temporal modeling capability of Transformer, a runoff prediction model with deep spatiotemporal feature fusion was constructed, which significantly improved the prediction accuracy and cross-basin generalization capability of complex hydrological dynamics. By adopting a distributed training architecture combined with a gradient encryption aggregation mechanism, the training time was greatly shortened while ensuring the privacy and security of multi-source data. Furthermore, the deployment cost was reduced through model compression technology, achieving efficient and lightweight real-time prediction. This provides a highly reliable and low-latency end-to-end solution for scenarios such as water resource management and flood warning.

[0154] In the runoff prediction model creation module, the WRF-Hydro is used to simulate the input runoff monitoring data to obtain a first runoff prediction result; the Transformer is used to infer the runoff monitoring data and the first runoff prediction result to obtain a second runoff prediction result.

[0155] WRF-Hydro, as the physical model, provides the first runoff prediction result based on hydrological mechanisms, ensuring that the prediction result conforms to physical laws; Transformer, as the data-driven model, captures complex nonlinear relationships through deep learning to generate the second runoff prediction result, correcting the local bias of the physical model; the collaboration of the two models not only retains the reliability of the physical model, but also utilizes the flexibility of the data-driven model to improve the robustness of the prediction.

[0156] The Transformer is built based on an encoder and a decoder;

[0157] The encoder is constructed based on a spatiotemporal multi-head self-attention layer, a spatiotemporal convolutional layer, a 3D terrain feature extraction layer, and a cross-modal feature fusion layer. The spatiotemporal multi-head self-attention layer extracts temporal dependency features and meteorological factor correlation features from the input runoff monitoring data using parallel-deployed temporal attention heads and variable attention heads, respectively. The spatiotemporal convolutional layer extracts the runoff feature matrix from the temporal dependency features and meteorological factor correlation features using cascaded 1D temporal convolutions and 2D spatial convolutions. The 3D terrain feature extraction layer extracts the terrain feature matrix from the input runoff monitoring data using a 3D dilated convolutional network. The cross-modal feature fusion layer fuses the runoff feature matrix and the terrain feature matrix using a gated cross-attention pyramid to obtain fused features.

[0158] The decoder is used to learn the fused features and the first runoff prediction result through a residual learning strategy, and output the second runoff prediction result.

[0159] The formula for the loss function is:

[0160] LOSS=ɑ*MSE(Y obs Y pred )+β*MSE(Y WRF Y pred );

[0161] Where LOSS represents the loss value of the loss function; Y obs Y represents the actual runoff value; pred Indicates the second runoff prediction result; Y WRF This represents the first runoff prediction result; α and β both represent weighting coefficients; MSE() represents the mean square error function.

[0162] The loss function integrates the observation error (MSE(Yobs,Ypred)) and the WRF-Hydro prediction error (MSE(YWRF,Ypred)), and avoids overfitting or underfitting caused by a single model by using the contributions of the weighting coefficients α and β from the equilibration physical model and the data-driven model.

[0163] By introducing a deep learning residual learning strategy into the Transformer, the dependence on WRF-Hydro parameters is reduced, improving the robustness of the runoff prediction model. By fully utilizing historical runoff monitoring data to model nonlinear time-series characteristics through the Transformer, the predictive response capability under sudden events is significantly improved. By combining WRF-Hydro, the structural advantages of the physical model are preserved, while physical consistency constraints are introduced through residual learning strategy and multi-task loss function, balancing accuracy and interpretability.

[0164] This approach captures the temporal evolution of runoff (e.g., peak lag) through temporal attention heads; mines the dynamic correlation between meteorological factors (e.g., precipitation, temperature) and runoff through variable attention heads, enabling multivariate coupled analysis; extracts local temporal patterns (e.g., short-term rainfall impulse response) through 1D temporal convolution; captures watershed spatial heterogeneity (e.g., the impact of terrain slope on runoff) through 2D spatial convolution, and designs a hierarchical expression that takes into account both spatiotemporal characteristics; and employs a 3D dilated convolutional network to expand the receptive field through dilation of the dilation rate, efficiently capturing the spatial constraints of large-scale terrain features (e.g., watershed elevation, river network) on runoff, thus avoiding the limitations of traditional 2D convolution for 3D terrain data (DEM) modeling.

[0165] The gated cross-attention pyramid dynamically adjusts the fusion weights of runoff and terrain features through gating units to suppress noise interference (such as outliers in terrain data); the pyramid structure enables multi-scale feature fusion (such as matching global terrain contours with local runoff features), enhancing the model's ability to model complex terrain-runoff relationships.

[0166] The dataset construction module is specifically used for:

[0167] Acquire a large amount of historical runoff monitoring data from different watersheds. The historical runoff monitoring data includes at least the watershed location, watershed name, geospatial data, meteorological data, monitoring time, WRF-Hydro initialization parameters, and actual runoff value.

[0168] The geospatial data includes at least a digital elevation model (DEM), land use type, soil type (such as FAO or STATSGO classification), slope, river network structure, sub-basin division, vegetation cover, albedo, and LAI (leaf area index).

[0169] The meteorological data includes at least precipitation, air temperature, wind speed, specific humidity, shortwave radiation, longwave radiation, and surface air pressure;

[0170] The WRF-Hydro initialization parameters include at least the surface Manning coefficient (OV_ROUGH surface roughness), the channel Manning coefficient (MANNING channel roughness), soil hydraulic parameters (DKSAT (saturated hydraulic conductivity), BEXP (soil porosity distribution index), SMCMAX (saturated soil water content)), infiltration and runoff generation parameters (REFKDT (infiltration adjustment factor), RETDEPRTFAC (surface water retention depth coefficient)), groundwater parameters (LKSATFAC (lateral saturated hydraulic conductivity scaling factor)), and initial soil conditions (SMCREF (reference soil moisture), SMCMAX (maximum water holding capacity)).

[0171] The historical runoff monitoring data shall be preprocessed in at least the following ways: data cleaning, format standardization, missing value filling, and time series alignment.

[0172] The preprocessed historical runoff monitoring data are segmented based on a sliding time window. The historical runoff monitoring data of the first 72 hours are labeled as input data, and the historical runoff monitoring data of the last 24 hours are labeled as output data to construct a dataset.

[0173] The dataset partitioning module is specifically used for:

[0174] The dataset is divided into several data subsets based on the number of worker nodes. Each data subset is encrypted using a homomorphic encryption algorithm and then sent to a worker node via the gRPC protocol.

[0175] The local model training module is specifically used for:

[0176] The working node divides the received data subset into a training set, a validation set, and a test set in a ratio of 7:1.5:1.5. The local model is trained using the training set, and differential privacy constraints are incorporated during the training process until the loss value of the loss function is less than a preset loss threshold.

[0177] The trained local model is validated using the validation set to determine if the prediction accuracy is greater than a preset accuracy threshold. If not, the validation fails, and the training set is expanded for continued training. If yes, the validation passes, and:

[0178] The validated local model is tested using the test set to determine whether the confidence level is greater than a preset confidence threshold. If not, the test fails, and the training set is expanded to continue training; if yes, the test passes, and training ends.

[0179] Differential privacy constraints are introduced during the training phase to prevent the model from overfitting sensitive data by adding noise and to enhance generalization ability; a dynamic expansion mechanism for the validation set (automatically expanding the training set when the prediction accuracy is insufficient) and a confidence threshold test (only passing if the confidence is greater than the threshold) ensure the reliability of the model.

[0180] The gradient parameter encryption upload module is specifically used for:

[0181] The worker node acquires the gradient parameters of the tested local model, encrypts the gradient parameters into first-level encrypted data using the AES256 algorithm, converts the first-level encrypted data into hexadecimal data, swaps the letter A with the number 3 and the letter B with the number 8 in the hexadecimal data to obtain second-level encrypted data, encrypts the second-level encrypted data into encrypted parameters using the RC6 algorithm, and uploads the encrypted parameters to the parameter server in real time via the gRPC protocol.

[0182] The gradient parameters are encrypted using AES256+RC6 dual algorithms and subjected to character substitution (e.g.) This prevents the leakage of intermediate parameters and meets the requirements of high-security scenarios.

[0183] The parameter update module is specifically used for:

[0184] The parameter server receives the encrypted parameters uploaded by each working node, decrypts the encrypted parameters into secondary encrypted data using the RC6 algorithm, swaps the letter A and the number 3 in the secondary encrypted data, swaps the letter B and the number 8 to obtain hexadecimal data, converts the hexadecimal data into primary encrypted data, and decrypts the primary encrypted data into gradient parameters using the AES256 algorithm.

[0185] The parameter server performs a weighted average of the gradient parameters to aggregate them into a global gradient, and updates the parameters of the runoff prediction model using the global gradient to complete distributed training.

[0186] The runoff prediction module is specifically used for:

[0187] The Transformer in the runoff prediction model after parameter updates is compressed using knowledge distillation technology. The runoff prediction model is then encapsulated and deployed. An API interface for accessing the deployed runoff prediction model is set, and the runoff prediction is executed by calling the deployed runoff prediction model through the API interface.

[0188] By coupling the WRF-Hydro hydrophysical model with the Transformer deep learning algorithm, synergistic optimization of physical laws and data-driven approaches is achieved. Combining a distributed federated learning architecture (parameter server-worker node cluster) and multi-level encryption mechanisms (AES256+RC6+character permutation), the privacy and security of multi-basin data are ensured. At the same time, spatiotemporal multi-head attention, 3D terrain feature extraction, and gated cross-modal fusion techniques are used to accurately capture the complex correlation between meteorology, topography, and runoff. Through dynamic loss weight adjustment, differential privacy constraints, and knowledge distillation compression, the robustness, anti-overfitting ability, and lightweight deployment efficiency of the model are significantly improved. Furthermore, by leveraging sliding time window data segmentation, residual learning decoder, and standardized API interface design, high-precision long-term time-series prediction, cross-basin generalization ability, and seamless integration with business systems are achieved, comprehensively solving the bottleneck problems of traditional methods in terms of accuracy, security, computational efficiency, and engineering implementation.

[0189] In summary, the advantages of this invention are as follows:

[0190] 1. A runoff prediction model is created using a parameter server based on sequentially connected WRF-Hydro and Transformer components. The loss function of the runoff prediction model is set, and the model is deployed to several worker nodes in the same cluster as the parameter server, serving as local models for each worker node. Next, a large amount of historical runoff monitoring data from different watersheds is acquired. After preprocessing the historical runoff monitoring data, a dataset is constructed. This dataset is divided into several data subsets and sent to each worker node. The worker node divides the received data subsets into training, validation, and test sets to train, validate, and test the local model. The gradient parameters of the tested local model are obtained, encrypted, and uploaded to the parameter server. The algorithm decrypts the encrypted parameters to obtain the gradient parameters, aggregates the gradient parameters to obtain the global gradient, and updates the parameters of the runoff prediction model using the global gradient to complete distributed training. Then, the Transformer in the runoff prediction model with updated parameters is compressed, and the runoff prediction model is encapsulated and deployed. Runoff prediction is then performed through the deployed runoff prediction model. In other words, runoff prediction is performed by coupling the WRF-Hydro and Transformer runoff prediction models, effectively combining the advantages of both. This allows the runoff prediction model to better cope with complex terrain areas and abnormal weather, has the ability to adaptively learn from observations, and fully considers the physical consistency of the hydrological system, thereby greatly improving the accuracy, stability, and interpretability of runoff prediction.

[0191] 2. By introducing a deep learning residual learning strategy into the Transformer, the dependence on WRF-Hydro parameters is reduced, improving the robustness of the runoff prediction model; by fully utilizing historical runoff monitoring data to model nonlinear time-series characteristics through the Transformer, the predictive response capability under sudden events is significantly improved; by combining WRF-Hydro, the structural advantages of the physical model are preserved, while physical consistency constraints are introduced through residual learning strategy and multi-task loss function, balancing accuracy and interpretability.

[0192] 3. WRF-Hydro analyzes hydrological processes (such as precipitation, evaporation, and surface runoff) based on physical mechanisms, while Transformer excels at capturing nonlinear relationships in time series. The complementarity of the two can enhance the model's ability to model complex hydrological dynamics. WRF-Hydro provides spatial distribution features (such as topography and soil moisture), while Transformer captures long-term time series dependencies through a self-attention mechanism, solving the gradient decay problem in long-range prediction of traditional LSTM / GRU. The physical equation constraints of WRF-Hydro can reduce the dependence of deep learning models on the amount of data, and still maintain high prediction stability in watersheds with scarce data.

[0193] 4. By splitting the dataset into multiple working nodes, local models can be trained in parallel using cluster computing resources, significantly shortening training time; through gradient encryption upload and global aggregation, collaborative model training is achieved without sharing the original data, making it suitable for cross-institutional collaboration scenarios; the parameter server allocates data subsets according to the computing capabilities of each node, avoiding single-node bottlenecks and improving the utilization rate of cluster resources.

[0194] 5. By integrating historical data from different watersheds, the runoff prediction model learns common patterns across watersheds, enhancing its ability to predict migration to previously unseen watersheds; unified preprocessing is performed to address the heterogeneity of data from different watersheds, reducing the impact of noise on the runoff prediction model.

[0195] 6. By coupling the physical mechanism of the WRF-Hydro hydrological model with the temporal modeling capability of Transformer, a runoff prediction model with deep spatiotemporal feature fusion was constructed, which significantly improved the prediction accuracy and cross-basin generalization capability of complex hydrological dynamics. By adopting a distributed training architecture combined with a gradient encryption aggregation mechanism, the training time was greatly shortened while ensuring the privacy and security of multi-source data. Furthermore, the deployment cost was reduced through model compression technology, achieving efficient and lightweight real-time prediction. This provides a highly reliable and low-latency end-to-end solution for scenarios such as water resource management and flood warning.

[0196] 7. WRF-Hydro, as a physical model, provides the first runoff prediction result based on hydrological mechanisms, ensuring that the prediction result conforms to physical laws; Transformer, as a data-driven model, captures complex nonlinear relationships through deep learning to generate the second runoff prediction result, correcting the local bias of the physical model; the collaboration of the two models not only retains the reliability of the physical model, but also utilizes the flexibility of the data-driven model to improve the robustness of the prediction.

[0197] 8. The loss function integrates the observation error (MSE(Yobs,Ypred)) and the WRF-Hydro prediction error (MSE(YWRF,Ypred)). By balancing the contributions of the physical model and the data-driven model through the weighting coefficients α and β, it avoids overfitting or underfitting caused by a single model dominating the model.

[0198] 9. Capture the temporal evolution of runoff (e.g., peak delay) through temporal attention heads; mine the dynamic correlation between meteorological factors (e.g., precipitation, temperature) and runoff through variable attention heads to achieve multivariate coupled analysis; extract local temporal patterns (e.g., short-term rainfall impulse response) through 1D temporal convolution; capture watershed spatial heterogeneity (e.g., the influence of terrain slope on runoff) through 2D spatial convolution, and design a hierarchical expression that takes into account both temporal and spatial characteristics; and expand the receptive field by using a three-dimensional dilated convolutional network and adjusting the porosity to efficiently capture the spatial constraints of large-scale terrain features (e.g., watershed elevation, river network) on runoff, avoiding the limitations of traditional 2D convolution for modeling three-dimensional terrain data (DEM).

[0199] 10. The gated cross-attention pyramid dynamically adjusts the fusion weights of runoff features and terrain features through gating units to suppress noise interference (such as outliers in terrain data); the pyramid structure enables multi-scale feature fusion (such as matching global terrain contours with local runoff features), enhancing the model's ability to model complex terrain-runoff relationships.

[0200] 11. Gradient parameters are encrypted using AES256+RC6 dual algorithms and subjected to character substitution (e.g. This prevents the leakage of intermediate parameters and meets the requirements of high-security scenarios.

[0201] 12. Differential privacy constraints are introduced during the training phase to prevent the model from overfitting sensitive data by adding noise and to enhance generalization ability; a dynamic expansion mechanism for the validation set (automatically expanding the training set when the prediction accuracy is insufficient) and a confidence threshold test (only passing if the confidence is greater than the threshold) ensure the reliability of the model.

[0202] 13. By coupling the WRF-Hydro hydrophysical model with the Transformer deep learning algorithm, we achieve synergistic optimization of physical laws and data-driven approaches. Combining a distributed federated learning architecture (parameter server-worker node cluster) and multi-level encryption mechanisms (AES256+RC6+character permutation), we ensure the privacy and security of multi-basin data while accurately capturing the complex correlation between meteorology, topography, and runoff using spatiotemporal multi-head attention, 3D terrain feature extraction, and gated cross-modal fusion techniques. Through dynamic loss weight adjustment, differential privacy constraints, and knowledge distillation compression, we significantly improve the model's robustness, anti-overfitting ability, and lightweight deployment efficiency. Furthermore, by leveraging sliding time window data segmentation, residual learning decoders, and standardized API interface design, we achieve high-precision long-term time-series prediction, cross-basin generalization capabilities, and seamless integration with business systems. This comprehensively solves the bottleneck problems of traditional methods in terms of accuracy, security, computational efficiency, and engineering implementation.

[0203] While specific embodiments of the present invention have been described above, those skilled in the art should understand that the specific embodiments described are merely illustrative and not intended to limit the scope of the present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. A runoff prediction method based on WRF-Hydro and Transformer coupling, characterized in that, The steps include the following: Step S1: The parameter server creates a runoff prediction model based on the sequentially connected WRF-Hydro and Transformer, sets the loss function of the runoff prediction model, and deploys the runoff prediction model to several working nodes in the same cluster as the parameter server as the local model of each working node. Step S2: Obtain a large amount of historical runoff monitoring data from different watersheds, and construct a dataset after preprocessing the historical runoff monitoring data. Step S3: Divide the dataset into several data subsets and send each data subset to a working node. Step S4: The working node divides the received data subset into a training set, a validation set, and a test set, and uses the training set, validation set, and test set to train, validate, and test the local model respectively. Step S5: The working node obtains the gradient parameters of the tested local model, encrypts the gradient parameters into first-level encrypted data using the AES256 algorithm, converts the first-level encrypted data into hexadecimal data, swaps the letter A and the number 3, and swaps the letter B and the number 8 in the hexadecimal data to obtain second-level encrypted data, encrypts the second-level encrypted data into encrypted parameters using the RC6 algorithm, and uploads the encrypted parameters to the parameter server in real time via the gRPC protocol. Step S6: The parameter server receives the encrypted parameters uploaded by each working node, decrypts the encrypted parameters into secondary encrypted data using the RC6 algorithm, swaps the letter A and the number 3 in the secondary encrypted data, swaps the letter B and the number 8 to obtain hexadecimal data, converts the hexadecimal data into primary encrypted data, and decrypts the primary encrypted data into gradient parameters using the AES256 algorithm. The parameter server performs a weighted average of the gradient parameters to aggregate them into a global gradient, and updates the parameters of the runoff prediction model using the global gradient to complete distributed training. Step S7: Using knowledge distillation technology, compress the Transformer in the runoff prediction model after parameter updates, then encapsulate and deploy the runoff prediction model, set up an API interface for accessing the deployed runoff prediction model, and call the deployed runoff prediction model through the API interface to perform runoff prediction.

2. The runoff prediction method based on WRF-Hydro and Transformer coupling as described in claim 1, characterized in that, In step S1, the WRF-Hydro is used to simulate the input runoff monitoring data to obtain a first runoff prediction result; the Transformer is used to infer the runoff monitoring data and the first runoff prediction result to obtain a second runoff prediction result. The Transformer is built based on an encoder and a decoder; The encoder is constructed based on a spatiotemporal multi-head self-attention layer, a spatiotemporal convolutional layer, a 3D terrain feature extraction layer, and a cross-modal feature fusion layer; The spatiotemporal multi-head self-attention layer is used to extract temporal dependency features and meteorological factor correlation features from the input runoff monitoring data through parallel deployment of temporal attention heads and variable attention heads, respectively; the spatiotemporal convolutional layer is used to extract the runoff feature matrix from the temporal dependency features and meteorological factor correlation features through cascaded 1D temporal convolution and 2D spatial convolution; the 3D terrain feature extraction layer is used to extract the terrain feature matrix from the input runoff monitoring data through a 3D dilated convolutional network; the cross-modal feature fusion layer is used to fuse the runoff feature matrix and the terrain feature matrix through a gated cross-attention pyramid to obtain fused features; The decoder is used to learn the fused features and the first runoff prediction result through a residual learning strategy, and output the second runoff prediction result. The formula for the loss function is: LOSS=ɑ*MSE(Y obs ,Y pred )+β*MSE(Y WRF ,Y pred ); Where LOSS represents the loss value of the loss function; Y obs Y represents the actual runoff value; pred Indicates the second runoff prediction result; Y WRF represents the first runoff prediction result; α and β both represent weighting coefficients; MSE() represents the mean square error function.

3. The runoff prediction method based on WRF-Hydro and Transformer coupling as described in claim 1, characterized in that, Step S2 specifically involves: Acquire a large amount of historical runoff monitoring data from different watersheds. The historical runoff monitoring data includes at least the watershed location, watershed name, geospatial data, meteorological data, monitoring time, WRF-Hydro initialization parameters, and actual runoff value. The geospatial data includes at least digital elevation models, land use types, soil types, slopes, river network structures, sub-basin divisions, vegetation cover, albedo, and LAI. The meteorological data includes at least precipitation, air temperature, wind speed, specific humidity, shortwave radiation, longwave radiation, and surface air pressure; The WRF-Hydro initialization parameters include at least the surface Manning coefficient, the channel Manning coefficient, soil hydraulic parameters, infiltration and runoff generation parameters, groundwater parameters, and the initial soil state. The historical runoff monitoring data shall be preprocessed in at least the following ways: data cleaning, format standardization, missing value filling, and time series alignment. The preprocessed historical runoff monitoring data are segmented based on a sliding time window. The historical runoff monitoring data of the first 72 hours are labeled as input data, and the historical runoff monitoring data of the last 24 hours are labeled as output data to construct a dataset. Step S3 specifically involves: The dataset is divided into several data subsets based on the number of worker nodes. Each data subset is encrypted using a homomorphic encryption algorithm and then sent to a worker node via the gRPC protocol.

4. The runoff prediction method based on WRF-Hydro and Transformer coupling as described in claim 1, characterized in that, Step S4 specifically involves: The worker node divides the received data subset into a training set, a validation set, and a test set in a ratio of 7:1.5:1.

5. The local model is trained using the training set, and differential privacy constraints are incorporated during the training process until the loss value of the loss function is less than a preset loss threshold. The trained local model is validated using the validation set to determine whether the prediction accuracy is greater than a preset accuracy threshold. If not, the validation fails, and the training set is expanded for continued training; if yes, the validation passes. The validated local model is tested using the test set to determine whether the confidence level is greater than a preset confidence threshold. If not, the test fails, and the training set is expanded to continue training; if yes, the test passes, and training ends.

5. A runoff prediction system based on WRF-Hydro and Transformer coupling, characterized in that, Includes the following modules: The runoff prediction model creation module is used by the parameter server to create a runoff prediction model based on the sequentially connected WRF-Hydro and Transformer, set the loss function of the runoff prediction model, and deploy the runoff prediction model to several working nodes in the same cluster as the parameter server as local models of each working node. The dataset construction module is used to acquire a large amount of historical runoff monitoring data from different watersheds, and to construct the dataset after preprocessing the historical runoff monitoring data. The dataset partitioning module is used to divide the dataset into several data subsets and send each data subset to a working node. The local model training module is used by the worker node to divide the received data subset into a training set, a validation set, and a test set, and to train, validate, and test the local model using the training set, validation set, and test set, respectively. The gradient parameter encryption upload module is used by the worker node to obtain the gradient parameters of the local model that has passed the test, encrypt the gradient parameters into first-level encrypted data using the AES256 algorithm, convert the first-level encrypted data into hexadecimal data, swap the letter A and the number 3, and swap the letter B and the number 8 in the hexadecimal data to obtain second-level encrypted data, encrypt the second-level encrypted data into encrypted parameters using the RC6 algorithm, and upload the encrypted parameters to the parameter server in real time via the gRPC protocol; The parameter update module is used to receive the encrypted parameters uploaded by each working node from the parameter server, decrypt the encrypted parameters into secondary encrypted data using the RC6 algorithm, swap the letter A and the number 3 in the secondary encrypted data, swap the letter B and the number 8 to obtain hexadecimal data, convert the hexadecimal data into primary encrypted data, and decrypt the primary encrypted data into gradient parameters using the AES256 algorithm. The parameter server performs a weighted average of the gradient parameters to aggregate them into a global gradient, and updates the parameters of the runoff prediction model using the global gradient to complete distributed training. The runoff prediction module is used to compress the Transformer in the runoff prediction model after parameter updates using knowledge distillation technology, then encapsulate and deploy the runoff prediction model, set up an API interface for accessing the deployed runoff prediction model, and call the deployed runoff prediction model to perform runoff prediction through the API interface.

6. A runoff prediction system based on WRF-Hydro and Transformer coupling as described in claim 5, characterized in that, In the runoff prediction model creation module, the WRF-Hydro is used to simulate the input runoff monitoring data to obtain a first runoff prediction result; the Transformer is used to infer the runoff monitoring data and the first runoff prediction result to obtain a second runoff prediction result. The Transformer is built based on an encoder and a decoder; The encoder is constructed based on a spatiotemporal multi-head self-attention layer, a spatiotemporal convolutional layer, a 3D terrain feature extraction layer, and a cross-modal feature fusion layer; The spatiotemporal multi-head self-attention layer is used to extract temporal dependency features and meteorological factor correlation features from the input runoff monitoring data through parallel deployment of temporal attention heads and variable attention heads, respectively; the spatiotemporal convolutional layer is used to extract the runoff feature matrix from the temporal dependency features and meteorological factor correlation features through cascaded 1D temporal convolution and 2D spatial convolution; the 3D terrain feature extraction layer is used to extract the terrain feature matrix from the input runoff monitoring data through a 3D dilated convolutional network; the cross-modal feature fusion layer is used to fuse the runoff feature matrix and the terrain feature matrix through a gated cross-attention pyramid to obtain fused features; The decoder is used to learn the fused features and the first runoff prediction result through a residual learning strategy, and output the second runoff prediction result. The formula for the loss function is: LOSS=ɑ*MSE(Y obs ,Y pred )+β*MSE(Y WRF ,Y pred ); Where LOSS represents the loss value of the loss function; Y obs Y represents the actual runoff value; pred Indicates the second runoff prediction result; Y WRF represents the first runoff prediction result; α and β both represent weighting coefficients; MSE() represents the mean square error function.

7. A runoff prediction system based on WRF-Hydro and Transformer coupling as described in claim 5, characterized in that, The dataset construction module is specifically used for: Acquire a large amount of historical runoff monitoring data from different watersheds. The historical runoff monitoring data includes at least the watershed location, watershed name, geospatial data, meteorological data, monitoring time, WRF-Hydro initialization parameters, and actual runoff value. The geospatial data includes at least digital elevation models, land use types, soil types, slopes, river network structures, sub-basin divisions, vegetation cover, albedo, and LAI. The meteorological data includes at least precipitation, air temperature, wind speed, specific humidity, shortwave radiation, longwave radiation, and surface air pressure; The WRF-Hydro initialization parameters include at least the surface Manning coefficient, the channel Manning coefficient, soil hydraulic parameters, infiltration and runoff generation parameters, groundwater parameters, and the initial soil state. The historical runoff monitoring data shall be preprocessed in at least the following ways: data cleaning, format standardization, missing value filling, and time series alignment. The preprocessed historical runoff monitoring data are segmented based on a sliding time window. The historical runoff monitoring data of the first 72 hours are labeled as input data, and the historical runoff monitoring data of the last 24 hours are labeled as output data to construct a dataset. The dataset partitioning module is specifically used for: The dataset is divided into several data subsets based on the number of worker nodes. Each data subset is encrypted using a homomorphic encryption algorithm and then sent to a worker node via the gRPC protocol.

8. A runoff prediction system based on WRF-Hydro and Transformer coupling as described in claim 5, characterized in that, The local model training module is specifically used for: The worker node divides the received data subset into a training set, a validation set, and a test set in a ratio of 7:1.5:1.

5. The local model is trained using the training set, and differential privacy constraints are incorporated during the training process until the loss value of the loss function is less than a preset loss threshold. The trained local model is validated using the validation set to determine whether the prediction accuracy is greater than a preset accuracy threshold. If not, the validation fails, and the training set is expanded for continued training; if yes, the validation passes. The validated local model is tested using the test set to determine whether the confidence level is greater than a preset confidence threshold. If not, the test fails, and the training set is expanded to continue training; if yes, the test passes, and training ends.

Citation Information

Patent Citations

  • Runoff prediction method based on Transform sequence-to-sequence model

    CN115146700A

  • Intelligent adaptive retrieval enhancement system and method and storage medium

    CN118210983A