Flood prediction correction method and system based on hydrological state perception residual learning

CN122736107APending Publication Date: 2026-09-11NANJING HYDRAULIC RES INST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611214236.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-11
Publication Date
2026-09-11

AI Technical Summary

Technical Problem

其中概念性水文模型基于水量平衡原理进行产汇流计算,但受限于模型结构概化、输入数据时空代表性不足等因素制约,在强降雨或流域前期干湿状态快速转换时,经常出现洪峰偏低,或过程线平滑等系统性偏差

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122736107A_ABST
    Figure CN122736107A_ABST
Patent Text Reader

Abstract

This invention discloses a flood forecast correction method and system based on hydrological state-aware residual learning, relating to the field of intelligent hydrological forecasting. The method acquires hydrological and meteorological data and historical measured flow rates; it uses a physical hydrological model to simulate baseline forecast flow rates and hydrological state variables; based on the above data, it constructs the current hydrological state and inputs it into a residual learning model to obtain a target residual prediction value; it calculates the distance metric between the current hydrological state and the state distribution in the pre-stored training domain as the state deviation, and maps this state deviation to a gating coefficient; it uses the gating coefficient to weight the target residual prediction value and fuses it with the baseline forecast flow rate to obtain the corrected forecast result. This invention can reduce the risk of extrapolation collapse of purely data-driven models under extreme conditions while retaining the constraints of the physical model, thereby improving the accuracy and stability of flood forecasting.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of flood forecasting and hydrological intelligent algorithm technology, and in particular to a flood forecasting correction method and system based on hydrological state perception residual learning. Background Technology

[0002] Flood events typically exhibit characteristics of suddenness, non-stationarity, and phased changes. Accurately forecasting peak flow, peak occurrence time, and flood hydrographs is crucial for basin-wide flood control scheduling, reservoir flood prevention decisions, and the safe operation of water conservancy projects.

[0003] Current flood forecasting primarily employs conceptual hydrological models, data-driven deep learning models, and hybrid correction paradigms of both. Conceptual hydrological models calculate runoff based on the principle of water balance, but are limited by factors such as generalized model structure and insufficient spatiotemporal representativeness of input data. During periods of heavy rainfall or rapid transitions between wet and dry conditions in the basin, they often exhibit systematic biases such as underestimating flood peaks or smoothing of process curves. Similarly, data-driven deep learning models can fit complex nonlinear errors, but they are highly dependent on the distribution characteristics of the training samples. When encountering extreme flood events outside the coverage of the training set, they are prone to numerical divergence or extrapolation distortions that violate physical conservation laws.

[0004] Under complex operating conditions, existing flood forecasting methods have insufficient ability to fit nonlinear errors. Summary of the Invention

[0005] Purpose of the invention: In order to solve the technical problems existing in the prior art, the present invention proposes a flood forecast correction method and system based on hydrological state perception residual learning.

[0006] Technical solution: Firstly, a flood forecast correction method based on hydrological state perception residual learning, comprising:

[0007] Obtain hourly hydrological and meteorological data and historical measured flow rates for the study watershed;

[0008] By using a physical hydrological model to simulate hourly hydrological and meteorological data, baseline forecast flow and hydrological state variables are obtained.

[0009] The current hydrological status is constructed based on hourly hydro-meteorological data, historical measured flow, baseline forecast flow, and hydrological state variables.

[0010] Input the current hydrological status into the residual learning model to obtain the target residual prediction value;

[0011] The distance metric between the current hydrological state and the pre-stored training domain state distribution is calculated as the state deviation, and the state deviation is mapped to a gating coefficient.

[0012] The target residual prediction value is weighted using a gating coefficient and then fused with the baseline forecast flow to obtain the corrected forecast result.

[0013] According to one aspect of this application, the hydrological state variables include the moisture content of three soil layers;

[0014] The current hydrological state is constructed based on hourly hydrological and meteorological data, historical measured flow, baseline forecast flow, and hydrological state variables, including:

[0015] The comprehensive water storage deficit ratio and the rate of change of soil moisture content in the three soil layers were calculated based on the moisture content of the three soil layers.

[0016] The current hydrological status is obtained by combining hourly hydrological and meteorological data, historical measured flow, baseline forecast flow, soil moisture content in the three layers, comprehensive water storage deficit ratio, and the rate of change of soil moisture content in the three layers.

[0017] According to one aspect of this application, the residual learning model includes a temporal location encoding layer, a hydrological state embedding layer, a sequence encoder layer, and a state attention convergence layer;

[0018] The current hydrological state is input into the residual learning model to obtain the target residual prediction value, including:

[0019] By using a time-location coding layer to add time sequence information to the historical sequence in the current hydrological state, an input representation is obtained;

[0020] A state embedding vector is extracted based on the current hydrological state using a hydrological state embedding layer, and then fused with the input representation to obtain the fused input representation.

[0021] The sequence encoder layer is used to extract the dependencies between different time steps of the fused input representation and output the hidden state at each time step.

[0022] The hidden states at each time step are weighted and aggregated using a state attention convergence layer to output the target residual prediction value.

[0023] According to one aspect of this application, calculating a distance metric between the current hydrological state and the pre-stored training domain state distribution as a state deviation includes:

[0024] Obtain the stable inverse matrix of the mean vector and covariance matrix corresponding to the pre-stored training domain state distribution;

[0025] The Mahalanobis distance is calculated based on the current hydrological state, mean vector, and stable inverse matrix of covariance matrix.

[0026] The Mahalanobis distance is used as the state deviation.

[0027] According to one aspect of this application, mapping state deviation to gating coefficients includes:

[0028] Using a pre-configured critical deviation threshold and gating sensitivity parameters, the state deviation is mapped to a gating coefficient through a sigmoid activation function, so that the gating coefficient decays when the state deviation is greater than the critical deviation threshold.

[0029] The target residual prediction value is weighted using a gating coefficient and then fused with the baseline forecast flow to obtain the revised forecast result, including:

[0030] Calculate the product of the gating coefficient and the predicted value of the target residual as the adaptive correction amount;

[0031] The baseline forecast flow is added to the adaptive correction, and a non-negativity constraint is applied to the addition result to obtain the corrected forecast result.

[0032] According to one aspect of this application, the pre-configured critical deviation threshold is a preset high percentile of the distance distribution of pre-stored training set samples;

[0033] The distance values ​​of the pre-stored training set samples are at least the 90th percentile in the distance distribution.

[0034] According to one aspect of this application, the residual learning model is pre-trained in the following manner:

[0035] Obtain a historical training sample set, which includes historical hydrological state features and corresponding real flow residuals;

[0036] Historical hydrological features are input into the initial residual learning model to obtain the training residual prediction values;

[0037] The loss function is calculated based on the actual flow residual and the predicted value of the training residual. The loss function is configured with sample weights to give higher optimization weights to high flow samples and samples underestimated by the physical hydrological model.

[0038] The network parameters of the initial residual learning model are updated based on the loss function to obtain the residual learning model.

[0039] According to one aspect of this application, hourly hydrometeorological data includes hourly average rainfall;

[0040] The current hydrological state is constructed based on hourly hydrological and meteorological data, historical measured flow, baseline forecast flow, and hydrological state variables, and also includes:

[0041] Calculate the cumulative rainfall in previous periods within multiple preset historical time windows based on hourly average rainfall;

[0042] The cumulative rainfall from the previous period is added as an additional feature to the current hydrological status to characterize the cumulative effect of previous rainfall in the basin.

[0043] According to one aspect of this application, the method is applied to a multi-step rolling flood forecasting scenario and includes:

[0044] When forecasting floods at the next time step of the target time, if the historical measured flow rate corresponding to the next time step cannot be obtained, the revised forecast result is used as a substitute measured flow rate to construct the current hydrological state at the next time step. The current hydrological state at the next time step is then input into the residual learning model for recursive forecasting.

[0045] The second aspect is a flood forecast correction system based on hydrological state-aware residual learning. The system includes a processor coupled to a memory. The memory stores instructions, and when the instructions are executed by the processor, they implement the method described in any one of the first aspects.

[0046] Beneficial effects: While preserving the constraints of the physical model, it can reduce the risk of extrapolation failure of the pure data-driven model under more extreme conditions, and improve the accuracy and stability of flood process forecasting. Attached Figure Description

[0047] Figure 1 This is a flowchart of the flood forecast correction method based on hydrological state perception residual learning of the present invention.

[0048] Figure 2 This is a flowchart of the present invention for obtaining the target residual prediction value.

[0049] Figure 3 This is a flowchart of the present invention for obtaining the state deviation.

[0050] Figure 4 This is a flowchart of the present invention that maps state deviation to gating coefficients.

[0051] Figure 5 This is a flowchart of the pre-trained residual learning model of the present invention. Detailed Implementation

[0052] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0053] It should be noted that the terms "first," "second," etc., in the specification and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein are implemented in a sequence other than those illustrated or described herein. Furthermore, the terms "including" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those explicitly listed, but may include other steps or units not explicitly listed or inherent to the process, method, product, or apparatus.

[0054] The phenomenon mentioned in the background technology, after the applicant's search, revealed that existing flood forecasting methods have insufficient nonlinear error fitting ability under complex working conditions, and their extrapolation stability and physical rationality are poor under more extreme conditions.

[0055] To solve these problems, combined with Figures 1 to 5 The present invention will be specifically described through the following embodiments.

[0056] Example 1

[0057] According to one aspect of this application, this embodiment provides a flood forecast correction method based on hydrological state-aware residual learning, the method comprising the following steps:

[0058] Step 101: Obtain hourly hydrological and meteorological data and historical measured flow rates for the study watershed.

[0059] In this embodiment, hourly hydrological and meteorological data are collected in real time through automatic rain gauges and evaporation observation stations in the watershed hydrological telemetry system, and historical measured flow rates are obtained through automatic water level and flow monitoring equipment at the watershed outlet section.

[0060] Specifically, rainfall and evaporation data within the basin are acquired and processed using conventional methods such as consistency checks, missing data completion, outlier removal, and areal average rainfall calculation to form hourly hydrological and meteorological data sequences. Historical measured flow sequences at the basin outlet section are also acquired simultaneously.

[0061] Step 102: Use a physical hydrological model to simulate hourly hydrological and meteorological data to obtain the baseline forecast flow and hydrological state variables.

[0062] In this embodiment, the physical hydrological model adopts the Xin'anjiang Three-Source Model based on the Nash efficiency coefficient calibration parameters. By performing full-storage runoff and confluence calculations, the baseline forecast flow rate at each time point is output, and the water content of the upper, middle and deep soil layers, which reflect the water storage mechanism within the watershed, is extracted simultaneously as hydrological state variables.

[0063] Step 103: Construct the current hydrological status based on hourly hydrological and meteorological data, historical measured flow, baseline forecast flow, and hydrological state variables.

[0064] Specifically, the physical derivative features in the hydrological state variables are extracted, and then combined with hourly hydrological and meteorological data, historical measured flow and baseline forecast flow through time-series sliding window splicing and normalization to form the current hydrological state feature vector for input into the deep learning network.

[0065] Step 104: Input the current hydrological status into the residual learning model to obtain the target residual prediction value.

[0066] The target residual prediction value refers to the flow prediction output by the model to compensate for the baseline bias of the physical hydrological model under the current runoff generation and confluence conditions. The current hydrological state is input into a pre-trained residual learning model. Through the model's internal self-attention mechanism, the nonlinear dependencies between hydrological features at different time steps are extracted, and the residual prediction result for the target time is output.

[0067] Step 105: Calculate the distance metric between the current hydrological state and the pre-stored training domain state distribution as the state deviation, and map the state deviation to the gating coefficient.

[0068] In this embodiment, the state deviation is used to characterize the relative distance between the current hydrological state vector and the overall distribution characteristics of the historical training data; the gating coefficient refers to the dimensionless control factor generated based on this deviation degree for dynamically adjusting the residual correction amplitude. To achieve adaptive control, this embodiment calculates the Mahalanobis distance, an equidistance metric, between the current hydrological state and the pre-stored training domain state distribution statistics to determine the state deviation.

[0069] Next, the state deviation is nonlinearly mapped to a gate coefficient with restricted values ​​using an activation function, thereby describing the prediction confidence of the data-driven model under the current input conditions.

[0070] Step 106: Weight the target residual prediction value using the gating coefficient and fuse it with the baseline forecast flow to obtain the corrected forecast result.

[0071] In this embodiment, the corrected forecast result refers to the final flood discharge forecast value after error compensation. Specifically, the gate coefficient is multiplied by the target residual prediction value to dynamically scale the residual correction magnitude, and the scaled residual value is superimposed on the baseline forecast discharge. Correspondingly, when the flood state to be forecast deviates from the training domain, the residual superposition intensity is automatically reduced, so that the forecast result smoothly reverts to the physically constrained baseline forecast discharge, reducing the risk of extrapolation distortion of the pure data-driven model under extreme conditions. After the corrected forecast result is output, it can be used in the flood control scheduling decision support system for flood warning, reservoir scheduling scheme generation, and flood control consultation information display.

[0072] Example 2

[0073] Based on Embodiment 1 above, this embodiment further describes the process of constructing the current hydrological state. In one possible implementation, the current hydrological state is constructed based on hourly hydro-meteorological data, historical measured flow, baseline forecast flow, and hydrological state variables, specifically including:

[0074] Step 201: Hydrological state variables include the moisture content of the three soil layers; calculate the comprehensive water storage deficit ratio and the rate of change of the moisture content of the three soil layers based on the moisture content of the three soil layers.

[0075] Specifically, the internal state variables output by the physical hydrological model are processed a second time to obtain the comprehensive water storage deficit ratio and the rate of change of soil moisture content in the three layers. The comprehensive water storage deficit ratio is used to characterize the dimensionless index of the relative distance of the current watershed from the full water storage state; the rate of change of soil moisture content in the three layers is used to characterize the difference in the dynamic filling and releasing process of soil moisture in different layers. To enhance the deep learning network's perception of soil moisture change trends, the soil moisture content in the three layers at the current time and the previous time are extracted and differentially calculated.

[0076] Accordingly, the formula for calculating the rate of change of water content in the upper soil layer is:

[0077] Δ _WU (t)=WU(t)-WU(t-1);

[0078] Where, Δ _WU WU(t) represents the rate of change of soil moisture content in the upper layer at time t; WU(t) represents the soil moisture content in the upper layer; WU(t-1) represents the soil moisture content in the upper layer at time t-1.

[0079] Based on this, the rate of change of soil moisture content in the middle layer and the rate of change of soil moisture content in the deep layer are calculated, so that the model can identify whether the soil moisture is in a stage of increasing replenishment or decreasing consumption.

[0080] Furthermore, the comprehensive water storage deficit ratio is calculated based on the moisture content of the three soil layers, specifically including:

[0081] Step 2011: Calculate the difference between the pre-configured upper layer water storage capacity, middle layer water storage capacity and deep layer water storage capacity and the corresponding soil moisture content of the three layers, and obtain the water shortage of the three layers of soil.

[0082] The three-layer soil water deficit refers to the physical space that each soil layer can continue to hold water before reaching saturation and runoff production. Specifically, it involves obtaining the pre-calibrated water storage capacity parameters of each layer in a physical hydrological model and subtracting the actual water content at the current moment. For example, the water deficit of the upper soil layer is obtained by subtracting the water content of the upper soil layer from its water storage capacity, and the water deficits of the middle and deep soil layers are calculated in the same way.

[0083] Step 2012: Calculate the ratio of the sum of the water deficit of the three soil layers to the total water storage capacity as the comprehensive water deficit ratio, where the total water storage capacity is the sum of the water storage capacity of the upper layer, the water storage capacity of the middle layer, and the water storage capacity of the deep layer.

[0084] In this embodiment, the sum of the water deficits of the three soil layers is divided by the total water storage capacity of the watershed to calculate the comprehensive water deficit ratio. The corresponding calculation formula is:

[0085] D _s (t)=([WU _M -WU(t)]+[WL _M -WL(t)]+[WD _M -WD(t)]) / (WU _M +WL _M +WD _M );

[0086] Among them, D _s (t) represents the comprehensive water deficit ratio at time t, with a value ranging from 0 to 1; WU(t), WL(t), and WD(t) are the water contents of the upper, middle, and deep soil layers at time t, respectively; WU _M WL _M WD _M These represent the pre-configured water storage capacities for the upper, middle, and deep layers. This indicator reflects the critical state of the watershed transitioning from drought and water scarcity to full storage and runoff generation.

[0087] Furthermore, the hourly hydro-meteorological data includes hourly average rainfall. In one possible implementation, constructing the current hydrological state also includes:

[0088] Step 202: Calculate the cumulative rainfall in the previous period within multiple preset historical time windows based on the hourly average rainfall.

[0089] Based on the set time window length, the hourly average rainfall over the current moment and previous moments is summed. The corresponding calculation formula is as follows:

[0090] P _mh(t)=∑ j=0 m-1 P(tj);

[0091] Among them, P _mh (t) represents the cumulative rainfall in the first m hours before time t; P(tj) represents the hourly average rainfall at time tj; m is the length of the time window; and ∑ is the summation operation.

[0092] Step 203: Add the previous cumulative rainfall as an additional feature to the current hydrological status to characterize the cumulative effect of previous rainfall in the watershed.

[0093] Specifically, the cumulative rainfall values ​​from different window lengths are concatenated into vectors to make them one of the feature dimensions of the subsequent network input.

[0094] Step 204: Combine hourly hydrological and meteorological data, historical measured flow, baseline forecast flow, three-layer soil moisture content, comprehensive water storage deficit ratio, and three-layer soil moisture content change rate to obtain the current hydrological status.

[0095] In this embodiment, the current hydrological state refers to a comprehensive feature vector that includes meteorological drivers, physical baselines, and derived states. Specifically, the features are aligned by time steps and concatenated into a feature vector. A minimum-maximum normalization method is used to map the data of each dimension to a unified latent space. The corresponding calculation formula is as follows:

[0096] x _norm =(xx _min ) / (x _max -x _min );

[0097] Where x is any original feature input value; x _min With x _max These are the minimum and maximum values ​​of the feature in the training set, respectively; x _norm These are the normalized feature values. The features of each dimension are normalized sequentially and then combined to obtain a single-time-step hydrological state vector. This vector contains multiple features and can be used as the state-aware input for the deep learning model at the current moment.

[0098] Example 3

[0099] Based on Example 1, this example further explains the process of inputting the current hydrological state into the residual learning model to obtain the target residual prediction value.

[0100] In one possible implementation, the residual learning model includes a temporal location encoding layer, a hydrological state embedding layer, a sequence encoder layer, and a state attention convergence layer. The method includes the following steps:

[0101] Step 301: Use the time location coding layer to add time sequence information to the historical sequence in the current hydrological state to obtain the input representation.

[0102] Specifically, the historical time series in the current hydrological state is obtained, and it is processed using a conventional sine-cosine position coding method. Relative position information is injected into each time step, and the input representation with time sequence characteristics is output.

[0103] Step 302: Extract state embedding vectors based on the current hydrological state using the hydrological state embedding layer, and fuse the state embedding vectors with the input representation to obtain the fused input representation.

[0104] Furthermore, the input representation is augmented with physical state features, specifically including:

[0105] Step 3021: Use a mapping function to map the water storage deficit characteristics and water content change characteristics in the current hydrological state into a state embedding vector.

[0106] In this embodiment, the state embedding vector is used to represent the latent space features of the watershed's aridity / wetness and water storage dynamics. Specifically, a mapping function is constructed using a fully connected network, and the water storage deficit features and water content change features in the current hydrological state are input into this mapping function. The corresponding calculation formula is as follows:

[0107] E _s =f _s (D _s (t),WU(t),WL(t),WD(t),Δ _WU (t),Δ _WL (t),Δ _WD (t));

[0108] Among them, E _s f is the state embedding vector; _s D is a mapping function; _s (t) represents the comprehensive water storage deficit ratio; Δ _WU (t), Δ _WL (t), Δ _WD (t) represent the rate of change of soil moisture content in the three soil layers, respectively. Mapping function f _s Multidimensional hydrological state features can be mapped to vectors with the same dimensions as the latent space, and this state embedding vector can be broadcast to each time step within the sliding time window, and added element by element to the input representation of the corresponding time step.

[0109] Step 3022: Add or concatenate the state embedding vector with the input representation to obtain the fused input representation, so as to introduce watershed dry and wet state information into the sequence encoder layer.

[0110] Specifically, on the same latent space dimension, the state embedding vector is added or concatenated with the input representation to generate a fused input representation, which introduces watershed dry and wet state information into the sequence encoder layer, so that the model can perceive the degree of water storage deficit when calculating time-series dependencies in subsequent calculations.

[0111] Step 303: Use the sequence encoder layer to extract the dependencies between different time steps of the fused input representation and output the hidden state of each time step.

[0112] In this embodiment, the sequence encoder layer is implemented using a Transformer encoder structure, including a multi-head self-attention sub-layer, a feedforward neural network sub-layer, residual connections, and a layer normalization structure. The latent space dimension, number of attention heads, number of encoder layers, and hidden dimension of the feedforward network of the Transformer encoder layer are preset.

[0113] An input mapping layer is employed to map the multidimensional features of the current hydrological state to a preset latent space dimension, resulting in a hidden feature matrix. The hyperparameters of this model architecture can be determined by those skilled in the art using conventional hyperparameter tuning methods based on the scale of the watershed data and computational resource conditions.

[0114] Furthermore, the process of outputting the hidden state at each time step specifically includes:

[0115] Step 3031: Extract the fused input representation according to the preset sliding time window length to obtain the sliding time window input sequence.

[0116] Specifically, according to the preset sliding time window length, the fused input representation is truncated to construct a feature matrix for the input attention mechanism.

[0117] For example, the sliding time window length is 12 time periods, that is, the features of the current time and the previous 11 historical time periods are extracted to form the input matrix.

[0118] Step 3032: Input the sequence within the sliding time window, calculate the dependency between the known historical time step and the current time step through a one-way self-attention mechanism, and mask the information of future time steps after the target prediction time, and output the hidden state of each time step.

[0119] In this embodiment, the hidden state at each time step is a high-dimensional feature vector containing context dependencies. Accordingly, within the sliding time window, a multi-head unidirectional self-attention mechanism is used to calculate the dependencies between known historical time steps and the current time step, masking future time step information after the target prediction time. This reduces the leakage of future observation data and outputs the hidden state at each time step that conforms to the physical constraints of real-time prediction.

[0120] Step 304: Use the state attention convergence layer to perform weighted convergence of the hidden states at each time step and output the target residual prediction value.

[0121] Step 3041: Calculate the correlation score between the hidden state at each time step and the current hydrological state.

[0122] In this embodiment, the correlation score refers to a numerical indicator that measures the matching degree and importance between the hidden state at each historical time step and the current hydrological state. Specifically, the correlation score between the hidden state at each time step and the current hydrological state is calculated using the following formula:

[0123] g(h _k ,S _t )=v T ×tanh(W _h ×h _k +W _s ×S _t +b _s );

[0124] Among them, g(h _k ,S _t ) represents the relevance score at the k-th time step; h _k The hidden state at the k-th time step; S _t This represents the current hydrological state vector; v, W _h W _s b _s All of these are trainable network parameters; T represents vector transpose.

[0125] Step 3042: Convert the relevance score into state attention weights.

[0126] In this embodiment, the state attention weight refers to a dimensionless coefficient used to control the information aggregation ratio at different time steps. Specifically, an exponential normalization function is used to convert the relevance score into the state attention weight, and the corresponding calculation formula is as follows:

[0127] a _k =exp(g(h _k ,S _t )) / ∑ _(j=t-11) t exp(g(h _j ,S _t ));

[0128] Among them, a _k Let be the state attention weight at the k-th time step; the summation interval is from time t-11 to time t covered by the sliding time window.

[0129] Step 3043: Use state attention weights to perform a weighted summation of the hidden states at each time step to obtain the context vector.

[0130] The context vector is a comprehensive representation that integrates features from key historical nodes. Specifically, it is obtained by weighting and summing the hidden states at each time step using state attention weights. The corresponding calculation relationship is as follows:

[0131] c _t =∑ _(k=t-11) t a _k ×h _k ;

[0132] Among them, c _t This is the context vector after state attention convergence. Based on this model, key historical time steps such as periods of heavy rainfall or periods when soil moisture content is close to full can be identified and given high weights.

[0133] Step 3044: Output the target residual prediction value based on the context vector.

[0134] The final prediction result is output based on the aggregated features, yielding the target residual prediction value. Specifically, the context vector is input into the residual output layer composed of fully connected layers, and the target residual prediction value is output based on the context vector. The corresponding calculation relationship is as follows:

[0135] e _hat (t+1)=W _o ×c _t +b _o ;

[0136] Among them, e _hat (t+1) represents the residual prediction value at the target forecast time; W _o b is the residual output layer weight matrix; _o This is the offset term for the residual output layer.

[0137] To address the issue of the sluggish perception of the early-stage wet and dry conditions of a watershed by purely data-driven models, this embodiment extracts physical derivative features such as the comprehensive water storage deficit ratio and adds state embedding and weighted convergence mechanisms to the self-attention architecture. This enables the model to have physical interpretability, locate key error-inducing nodes such as critical transitions in runoff generation, and enhance the ability to characterize nonlinear errors under complex rainfall-runoff conditions.

[0138] Example 4

[0139] Based on Embodiment 1 above, this embodiment further describes the process of calculating the state deviation, mapping gating coefficient, and fusing to obtain the corrected forecast result. In one possible implementation, the distance metric between the current hydrological state and the pre-stored training domain state distribution is calculated as the state deviation, including the following steps:

[0140] Step 401: Obtain the mean vector and stable inverse matrix of the covariance matrix corresponding to the pre-stored training domain state distribution. The stable inverse matrix of the covariance matrix can be the inverse matrix of the regularized covariance matrix or the generalized inverse matrix.

[0141] In this embodiment, the mean vector is used to characterize the overall data center of the historical training sample set. When calculating the Mahalanobis distance, the current state is centered by subtracting the mean vector. The stable inverse of the covariance matrix is ​​used to eliminate the correlation between various hydrological features and to unify the contribution scale of different features to the distance metric. Based on the pre-stored training domain state distribution, conventional matrix operations are used to extract and save this statistic, which is then used as a benchmark parameter for online real-time evaluation of state deviation.

[0142] As an optional implementation, a gated state vector is constructed from the current time-instance features of the hydrological state, and the mean vector corresponding to the gated state distribution in the training domain, as well as the inverse matrix of the regularized covariance matrix or the generalized inverse matrix of the covariance matrix, are obtained.

[0143] The gated state vector represents the degree to which the current state covers the historical training domain. For example, the gated state vector Z... _t It consists of the normalized comprehensive water storage deficit ratio, the change in three-layer tension water storage or soil moisture content, the cumulative rainfall in the previous 12 hours, historical measured flow, and baseline forecast flow. Let the mean vector of the gating state distribution in the training domain be μ. _z The covariance matrix is ​​Σ _z The corresponding regularized covariance matrix expression is:

[0144] Σ _z * =Σ _z +εI;

[0145] Where ε is a regularization parameter greater than 0, I is the identity matrix, and when Σ _z * If a stable inverse cannot be found, the Moore-Penrose generalized inverse of the covariance matrix is ​​used.

[0146] Step 402: Calculate the Mahalanobis distance based on the current hydrological state, mean vector, and stable inverse matrix of covariance matrix.

[0147] Step 403: Use the Mahalanobis distance as the state deviation.

[0148] In this embodiment, the state deviation is a relative distance index measured by Mahalanobis distance. Specifically, the difference between the current hydrological state vector and the mean vector is calculated. Using the stable inverse of the covariance matrix, a weighted quadratic form is applied to this difference, and the square root is obtained to obtain the Mahalanobis distance. This Mahalanobis distance is used as the state deviation. The corresponding calculation formula is:

[0149] d _t =sqrt((S _t sub -μ) T ×σ -1 ×(S _t sub -μ));

[0150] Where, d _t S represents the state deviation at time t; _t sub Let μ be the current hydrological state vector at time t; μ be the mean vector; σ be the mean vector. -1 is the stable inverse matrix of the covariance matrix; T denotes the vector transpose, and sqrt is the square root operation. This distance measures the true multidimensional distance between the current hydrological state and the historical empirical distribution, reducing the sensitivity of simple Euclidean distance to feature dimensions.

[0151] In this embodiment, the hydrological state vector used to calculate the state deviation is a subset of states directly related to the watershed's water storage and runoff generation mechanism in the current hydrological state. Specifically, it selects multi-dimensional features such as the comprehensive water storage deficit ratio, the moisture content of the three soil layers, and the rate of change of the moisture content of the three soil layers to form the hydrological state vector required for the state deviation calculation. This selection method ensures that the distance metric reflects the degree of deviation of the watershed's physical runoff generation state, rather than changes in meteorological driving forces or flow response signals.

[0152] In one possible implementation, mapping the state deviation to a gating coefficient specifically includes:

[0153] Step 404: Using the pre-configured critical deviation threshold and gating sensitivity parameters, the state deviation is mapped to the gating coefficient through the S-shaped activation function, so that the gating coefficient decays when the state deviation is greater than the critical deviation threshold.

[0154] In this embodiment, dimensionless weights with gating coefficients ranging from 0 to 1 are used to control the degree of credible adoption of the residual prediction values. Specifically, using a pre-configured critical deviation threshold and gating sensitivity parameters, a nonlinear mapping of the state deviation is performed through a sigmoid activation function. The corresponding calculation formula is as follows:

[0155] λ _t=1,d _t ≤τ;

[0156] λ _t =exp(-α(dt-τ)), dt>τ;

[0157] Where, λ _t d is the gating coefficient at time t; α is the gating sensitivity parameter; d _t τ is the state deviation; τ is the critical deviation threshold; and exp(•) is the natural exponential function.

[0158] In another possible implementation, the threshold τ is determined based on the Mahalanobis distance distribution of the training set samples. This causes the gating coefficients to decay rapidly when the state deviation exceeds a critical deviation threshold, suppressing unreliable extrapolation predictions.

[0159] In one feasible implementation, the pre-configured critical deviation threshold is a preset high percentile of the pre-stored training set sample distance distribution. The pre-stored training set sample distance distribution contains a percentile value not lower than the 90th percentile. For example, the critical deviation threshold is any high percentile from the 90th to the 99th percentile of the pre-stored training set sample Mahalanobis distance distribution, such as the 95th percentile.

[0160] Furthermore, the target residual prediction value is weighted using a gating coefficient and fused with the baseline forecast flow to obtain the revised forecast result, specifically including:

[0161] Step 405: Calculate the product of the gating coefficient and the predicted target residual value as the adaptive correction amount.

[0162] Step 406: Add the baseline forecast flow to the adaptive correction, and apply a non-negative constraint to the addition result to obtain the corrected forecast result.

[0163] In this embodiment, the adaptive correction is the actual effective residual after confidence level discounting; the corrected forecast result is the final forecast flow after superimposing the residuals and filtering out unreasonable negative values. Specifically, the product of the gating coefficient and the target residual prediction value is calculated and used as the adaptive correction. The baseline forecast flow is added to the adaptive correction, and a non-negativity constraint is applied to the addition result. The corresponding calculation formula is:

[0164] Q _cor (t+1)=max(Q _xaj (t+1)+λ _t ×e _hat (t+1),0);

[0165] Among them, Q _cor (t+1) represents the corrected forecast result at the target time; Q_xaj (t+1) represents the baseline forecast flow at the target time; λ _t e is the gating factor; _hat (t+1) represents the target residual prediction value; max(...,0) represents the non-negativity constraint operation. When the flood state to be predicted deviates from the training domain, the forecast results are smoothly backed up to the physical baseline, ensuring that the final flow does not exhibit negative values ​​that violate physical laws. This is used to address the problem of extrapolation collapse in purely data-driven models.

[0166] When deep learning models encounter unknown extreme floods, they are prone to extrapolation collapse. This embodiment introduces a state confidence gating mechanism based on Mahalanobis distance. When the input deviates abnormally from the historical training distribution, the residual correction magnitude is automatically decayed, allowing the forecast to smoothly revert to a physical benchmark with a water balance baseline. This reduces the risk of numerical distortion caused by unbounded extrapolation and maintains the forecast robustness under extreme conditions.

[0167] Example 5

[0168] Based on Embodiment 1 above, this embodiment further describes the training process of the residual learning model. In one possible implementation, the residual learning model is pre-trained in the following manner, which includes the following steps:

[0169] Step 501: Obtain the historical training sample set, which includes historical hydrological state features and corresponding real flow residuals.

[0170] Specifically, the time-series feature matrix corresponding to historical flood events is obtained and used as historical hydrological state features. The difference between the measured flow and the baseline forecast flow is calculated and used as the real flow residual. Based on this, a historical training sample set is constructed.

[0171] Step 502: Input the historical hydrological state features into the initial residual learning model to obtain the training residual prediction values.

[0172] Specifically, historical hydrological state features are input into the initial residual learning model to be optimized. After feature mapping and self-attention calculation within the network, the predicted training residual values ​​at the corresponding time are output.

[0173] Step 503: Calculate the loss function based on the actual flow residual and the predicted training residual. The loss function is configured with sample weights to give higher optimization weights to high flow samples and samples underestimated by the physical hydrological model.

[0174] The sample weights are penalty coefficients that are differentiated for different flow ranges and residual physical directions.

[0175] Step 5031: For each sample in the historical training sample set, calculate the flow rate weight factor and the residual direction weight factor respectively.

[0176] Specifically, a decoupling analysis is performed on the error characteristics of each sample to obtain the flow rate weighting factor and the residual direction weighting factor. This can be divided into the following processes:

[0177] Step a: Calculate the flow magnitude weighting factor based on the relative proportion of the historical measured flow corresponding to the sample that exceeds the pre-calculated average measured flow, so that the flow magnitude weighting factor is positively amplified as the relative proportion increases.

[0178] In this embodiment, the flow rate weighting factor is a dimensionless adjustment parameter that dynamically scales with the measured flow rate. To avoid the drawback of conventional mean square error being easily dominated by a large number of low-to-medium water samples, the flow rate weighting factor is calculated based on the relative proportion of the historical measured flow rate corresponding to the sample exceeding the pre-calculated average measured flow rate. The corresponding calculation formula is as follows:

[0179] w _Q,i =1+β×max(0,(Q _obs,i -Q _bar_obs ) / Q _bar_obs );

[0180] Among them, w _Q,i Q is the flow rate weighting factor for the i-th sample; _obs,i Q represents the historical measured flow rate at the time corresponding to the i-th sample; _bar_obs The training set contains the pre-calculated mean measured flow rate; β is a magnitude-sensitive coefficient used to control the amplification of weights for high-water samples, which can be determined by grid search on the validation set using the relative error of the flood peak as an indicator; max(0,...) is used to ensure that the weights of samples below the mean are based on a value of 1. This weighting method allows the model to be tilted towards the flood peak range during training.

[0181] Step b: Determine whether the predicted values ​​of the actual traffic residual and the training residual meet the preset undercorrection condition. The undercorrection condition is that the actual traffic residual is greater than zero and the predicted value of the training residual is less than the actual traffic residual.

[0182] The undercorrection condition is a logical criterion used to characterize the existence of a systematically low flood peak in the physical hydrological model, which the current network has failed to effectively compensate for. Specifically, the sign and magnitude relationship between the actual flow residual and the predicted value of the training residual are extracted to determine whether the actual flow residual is greater than zero and the predicted value of the training residual is less than the actual flow residual simultaneously. The overcorrection condition is that the predicted value of the training residual is greater than the sum of the actual flow residual and the preset allowable deviation.

[0183] Step c: When the undercorrection condition is met, the preset penalty coefficient is used as the residual direction weighting factor; in other cases, the residual direction weighting factor is set to a constant.

[0184] The residual directional weighting factor is used to amplify the preset directional error gradient. Specifically, when the undercorrection condition is met, it indicates that the network's correction of the flood peak underestimation is insufficient, and a preset penalty coefficient greater than 1 is used as the residual directional weighting factor; in other cases, the residual directional weighting factor is set to a constant. The corresponding expression is:

[0185] w _e,i =γ,e _i >0 and e _hat_i <e _i ;

[0186] w _e,i =1;

[0187] Among them, w _e,i e is the residual direction weighting factor for the i-th sample; _i e represents the true flow residual for the i-th sample; _hat_i γ represents the predicted training residual value of the i-th sample; γ is the preset penalty coefficient; in other cases, the residual direction weight factor is set to 1. This weight setting enhances the model's ability to compensate for the underestimation of flood peaks in the physical hydrological model.

[0188] Accordingly, the values ​​of the magnitude-sensitive coefficient and the positive residual undercorrection penalty coefficient can be determined by those skilled in the art using conventional hyperparameter tuning methods such as cross-validation or grid search, based on actual watershed data and validation set accuracy indicators.

[0189] Step 5032: Calculate the product of the flow rate weight factor and the residual direction weight factor, and use it as the sample weight.

[0190] Specifically, the flow rate weighting factor and the residual direction weighting factor are multiplied by a scalar, and the product of the flow rate weighting factor and the residual direction weighting factor is used as the sample weight. The corresponding expression is:

[0191] w _i =w _Q,i ×w _e,i ;

[0192] Among them, w _i Let be the sample weight for the i-th sample. This sample weight takes into account both the absolute magnitude of the flow and the physical direction of the residual.

[0193] Step 5033: Use sample weights to weight the mean square error between the actual traffic residual and the predicted training residual to obtain the loss function.

[0194] In this embodiment, the loss function is an asymmetric objective function, used to characterize the overall prediction performance of the network. Specifically, the squared difference between the actual traffic residual and the predicted training residual is calculated. Using sample weights, this squared difference is weighted and summed sample by sample to obtain the loss function. The corresponding expression is:

[0195] L=(1 / N)×∑ _i=1 N (w _i ×(e _i -e _hat_i ) 2 );

[0196] Where L is the value of the loss function, N is the number of samples in the training batch, and the superscript 2 indicates the square.

[0197] Step 504: Update the network parameters of the initial residual learning model based on the loss function to obtain the residual learning model.

[0198] Specifically, the conventional adaptive moment estimator (Adam) optimizer is used to calculate the gradient of the loss function with respect to the network parameters. Combined with an early stopping mechanism, the network parameters of the initial residual learning model are continuously updated within the maximum number of training rounds until the convergence condition is met, and the parameters are fixed to obtain the trained residual learning model.

[0199] To address the shortcomings of physical hydrological models that often underestimate flood peaks and conventional networks that tend to ignore high-water samples, this embodiment constructs a flood peak-sensitive asymmetric weighted loss function. This allows the network to preferentially fit high-flow intervals and the error characteristics underestimated by physical models, thereby improving the ability to capture flood peak flow and the accuracy of peak forecasting.

[0200] Example 6

[0201] Based on Embodiment 1 above, this embodiment further illustrates the application process in a multi-step rolling flood forecasting scenario. In one possible implementation, the present invention is applied to a multi-step rolling flood forecasting scenario, specifically including the following steps:

[0202] Step 601: When forecasting the next flood moment at the target moment, if the historical measured flow corresponding to the next moment cannot be obtained, the revised forecast result is used as a substitute measured flow to construct the current hydrological state at the next moment, and the current hydrological state at the next moment is input into the residual learning model for recursive forecasting.

[0203] In real-world multi-step rolling flood forecasting scenarios, as the forecast period lengthens, the actual future observation data has not yet occurred, resulting in the network lacking the necessary flow input characteristics when constructing the sliding time window.

[0204] In this embodiment, it is detected whether the historical measured flow corresponding to the next moment can be obtained; if it cannot be obtained, the corrected forecast result output at the previous moment is extracted and used as a substitute measured flow, which is then incorporated into the input feature sequence of the current hydrological state.

[0205] For example, when predicting the flow residual at time t+2, if the measured flow at time t+1 is unknown, then the corrected forecast result Q at time t+1 will be used. _cor (t+1) represents the historical measured flow rate Q. _obs The alternative value of (t+1) is input into the residual learning model for recursive forecasting. Based on this, continuous autoregressive rolling forecasts are completed under the condition of missing latest observations, maintaining the consistency of the model in long-term engineering applications.

[0206] Based on the above embodiments, this application also provides a flood forecast correction system based on hydrological state perception residual learning. The system includes a processor coupled to a memory. The memory stores instructions, which are executed by the processor to implement the methods described in the above embodiments.

[0207] This application also provides an electronic device, including: one or more processors and a memory, wherein the one or more processors are coupled to the memory, the memory is used to store computer program code, the computer program code including computer instructions, and when the one or more processors execute the computer instructions, the electronic device executes the methods executed in the above-described method embodiments.

[0208] This application also provides a chip, including: a processor and a communication interface, wherein the processor calls a computer program or instruction through the communication interface to execute the methods executed in the above-described method embodiments.

[0209] This application also provides a computer program product, which, when run on a computer, executes the methods described in the above-described method embodiments.

[0210] This application also provides a computer-readable storage medium storing a computer program. When the computer program is run on a computer, the computer executes the methods described in the above-described method embodiments.

[0211] The preferred embodiments of the present invention have been described in detail above. However, the present invention is not limited to the specific details in the above embodiments. Within the scope of the technical concept of the present invention, various equivalent transformations can be made to the technical solutions of the present invention, and these equivalent transformations all fall within the protection scope of the present invention.

Claims

1. A flood forecast correction method based on hydrological state-aware residual learning, characterized in that, include: Obtain hourly hydrological and meteorological data and historical measured flow rates for the study watershed; By using a physical hydrological model to simulate hourly hydrological and meteorological data, baseline forecast flow and hydrological state variables are obtained. The current hydrological status is constructed based on hourly hydro-meteorological data, historical measured flow, baseline forecast flow, and hydrological state variables. Input the current hydrological status into the residual learning model to obtain the target residual prediction value; The distance metric between the current hydrological state and the pre-stored training domain state distribution is calculated as the state deviation, and the state deviation is mapped to a gating coefficient. The target residual prediction value is weighted using a gating coefficient and then fused with the baseline forecast flow to obtain the corrected forecast result.

2. The method according to claim 1, characterized in that, Hydrological state variables include the moisture content of three soil layers; The current hydrological state is constructed based on hourly hydrological and meteorological data, historical measured flow, baseline forecast flow, and hydrological state variables, including: The comprehensive water storage deficit ratio and the rate of change of soil moisture content in the three soil layers were calculated based on the moisture content of the three soil layers. The current hydrological status is obtained by combining hourly hydrological and meteorological data, historical measured flow, baseline forecast flow, soil moisture content in the three layers, comprehensive water storage deficit ratio, and the rate of change of soil moisture content in the three layers.

3. The method according to claim 1, characterized in that, The residual learning model includes a temporal location encoding layer, a hydrological state embedding layer, a sequence encoder layer, and a state attention convergence layer; The current hydrological state is input into the residual learning model to obtain the target residual prediction value, including: By using a time-location coding layer to add time sequence information to the historical sequence in the current hydrological state, an input representation is obtained; A state embedding vector is extracted based on the current hydrological state using a hydrological state embedding layer, and then fused with the input representation to obtain the fused input representation. The sequence encoder layer is used to extract the dependencies between different time steps of the fused input representation and output the hidden state at each time step. The hidden states at each time step are weighted and aggregated using a state attention convergence layer to output the target residual prediction value.

4. The method according to claim 1, characterized in that, The distance metric between the current hydrological state and the pre-stored training domain state distribution is calculated as the state deviation, including: Obtain the stable inverse matrix of the mean vector and covariance matrix corresponding to the pre-stored training domain state distribution; The inverse or generalized inverse of the regularized covariance matrix; The Mahalanobis distance is calculated based on the current hydrological state, mean vector, and stable inverse matrix of covariance matrix. The Mahalanobis distance is used as the state deviation.

5. The method according to claim 4, characterized in that, Mapping state deviation to gating coefficients includes: Using a pre-configured critical deviation threshold and gating sensitivity parameters, the state deviation is mapped to a gating coefficient through a sigmoid activation function, so that the gating coefficient decays when the state deviation is greater than the critical deviation threshold. The target residual prediction value is weighted using a gating coefficient and then fused with the baseline forecast flow to obtain the revised forecast result, including: Calculate the product of the gating coefficient and the predicted value of the target residual as the adaptive correction amount; The baseline forecast flow is added to the adaptive correction, and a non-negativity constraint is applied to the addition result to obtain the corrected forecast result.

6. The method according to claim 5, characterized in that, The pre-configured critical deviation threshold is the preset high percentile of the distance distribution of the pre-stored training set samples; The distance values ​​of the pre-stored training set samples are at least the 90th percentile in the distance distribution.

7. The method according to claim 1, characterized in that, The residual learning model is pre-trained in the following way: Obtain a historical training sample set, which includes historical hydrological state features and corresponding real flow residuals; Historical hydrological features are input into the initial residual learning model to obtain the training residual prediction values; The loss function is calculated based on the actual flow residual and the predicted value of the training residual. The loss function is configured with sample weights to give higher optimization weights to high flow samples and samples underestimated by the physical hydrological model. The network parameters of the initial residual learning model are updated based on the loss function to obtain the residual learning model.

8. The method according to claim 1, characterized in that, Hourly hydro-meteorological data include hourly average rainfall; The current hydrological state is constructed based on hourly hydrological and meteorological data, historical measured flow, baseline forecast flow, and hydrological state variables, and also includes: Calculate the cumulative rainfall in previous periods within multiple preset historical time windows based on hourly average rainfall; The cumulative rainfall from the previous period is added as an additional feature to the current hydrological status to characterize the cumulative effect of previous rainfall in the basin.

9. The method according to claim 1, characterized in that, The method is applied to multi-step rolling flood forecasting scenarios and includes: When forecasting floods at the next time step of the target time, if the historical measured flow rate corresponding to the next time step cannot be obtained, the revised forecast result is used as a substitute measured flow rate to construct the current hydrological state at the next time step. The current hydrological state at the next time step is then input into the residual learning model for recursive forecasting.

10. A flood forecast correction system based on hydrological state-aware residual learning, characterized in that, The system includes a processor coupled to a memory storing instructions which, when executed by the processor, implement the method as claimed in any one of claims 1 to 9.