River flow forecasting method and system based on physical hydrological model and XGBoost
By combining physical hydrological models with XGBoost, and employing a time-aware loss function and adaptive weight optimization strategy, the problem of insufficient accuracy in river flow forecasting under complex underlying surfaces and extreme rainfall conditions was solved, achieving higher forecast accuracy and reliability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-12
- Publication Date
- 2026-04-14
AI Technical Summary
Existing methods for predicting river flow are not accurate enough under complex underlying surfaces and extreme rainfall conditions, and lack interpretability and adaptability. Hybrid modeling methods fail to adjust dynamically, resulting in unsatisfactory forecast results.
By combining a physical hydrological model with XGBoost, a residual correction model for river flow is created. A time-aware loss function and an adaptive weight optimization strategy are adopted. The residuals are learned through XGBoost and the weights are dynamically adjusted to correct the bias of the physical hydrological model.
It improves the accuracy and reliability of river flow forecasting, especially showing stronger robustness and adaptability in extreme events, while maintaining the interpretability of the physical model and the fitting ability of the data model.
Smart Images

Figure CN121858853A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of water conservancy and hydrological forecasting and water resources management technology, and in particular to a method and system for forecasting river flow based on physical hydrological models and XGBoost. Background Technology
[0002] In current water resource management, flood and drought prevention, and water conservancy project scheduling, river flow forecasting is a crucial non-engineering measure. Accurate flow forecasts provide key information for flood control decisions, reservoir operation optimization, and water supply planning, effectively improving flood and drought disaster prevention capabilities and water resource utilization efficiency. Currently, there are two main methods for river flow forecasting: One approach is the traditional physics-driven hydrological modeling method, such as the SCS-CN runoff generation model, the Nash unit hydrograph confluence model, and the Muskingum channel evolution model developed by the U.S. Department of Agriculture. This type of method is based on hydrological mechanisms, constructing a complete physical simulation chain from rainfall to runoff generation, confluence, and channel evolution, thus achieving a systematic description of the watershed's hydrological cycle. A typical process includes: (1) determining the runoff coefficient based on the watershed's early soil moisture; (2) calculating slope confluence using the unit hydrograph method; (3) simulating flood propagation in the river network using channel calculation methods; and (4) superimposing baseflow components to generate the final flow forecast results. This type of method has a strong physical basis and process interpretability.
[0003] The second type is the pure data-driven machine learning method that has emerged in recent years, such as flow forecasting models built based on algorithms like LSTM neural networks, random forests, and support vector machines. These methods do not explicitly describe hydrophysical processes; instead, they use historical meteorological and hydrological data to directly learn the mapping relationship from input to output, achieving end-to-end flow forecasting and demonstrating high fitting accuracy in some watersheds.
[0004] However, existing technologies still have the following shortcomings: First, traditional hydrological models are highly sensitive to parameters, and their forecasting performance depends heavily on the accurate calibration of parameters such as the Manning coefficient, soil infiltration rate, and channel roughness. Under complex underlying surface conditions, such as in mountainous areas, the spatial variability of parameters is large, making it difficult for models to accurately reflect the actual hydrological response mechanism, thus limiting forecast accuracy.
[0005] Second, physical models are poorly adapted to extreme rainfall or sudden flood scenarios and lack the ability to learn from real-time observation data. For example, when faced with short-duration heavy rainfall, these models often suffer from problems such as underestimating the flood peak and delaying the peak arrival time, making it difficult to meet the high-precision requirements for real-time flood early warning.
[0006] Third, while pure data-driven machine learning models perform well in terms of fitting accuracy, they have "black box" characteristics. The prediction results lack physical constraints and interpretability, and may violate basic physical laws such as mass conservation and energy balance. They also have poor generalization ability under extreme conditions where the training samples are not covered, and the reliability of the prediction is difficult to guarantee.
[0007] Fourth, existing hybrid modeling methods mostly adopt static weight fusion strategies, failing to adaptively adjust based on the dynamic performance of physical and data models under different hydrological scenarios, resulting in unsatisfactory integrated forecasting results.
[0008] Therefore, how to provide a river flow forecasting method and system based on physical hydrological models and XGBoost to improve the accuracy and reliability of river flow forecasting has become an urgent technical problem to be solved. Summary of the Invention
[0009] The technical problem to be solved by the present invention is to provide a method and system for river flow forecasting based on physical hydrological models and XGBoost, so as to improve the accuracy and reliability of river flow forecasting.
[0010] In a first aspect, the present invention provides a method for predicting river flow based on a physical hydrological model and XGBoost, comprising the following steps: Step S1: Create a river flow residual correction model based on the XGBoost network, and set the loss function of the river flow residual correction model as the time-aware loss function; Step S2: Acquire a large amount of historical meteorological data, historical hydrological observation data, and historical physical prediction data of the physical hydrological model group; the physical hydrological model group includes the pre-trained SCS-CN runoff generation model, Nash unit hydrograph confluence model, Muskingum channel evolution model, and exponential decay baseflow model. Step S3: Preprocess the historical meteorological data, historical hydrological observation data and historical physical prediction data, and extract 44-dimensional historical river flow characteristics. Construct a dataset based on the historical meteorological data, historical physical prediction data and historical river flow characteristics. Step S4: Train the river flow residual correction model using the dataset and the time-aware loss function, and test and deploy the trained river flow residual correction model. Step S5: Obtain real-time meteorological data and real-time hydrological observation data, and input the real-time meteorological data and real-time hydrological observation data into the physical hydrological model group to obtain real-time physical prediction data; Step S6: Extract 44-dimensional real-time river flow characteristics from the real-time meteorological data, real-time hydrological observation data, and real-time physical prediction data; Step S7: Input the real-time hydrological observation data, real-time physical prediction data and real-time river flow characteristics into the deployed river flow residual correction model to obtain the residual value of the total predicted flow of the physical hydrological model group. Step S8: Search for the weight coefficients of the residual value using an adaptive weight optimization strategy; Step S9: Obtain the final predicted river flow using the total predicted flow output by the physical hydrological model group, the residual value output by the river flow residual correction model, and the weighting coefficients. Perform channel flow forecasting based on the predicted river flow.
[0011] Furthermore, in step S1, the formula for the time-aware loss function is: ; in, This represents the loss value of the time-aware loss function; N represents the total number of time points included in a single computation used to train the model. Represents the weighting function; Represents the true residual; This represents the predicted residual value; In step S2, the historical meteorological data includes at least rainfall, temperature, wind speed, and timestamp; The historical hydrological observation data includes at least measured flow rate, water level data, and timestamps; The historical physical prediction data includes excess permeability yield, unit runoff, channel runoff, base flow, and total predicted flow; total predicted flow = channel runoff + base flow; The SCS-CN runoff model is used to calculate excess permeability runoff; the Nash unitline runoff model is used to calculate unitline runoff based on excess permeability runoff; the Muskingum channel evolution model is used to calculate channel runoff based on unitline runoff; and the exponentially decaying baseflow model is used to calculate baseflow based on soil moisture content and superimpose it with surface runoff to form total runoff.
[0012] Furthermore, step S3 specifically includes: The historical meteorological data, historical hydrological observation data, and historical physical prediction data are preprocessed, including time alignment, missing value handling, outlier handling, data consistency check, and data standardization. 44-dimensional historical river flow characteristics are then extracted from the preprocessed historical meteorological data, historical hydrological observation data, and historical physical prediction data. The historical river flow characteristics include 5-dimensional physical model intermediate process characteristics, 15-dimensional rainfall statistical characteristics, 4-dimensional rainfall pattern classification characteristics, 2-dimensional anterior impact characteristics, 6-dimensional flow lag characteristics, 6-dimensional time periodicity characteristics, 3-dimensional watershed response characteristics, and 3-dimensional model residual characteristics. A dataset is constructed based on the aforementioned historical meteorological data, historical physical prediction data, and historical river flow characteristics.
[0013] Furthermore, step S4 specifically includes: Based on the chronological order, the dataset is divided into a training set, a validation set, and a test set in a ratio of 70%:15%:15%. The river flow residual correction model is trained by selecting a preset training batch from the training set. After each training batch is completed, the validation loss value of the time-aware loss function is calculated through the validation set, and the hyperparameters of the river flow residual correction model are tuned until the validation loss value does not decrease for 20 consecutive training batches to complete the training. The Nash-Sutcliffe efficiency coefficient, root mean square error, and flood peak error index are calculated using the test set to test the trained river flow residual correction model. The river flow residual correction model that passes the test is then deployed. Step S5 specifically involves: Real-time meteorological data and real-time hydrological observation data are acquired. After preprocessing the real-time meteorological data and real-time hydrological observation data, they are input into a physical hydrological model group after the physical model parameters have been calibrated by a genetic algorithm to obtain real-time physical prediction data.
[0014] Furthermore, step S8 specifically includes: The optimal weight coefficient is selected by iterating through the weight coefficient values of the residual values using the constrained regression optimization method, the feature-based dynamic weight prediction method, and the sliding window local search method, respectively. In step S9, the predicted river flow = total predicted flow + weighting coefficient * residual value.
[0015] Secondly, the present invention provides a river flow forecasting system based on a physical hydrological model and XGBoost, comprising the following modules: The river flow residual correction model creation module is used to create a river flow residual correction model based on the XGBoost network, and the loss function of the river flow residual correction model is set as the time-aware loss function. The historical data acquisition module is used to acquire a large amount of historical meteorological data, historical hydrological observation data, and historical physical prediction data of the physical hydrological model group; the physical hydrological model group includes the pre-trained SCS-CN runoff generation model, the Nash unit hydrograph confluence model, the Muskingum channel evolution model, and the exponential decay baseflow model. The dataset construction module is used to preprocess the historical meteorological data, historical hydrological observation data and historical physical prediction data, extract 44-dimensional historical river flow characteristics, and construct a dataset based on the historical meteorological data, historical physical prediction data and historical river flow characteristics. The river flow residual correction model training module is used to train the river flow residual correction model using the dataset and the time-aware loss function, and to test and deploy the trained river flow residual correction model. The real-time physical prediction data output module is used to acquire real-time meteorological data and real-time hydrological observation data, and input the real-time meteorological data and real-time hydrological observation data into the physical hydrological model group to obtain real-time physical prediction data. The real-time river flow feature extraction module is used to extract 44-dimensional real-time river flow features from the real-time meteorological data, real-time hydrological observation data, and real-time physical prediction data. The residual value output module is used to input the real-time hydrological observation data, real-time physical prediction data and real-time river flow characteristics into the deployed river flow residual correction model to obtain the residual value of the total predicted flow of the physical hydrological model group. The weight coefficient search module is used to search for the weight coefficients of the residual value through an adaptive weight optimization strategy. The channel flow forecasting module is used to obtain the final predicted river flow through the total predicted flow output by the physical hydrological model group, the residual value output by the channel flow residual correction model, and the weighting coefficients, and to perform channel flow forecasting based on the predicted river flow.
[0016] Furthermore, in the river flow residual correction model creation module, the formula for the time-aware loss function is: ; in, This represents the loss value of the time-aware loss function; N represents the total number of time points included in a single computation used to train the model. Represents the weighting function; Represents the true residual; This represents the predicted residual value; In the historical data acquisition module, the historical meteorological data includes at least rainfall, temperature, wind speed, and timestamp; The historical hydrological observation data includes at least measured flow rate, water level data, and timestamps; The historical physical prediction data includes excess permeability yield, unit runoff, channel runoff, base flow, and total predicted flow; total predicted flow = channel runoff + base flow; The SCS-CN runoff model is used to calculate excess permeability runoff; the Nash unitline runoff model is used to calculate unitline runoff based on excess permeability runoff; the Muskingum channel evolution model is used to calculate channel runoff based on unitline runoff; and the exponentially decaying baseflow model is used to calculate baseflow based on soil moisture content and superimpose it with surface runoff to form total runoff.
[0017] Furthermore, the dataset construction module is specifically used for: The historical meteorological data, historical hydrological observation data, and historical physical prediction data are preprocessed, including time alignment, missing value handling, outlier handling, data consistency check, and data standardization. 44-dimensional historical river flow characteristics are then extracted from the preprocessed historical meteorological data, historical hydrological observation data, and historical physical prediction data. The historical river flow characteristics include 5-dimensional physical model intermediate process characteristics, 15-dimensional rainfall statistical characteristics, 4-dimensional rainfall pattern classification characteristics, 2-dimensional anterior impact characteristics, 6-dimensional flow lag characteristics, 6-dimensional time periodicity characteristics, 3-dimensional watershed response characteristics, and 3-dimensional model residual characteristics. A dataset is constructed based on the aforementioned historical meteorological data, historical physical prediction data, and historical river flow characteristics.
[0018] Furthermore, the river flow residual correction model training module is specifically used for: Based on the chronological order, the dataset is divided into a training set, a validation set, and a test set in a ratio of 70%:15%:15%. The river flow residual correction model is trained by selecting a preset training batch from the training set. After each training batch is completed, the validation loss value of the time-aware loss function is calculated through the validation set, and the hyperparameters of the river flow residual correction model are tuned until the validation loss value does not decrease for 20 consecutive training batches to complete the training. The Nash-Sutcliffe efficiency coefficient, root mean square error, and flood peak error index are calculated using the test set to test the trained river flow residual correction model. The river flow residual correction model that passes the test is then deployed. The real-time physics prediction data output module is specifically used for: Real-time meteorological data and real-time hydrological observation data are acquired. After preprocessing the real-time meteorological data and real-time hydrological observation data, they are input into a physical hydrological model group after the physical model parameters have been calibrated by a genetic algorithm to obtain real-time physical prediction data.
[0019] Furthermore, the weight coefficient search module is specifically used for: The optimal weight coefficient is selected by iterating through the weight coefficient values of the residual values using the constrained regression optimization method, the feature-based dynamic weight prediction method, and the sliding window local search method, respectively. In the channel flow forecasting module, the predicted channel flow = total predicted flow + weighting coefficient * residual value.
[0020] The advantages of this invention are: 1. A river flow residual correction model was created based on the XGBoost network, with a time-aware loss function. A large amount of historical meteorological data, historical hydrological observation data, and historical physical prediction data from the physical-hydrological model group were then acquired. These historical meteorological, hydrological, and physical prediction data were preprocessed, and 44-dimensional historical river flow features were extracted. A dataset was constructed based on these historical meteorological, physical prediction, and river flow features. The river flow residual correction model was then trained using the dataset and the time-aware loss function, and the trained model was tested and deployed. Next, real-time meteorological and hydrological observation data were input into the pre-trained physical-hydrological model group to obtain real-time physical prediction data. 44-dimensional real-time river flow features were extracted from these data and input into the river flow residual correction model to obtain the residual values of the physical-hydrological model group. Finally, an adaptive weight optimization strategy was used to search for the weights of the residual values. The weighting coefficients are used to obtain the final predicted river flow, based on the total predicted flow, residual values, and weighting coefficients. Channel flow forecasting is then performed based on this predicted flow. This involves constructing a hybrid framework of "physical model as baseline, dynamic correction via machine learning" to systematically improve the accuracy and reliability of channel flow forecasting. Specifically, it doesn't simply replace or statically combine two models; instead, it first uses a hydrological model with physical mechanisms (physical-hydrological model set) to generate a basic forecast (real-time physical prediction data), and then uses a channel flow residual correction model to predict the residual values of the physical-hydrological model set. An adaptive weighting optimization strategy is introduced to dynamically adjust the intensity of residual correction based on real-time hydrological conditions. Finally, the weighted residuals are compensated to the forecast values of the physical hydrological model group to obtain the final result. This architecture not only preserves the interpretability and physical constraints of the physical hydrological model group, but also utilizes the powerful fitting ability of the data-driven model to correct the systematic biases of the physical hydrological model group under scenarios such as complex underlying surfaces and extreme rainfall. At the same time, the time-aware loss function is used to optimize the forecast accuracy of key periods such as flood peaks, which ultimately greatly improves the accuracy and reliability of river flow forecasts.
[0021] 2. By combining physical hydrological models (such as the SCS-CN runoff model and the Nash unit hydrograph model) with the XGBoost machine learning model, the physical model provides a prediction basis based on physical mechanisms, while the XGBoost model learns residuals through a data-driven approach to correct the biases of the physical model. This fusion approach not only utilizes the interpretability of the physical model but also leverages the advantages of machine learning in handling nonlinear relationships and complex patterns, making river flow forecasts more accurate and reliable. In particular, it demonstrates stronger robustness in the prediction of extreme events (such as floods), showing a significant improvement over single-model methods.
[0022] 3. During the model training phase, a time-aware loss function was introduced. This function dynamically adjusts the importance of errors at different time points through a weighting function, thereby more effectively capturing the time-dependent characteristics of river flow. This helps the model better learn dynamic processes such as flood peak evolution and baseflow decay, reducing prediction lag or lead errors and improving the time-series consistency of forecasts. Compared with traditional mean square error loss, time-aware loss is more adaptable to the non-stationarity of hydrological data, enhancing the practicality of the model in long-term forecasts.
[0023] 4. By extracting 44-dimensional river flow features from multi-source data (historical meteorological, hydrological observation, and physical prediction data), including diverse features such as intermediate processes of physical models, rainfall statistics, and time periodicity, and performing preprocessing steps such as time alignment and missing value handling, this meticulous feature engineering ensures the integrity, consistency, and representativeness of the input data. It can capture the key driving factors of watershed response, provide high-quality input for model training, thereby reducing the risk of overfitting and improving the generalization ability of forecasts.
[0024] 5. By dividing the dataset into training, validation, and test sets (70%:15%:15%) in chronological order, and employing hyperparameter tuning and early stopping strategies (such as ensuring the loss does not decrease after 20 consecutive validation batches), systematic training and evaluation of the model were achieved. During the testing phase, multiple metrics, including the Nash-Sutcliffe efficiency coefficient, were used for validation, ensuring the model's performance on unknown data. This rigorous process avoids overfitting, improves the model's stability in actual deployment, and meets the high reliability requirements of hydrological forecasting.
[0025] 6. In the real-time forecasting stage, real-time physical prediction data is generated through physical hydrological models, and residual values are output using the XGBoost model. Then, the weight coefficients are dynamically adjusted by combining adaptive weight optimization strategies (such as constrained regression and sliding window local search). This mechanism allows the system to automatically optimize the correction amount according to the characteristics of real-time data, making the final forecast (predicted river flow = total predicted flow + weight coefficient * residual value) more adaptive and accurate, especially suitable for rapid response to climate change or sudden hydrological events.
[0026] 7. By integrating the physical hydrological model group with the XGBoost model in the form of residual prediction, the physical model provides the basic prediction, while the machine learning model is responsible for learning the residual error. This well-defined structure retains the mechanistic transparency of the physical model and makes up for its shortcomings through data-driven methods. At the same time, adaptive weight optimization allows the fusion strategy to be adjusted under different hydrological conditions, which enhances flexibility and interpretability and facilitates customized adjustments according to needs in practical applications.
[0027] 8. To address the high parameter sensitivity, the XGBoost residual learning mechanism is introduced to automatically correct the systematic bias caused by parameter uncertainty in the physical hydrological model group. Even if the parameter calibration of the physical hydrological model group is not accurate enough, the river flow residual correction model can achieve intelligent compensation by learning historical error patterns, significantly reducing the model's dependence on parameter accuracy and improving model robustness. To address the poor forecasting capability for extreme events, multi-time-window rainfall statistics, rainfall pattern classification, and flow lag characteristics are constructed, and a time-aware loss function is innovatively introduced, enabling XGBoost to fully explore the nonlinear response patterns under extreme rainfall. In flood peak forecasting, compared with traditional physical models (error > 90%), the relative error is significantly controlled within 15%-45%, with the TW-MSE mechanism further reducing the error by 8%-12%, achieving a breakthrough in the accurate capture of key hydrological events. To address the lack of physical constraints, a complete physical hydrological process framework (SCS-CN runoff generation model, Nash unit hydrograph confluence model, Muskingum channel evolution model, and exponentially decaying baseflow model) is retained to ensure that the prediction results conform to water balance and hydrological physical laws. The channel flow residual correction model only learns the residual correction term, rather than directly predicting the flow, thus maintaining good interpretability and physical consistency while improving accuracy. To address the poor fusion effect of fixed weights, an adaptive weight learning ensemble strategy (constrained regression, feature prediction, and sliding search) is introduced. This strategy can dynamically adjust the fusion ratio between the physical hydrological model group and the channel flow residual correction model according to different hydrological conditions and model performance. The weight of the physical hydrological model group is increased when it performs well during the dry season, and its weight is increased when the channel flow residual correction model has higher accuracy during the flood peak season, achieving the optimal fusion effect of "complementary advantages and dynamic balance". Attached Figure Description
[0028] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0029] Figure 1 This is a flowchart of a river flow forecasting method based on a physical hydrological model and XGBoost according to the present invention.
[0030] Figure 2This is a schematic diagram of the structure of a river flow forecasting system based on a physical hydrological model and XGBoost according to the present invention. Detailed Implementation
[0031] The overall approach of the technical solution in this application is as follows: First, real-time physical prediction data is generated using a physical hydrological model set. Then, the residual value of the physical hydrological model set is predicted using a river flow residual correction model. An adaptive weight optimization strategy is introduced to dynamically adjust the intensity of residual correction according to the real-time hydrological situation. Finally, the weighted residual is compensated to the predicted value of the physical hydrological model set to obtain the final result (predicted river flow). This architecture retains the interpretability and physical constraints of the physical hydrological model set, while using the powerful fitting ability of the data-driven model to correct the systematic bias of the physical hydrological model set under scenarios such as complex underlying surfaces and extreme rainfall. At the same time, the forecast accuracy of key periods such as flood peaks is optimized through a time-aware loss function, thereby improving the accuracy and reliability of river flow forecast.
[0032] Please refer to Figures 1 to 2 As shown, a preferred embodiment of the river flow forecasting method based on a physical hydrological model and XGBoost according to the present invention includes the following steps: Step S1: Create a river flow residual correction model based on the XGBoost network, and set the loss function of the river flow residual correction model as the Temporal-Weighted Mean Squared Error (TW-MSE). The river flow residual correction model uses the gradient boosting tree algorithm to learn the residual values of the physical hydrological model set, thereby realizing intelligent correction of the systematic errors of the physical hydrological model set.
[0033] Step S2: Acquire a large amount of historical meteorological data, historical hydrological observation data, and historical physical prediction data of the physical hydrological model group; the physical hydrological model group includes the pre-trained SCS-CN runoff generation model, Nash unit hydrograph confluence model, Muskingum channel evolution model, and exponential decay baseflow model. Step S3: Preprocess the historical meteorological data, historical hydrological observation data and historical physical prediction data, and extract 44-dimensional historical river flow characteristics. Construct a dataset based on the historical meteorological data, historical physical prediction data and historical river flow characteristics. In practice, a fixed time window sliding method is used to construct training samples: Input features: 72 consecutive hours of meteorological data, physical prediction data, and 44-dimensional river flow characteristics; Prediction target: measured flow for the next hour (or a 24-hour sequence); Sliding step size: 1 hour, to ensure the continuity of sample time; Step S4: Train the river flow residual correction model using the dataset and the time-aware loss function, and test and deploy the trained river flow residual correction model. Step S5: Obtain real-time meteorological data and real-time hydrological observation data, and input the real-time meteorological data and real-time hydrological observation data into the physical hydrological model group to obtain real-time physical prediction data; Step S6: Extract 44-dimensional real-time river flow characteristics from the real-time meteorological data, real-time hydrological observation data, and real-time physical prediction data; Step S7: Input the real-time hydrological observation data, real-time physical prediction data and real-time river flow characteristics into the deployed river flow residual correction model to obtain the residual value of the total predicted flow of the physical hydrological model group. Step S8: Search for the weight coefficients of the residual value using an adaptive weight optimization strategy; Step S9: Obtain the final predicted river flow using the total predicted flow output by the physical hydrological model group, the residual value output by the river flow residual correction model, and the weighting coefficients. Perform channel flow forecasting based on the predicted river flow.
[0034] In step S1, the formula for the time-aware loss function is: ; in, This represents the loss value of the time-aware loss function; N represents the total number of time points included in a single computation used to train the model. Represents the weighting function; Represents the true residual; This represents the predicted residual value; ; Where α represents the weight enhancement coefficient, which is used to control the maximum increase of the peak weight (the empirical value range is 1.0~2.0). The measured flow rate at time t; The peak flow threshold is typically defined as a specific high quantile in the historical flow series of the basin, such as the 95th percentile; σ represents the bandwidth parameter, used to control the rate at which the weight decays as the flow deviates from the threshold, and is usually set to 0.2*. ; when far below hour, ≈1, the model learns at a normal intensity.
[0035] when Approaching or exceeding hour, If the value is significantly increased (up to 1+α), the model will devote more "attention" to correcting the residual values of the physical hydrological model group for that period.
[0036] The weighting function forms an "attention peak" centered on the flood peak threshold, thereby guiding XGBoost to prioritize the prediction accuracy of the flood peak segment.
[0037] XGBoost (eXtreme Gradient Boosting) is an efficient gradient boosting decision tree algorithm that trains multiple decision trees sequentially in a regularized manner. It improves model performance by continuously fitting the residuals of the previous prediction. Its standard loss function is mean squared error (MSE), which treats all samples equally. However, the traditional MSE loss function has limitations in flood forecasting because it treats prediction errors during the normal water period and the flood peak period equally. But in hydrological forecasting, accurate prediction of the flood peak period is crucial for disaster prevention and mitigation. To address this, this invention designs a dynamic weighting mechanism that allows the model to focus more on key hydrological periods during training.
[0038] In step S2, the historical meteorological data includes at least rainfall, temperature, wind speed, and timestamp; The historical hydrological observation data includes at least measured flow rate, water level data, and timestamps; The historical physical prediction data includes excess permeability yield, unit runoff, channel runoff, base flow, and total predicted flow; total predicted flow = channel runoff + base flow; The SCS-CN runoff model is used to calculate excess permeability runoff; the Nash unitline runoff model is used to calculate unitline runoff based on excess permeability runoff; the Muskingum channel evolution model is used to calculate channel runoff based on unitline runoff; and the exponentially decaying baseflow model is used to calculate baseflow based on soil moisture content (or groundwater storage) and superimpose it with surface runoff to form total runoff.
[0039] The SCS-CN runoff model is based on the Curve Number Method developed by the USDA Soil Conservation Service to calculate watershed runoff (excessive infiltration runoff). The core parameter of the model is the Curve Number (CN) value, which reflects the watershed's runoff capacity.
[0040] The Nash unit hydrograph confluence model uses Nash instantaneous unit hydrograph theory to simulate the watershed confluence process, generalizing the watershed into a system of n linear reservoirs connected in series, with each reservoir having a time delay of k hours.
[0041] The Muskingum channel evolution model is used to simulate the propagation process of floods in a river channel. Based on the water balance equation and the storage-discharge relationship, it uses two parameters (K, X) to describe the channel characteristics. K is the storage constant / propagation time, which has the dimension of time and represents the propagation time of the flood wave in the river segment. The larger the K value, the longer it takes for the flood to propagate from upstream to downstream. X is a weighting factor that reflects the importance of wedge-shaped storage relative to cylindrical storage in the river segment. The X value represents the weight of upstream and downstream flow in calculating the storage capacity of the river segment. X=0 indicates that the storage capacity is only related to the downstream flow (such as a reservoir). X=0.5 indicates that the storage capacity is related to the difference in flow between the upstream and downstream sections (showing obvious wedge-shaped storage).
[0042] The exponentially decaying baseflow model is used to simulate the continuous recharge process of groundwater into river channels. It takes into account the delayed recharge effect of rainfall on groundwater and improves the forecast accuracy for dry seasons and baseflow sections.
[0043] The physical hydrological model group constitutes a complete physical chain of "rainfall → runoff generation → confluence → river channel → baseflow". Its output results and intermediate process variables provide important features for the subsequent river flow residual correction model.
[0044] Step S3 specifically involves: The historical meteorological data, historical hydrological observation data, and historical physical prediction data are preprocessed with at least the following steps: time alignment (alignment at the hourly level), missing value handling (using linear interpolation to fill in missing values, with a single missing value not exceeding 6 hours), outlier handling (using the 3σ criterion to identify outliers, combined with manual review and confirmation), data consistency check (ensuring the spatiotemporal matching of rainfall and flow data), and data standardization (X_normalized=(X-μ) / σ, where μ and σ are the mean and standard deviation, respectively, and X is the data to be standardized). A 44-dimensional historical river flow feature is then extracted from the preprocessed historical meteorological data, historical hydrological observation data, and historical physical prediction data. The historical river flow characteristics include 5-dimensional physical model intermediate process characteristics, 15-dimensional rainfall statistical characteristics, 4-dimensional rainfall pattern classification characteristics, 2-dimensional anterior impact characteristics, 6-dimensional flow lag characteristics, 6-dimensional time periodicity characteristics, 3-dimensional watershed response characteristics, and 3-dimensional model residual characteristics. A dataset is constructed based on the aforementioned historical meteorological data, historical physical prediction data, and historical river flow characteristics.
[0045] The intermediate process characteristics of the physical model include excess permeability production, unit line runoff, channel runoff, base flow, and total predicted flow.
[0046] Rainfall statistics include cumulative rainfall (reflecting the total amount of rainfall at different time points) in five time windows: 3 hours, 6 hours, 12 hours, 24 hours, and 48 hours; maximum rainfall intensity (capturing extreme rainfall events); and rainfall variation coefficient (characterizing the non-uniformity of the spatiotemporal distribution of rainfall). Through multi-scale time windows, the model can simultaneously perceive the impact of short-term heavy rainfall and the long-term cumulative effects.
[0047] The rainfall pattern classification features include light rain indicators (0-2.5 mm / h), moderate rain indicators (2.5-10 mm / h), heavy rain indicators (10-25 mm / h), and torrential rain indicators (>25 mm / h); each indicator is a binary variable (0 or 1) used to identify the watershed response characteristics under different rainfall patterns.
[0048] The early impact characteristics include the 7-day API (Antecedent Precipitation Index) and the 14-day API; the API is used to quantify soil moisture status, and the 7-day API and 14-day API reflect the impact of short-term and medium-term soil water storage status on runoff generation capacity, respectively.
[0049] The flow lag characteristics include Qt-1 (historical flow 1-hour lag value), Qt-2 (historical flow 2-hour lag value), Qt-3, Qt-6, Qt-12, and Qt-24; these lag characteristics characterize the short-term memory (1-3 hours), medium-term memory (6 hours), and long-term memory (12-24 hours) of the watershed hydrological response.
[0050] The time periodicity features include hourly periods encoded by the SIN and COS functions. Weekly cycle Annual cycle The use of trigonometric functions to encode time periodicity avoids the boundary abruptness problem of linear coding. These characteristics reflect the regularity of evapotranspiration, human activities and seasonal hydrological changes.
[0051] Watershed response characteristics include rainfall-runoff ratio (the ratio of current flow to cumulative rainfall, which assesses runoff generation efficiency), baseflow ratio (the proportion of baseflow to total flow, reflecting the contribution of groundwater), and peak flow indicator variable (indicating whether the current period is a flood peak (1 when flow > threshold)).
[0052] The model residual features include the current residual, the residual after 1 hour lag, and the residual after 2 hours lag; by learning the temporal pattern of the residuals, the model can capture the systematic bias of the physical model.
[0053] Step S4 specifically involves: Based on chronological order, the dataset is divided into a training set (e.g., 2017-2021), a validation set (e.g., 2022-2023), and a test set (e.g., 2024-2025) in a ratio of 70%:15%:15% to avoid data leakage; The river flow residual correction model is trained by selecting a preset training batch from the training set. After each training batch is completed, the validation loss value of the time-aware loss function is calculated through the validation set, and the hyperparameters of the river flow residual correction model are tuned until the validation loss value does not decrease for 20 consecutive training batches to complete the training. The Nash-Sutcliffe efficiency coefficient (NSE, where a closer NSE to 1 indicates better model performance and NSE < 0 indicates that the model is inferior to the mean baseline), root mean square error (RMSE, where a smaller RMSE indicates higher prediction accuracy, with units the same as flow rate (cms or m³ / s)), and flood peak error indices (flood peak flow relative error: |(Qpeak_pred-Qpeak_obs)| / Qpeak_obs; peak occurrence time error: |Tpeak_pred-Tpeak_obs| (hours)) were calculated using the test set. The trained river flow residual correction model was then tested, and the tested river flow residual correction model was deployed. For the deployment of the river flow residual correction model, in specific implementation, the tested river flow residual correction model can be saved as a model file in .json or .pkl format and encapsulated as a RESTful API interface: the interface response time is controlled within 500ms to meet the real-time forecasting requirements.
[0054] For resource-constrained edge devices, a model compression technique is employed to compress the river flow residual correction model. This includes: feature selection: retaining the Top-30 features based on importance ranking; tree pruning: limiting the maximum tree depth and number of trees in XGBoost; and quantization acceleration: using int8 quantization to reduce computational complexity. The compressed model maintains over 95% of the original model's accuracy, while inference speed is improved by 2-5 times.
[0055] A model performance monitoring mechanism was established: real-time tracking of forecast errors (RMSE, NSE); regular (e.g., quarterly) retraining of the model using the latest data; and triggering model updates when forecast errors exceed a threshold. Incremental learning or online learning methods were used to ensure that the model always adapts to the latest hydrological characteristics of the watershed.
[0056] Step S5 specifically involves: Real-time meteorological data and real-time hydrological observation data are acquired. After preprocessing the real-time meteorological data and real-time hydrological observation data, they are input into the physical hydrological model group after the physical model parameters have been calibrated by the genetic algorithm (the objective function is to minimize the negative value of NSE) to obtain real-time physical prediction data.
[0057] Step S8 specifically involves: The optimal weight coefficients are selected by iterating through the values of the weight coefficients of the residuals using the constrained regression optimization method (constrained regression method), the feature-based dynamic weight prediction method (feature prediction method), and the sliding window local search method (sliding search method). This involves dynamically adjusting the fusion weights of the physical hydrological model group and the river flow residual correction model based on model performance and hydrological conditions to achieve optimal forecasting results. Specifically, through an adaptive weighting strategy, the optimal fusion method can be automatically selected under different hydrological conditions, significantly improving forecast stability. The constrained regression optimization method fixes the optimal weights through global optimization; the feature-based dynamic weight prediction method predicts the optimal weights in real time based on current hydrological and meteorological conditions by constructing a weight prediction model; and the sliding window local search method adjusts the weights in real time based on model performance within a sliding time window using a local greedy search strategy.
[0058] In step S9, the predicted river flow = total predicted flow + weighting coefficient * residual value.
[0059] A preferred embodiment of the river flow forecasting system based on a physical hydrological model and XGBoost according to the present invention includes the following modules: The river flow residual correction model creation module is used to create a river flow residual correction model based on the XGBoost network. The loss function of the river flow residual correction model is set as the Temporal-Weighted Mean Squared Error (TW-MSE). The river flow residual correction model uses the gradient boosting tree algorithm to learn the residual values of the physical hydrological model set, thereby realizing intelligent correction of the systematic errors of the physical hydrological model set.
[0060] The historical data acquisition module is used to acquire a large amount of historical meteorological data, historical hydrological observation data, and historical physical prediction data of the physical hydrological model group; the physical hydrological model group includes the pre-trained SCS-CN runoff generation model, the Nash unit hydrograph confluence model, the Muskingum channel evolution model, and the exponential decay baseflow model. The dataset construction module is used to preprocess the historical meteorological data, historical hydrological observation data and historical physical prediction data, extract 44-dimensional historical river flow characteristics, and construct a dataset based on the historical meteorological data, historical physical prediction data and historical river flow characteristics. In practice, a fixed time window sliding method is used to construct training samples: Input features: 72 consecutive hours of meteorological data, physical prediction data, and 44-dimensional river flow characteristics; Prediction target: measured flow for the next hour (or a 24-hour sequence); Sliding step size: 1 hour, to ensure the continuity of sample time; The river flow residual correction model training module is used to train the river flow residual correction model using the dataset and the time-aware loss function, and to test and deploy the trained river flow residual correction model. The real-time physical prediction data output module is used to acquire real-time meteorological data and real-time hydrological observation data, and input the real-time meteorological data and real-time hydrological observation data into the physical hydrological model group to obtain real-time physical prediction data. The real-time river flow feature extraction module is used to extract 44-dimensional real-time river flow features from the real-time meteorological data, real-time hydrological observation data, and real-time physical prediction data. The residual value output module is used to input the real-time hydrological observation data, real-time physical prediction data and real-time river flow characteristics into the deployed river flow residual correction model to obtain the residual value of the total predicted flow of the physical hydrological model group. The weight coefficient search module is used to search for the weight coefficients of the residual value through an adaptive weight optimization strategy. The channel flow forecasting module is used to obtain the final predicted river flow through the total predicted flow output by the physical hydrological model group, the residual value output by the channel flow residual correction model, and the weighting coefficients, and to perform channel flow forecasting based on the predicted river flow.
[0061] In the river flow residual correction model creation module, the formula for the time-aware loss function is: ; in, This represents the loss value of the time-aware loss function; N represents the total number of time points included in a single computation used to train the model. Represents the weighting function; Represents the true residual; This represents the predicted residual value; ; Where α represents the weight enhancement coefficient, which is used to control the maximum increase of the peak weight (the empirical value range is 1.0~2.0). The measured flow rate at time t; The peak flow threshold is typically defined as a specific high quantile in the historical flow series of the basin, such as the 95th percentile; σ represents the bandwidth parameter, used to control the rate at which the weight decays as the flow deviates from the threshold, and is usually set to 0.2*. ;; when far below hour, ≈1, the model learns at a normal intensity.
[0062] when Approaching or exceeding hour, If the value is significantly increased (up to 1+α), the model will devote more "attention" to correcting the residual values of the physical hydrological model group for that period.
[0063] The weighting function forms an "attention peak" centered on the flood peak threshold, thereby guiding XGBoost to prioritize the prediction accuracy of the flood peak segment.
[0064] XGBoost (eXtreme Gradient Boosting) is an efficient gradient boosting decision tree algorithm that trains multiple decision trees sequentially in a regularized manner. It improves model performance by continuously fitting the residuals of the previous prediction. Its standard loss function is mean squared error (MSE), which treats all samples equally. However, the traditional MSE loss function has limitations in flood forecasting because it treats prediction errors during the normal water period and the flood peak period equally. But in hydrological forecasting, accurate prediction of the flood peak period is crucial for disaster prevention and mitigation. To address this, this invention designs a dynamic weighting mechanism that allows the model to focus more on key hydrological periods during training.
[0065] In the historical data acquisition module, the historical meteorological data includes at least rainfall, temperature, wind speed, and timestamp; The historical hydrological observation data includes at least measured flow rate, water level data, and timestamps; The historical physical prediction data includes excess permeability yield, unit runoff, channel runoff, base flow, and total predicted flow; total predicted flow = channel runoff + base flow; The SCS-CN runoff model is used to calculate excess permeability runoff; the Nash unitline runoff model is used to calculate unitline runoff based on excess permeability runoff; the Muskingum channel evolution model is used to calculate channel runoff based on unitline runoff; and the exponentially decaying baseflow model is used to calculate baseflow based on soil moisture content (or groundwater storage) and superimpose it with surface runoff to form total runoff.
[0066] The SCS-CN runoff model is based on the Curve Number Method developed by the USDA Soil Conservation Service to calculate watershed runoff (excessive infiltration runoff). The core parameter of the model is the Curve Number (CN) value, which reflects the watershed's runoff capacity.
[0067] The Nash unit hydrograph confluence model uses Nash instantaneous unit hydrograph theory to simulate the watershed confluence process, generalizing the watershed into a system of n linear reservoirs connected in series, with each reservoir having a time delay of k hours.
[0068] The Muskingum channel evolution model is used to simulate the propagation process of floods in a river channel. Based on the water balance equation and the storage-discharge relationship, it uses two parameters (K, X) to describe the channel characteristics. K is the storage constant / propagation time, which has the dimension of time and represents the propagation time of the flood wave in the river segment. The larger the K value, the longer it takes for the flood to propagate from upstream to downstream. X is a weighting factor that reflects the importance of wedge-shaped storage relative to cylindrical storage in the river segment. The X value represents the weight of upstream and downstream flow in calculating the storage capacity of the river segment. X=0 indicates that the storage capacity is only related to the downstream flow (such as a reservoir). X=0.5 indicates that the storage capacity is related to the difference in flow between the upstream and downstream sections (showing obvious wedge-shaped storage).
[0069] The exponentially decaying baseflow model is used to simulate the continuous recharge process of groundwater into river channels. It takes into account the delayed recharge effect of rainfall on groundwater and improves the forecast accuracy for dry seasons and baseflow sections.
[0070] The physical hydrological model group constitutes a complete physical chain of "rainfall → runoff generation → confluence → river channel → baseflow". Its output results and intermediate process variables provide important features for the subsequent river flow residual correction model.
[0071] The dataset construction module is specifically used for: The historical meteorological data, historical hydrological observation data, and historical physical prediction data are preprocessed with at least the following steps: time alignment (alignment at the hourly level), missing value handling (using linear interpolation to fill in missing values, with a single missing value not exceeding 6 hours), outlier handling (using the 3σ criterion to identify outliers, combined with manual review and confirmation), data consistency check (ensuring the spatiotemporal matching of rainfall and flow data), and data standardization (X_normalized=(X-μ) / σ, where μ and σ are the mean and standard deviation, respectively, and X is the data to be standardized). A 44-dimensional historical river flow feature is then extracted from the preprocessed historical meteorological data, historical hydrological observation data, and historical physical prediction data. The historical river flow characteristics include 5-dimensional physical model intermediate process characteristics, 15-dimensional rainfall statistical characteristics, 4-dimensional rainfall pattern classification characteristics, 2-dimensional anterior impact characteristics, 6-dimensional flow lag characteristics, 6-dimensional time periodicity characteristics, 3-dimensional watershed response characteristics, and 3-dimensional model residual characteristics. A dataset is constructed based on the aforementioned historical meteorological data, historical physical prediction data, and historical river flow characteristics.
[0072] The intermediate process characteristics of the physical model include excess permeability production, unit line runoff, channel runoff, base flow, and total predicted flow.
[0073] Rainfall statistics include cumulative rainfall (reflecting the total amount of rainfall at different time points) in five time windows: 3 hours, 6 hours, 12 hours, 24 hours, and 48 hours; maximum rainfall intensity (capturing extreme rainfall events); and rainfall variation coefficient (characterizing the non-uniformity of the spatiotemporal distribution of rainfall). Through multi-scale time windows, the model can simultaneously perceive the impact of short-term heavy rainfall and the long-term cumulative effects.
[0074] The rainfall pattern classification features include light rain indicators (0-2.5 mm / h), moderate rain indicators (2.5-10 mm / h), heavy rain indicators (10-25 mm / h), and torrential rain indicators (>25 mm / h); each indicator is a binary variable (0 or 1) used to identify the watershed response characteristics under different rainfall patterns.
[0075] The early impact characteristics include the 7-day API (Antecedent Precipitation Index) and the 14-day API; the API is used to quantify soil moisture status, and the 7-day API and 14-day API reflect the impact of short-term and medium-term soil water storage status on runoff generation capacity, respectively.
[0076] The flow lag characteristics include Qt-1 (historical flow 1-hour lag value), Qt-2 (historical flow 2-hour lag value), Qt-3, Qt-6, Qt-12, and Qt-24; these lag characteristics characterize the short-term memory (1-3 hours), medium-term memory (6 hours), and long-term memory (12-24 hours) of the watershed hydrological response.
[0077] The time periodicity features include hourly periods encoded by the SIN and COS functions. Weekly cycle Annual cycle The use of trigonometric functions to encode time periodicity avoids the boundary abruptness problem of linear coding. These characteristics reflect the regularity of evapotranspiration, human activities and seasonal hydrological changes.
[0078] Watershed response characteristics include rainfall-runoff ratio (the ratio of current flow to cumulative rainfall, which assesses runoff generation efficiency), baseflow ratio (the proportion of baseflow to total flow, reflecting the contribution of groundwater), and peak flow indicator variable (indicating whether the current period is a flood peak (1 when flow > threshold)).
[0079] The model residual features include the current residual, the residual after 1 hour lag, and the residual after 2 hours lag; by learning the temporal pattern of the residuals, the model can capture the systematic bias of the physical model.
[0080] The river flow residual correction model training module is specifically used for: Based on chronological order, the dataset is divided into a training set (e.g., 2017-2021), a validation set (e.g., 2022-2023), and a test set (e.g., 2024-2025) in a ratio of 70%:15%:15% to avoid data leakage; The river flow residual correction model is trained by selecting a preset training batch from the training set. After each training batch is completed, the validation loss value of the time-aware loss function is calculated through the validation set, and the hyperparameters of the river flow residual correction model are tuned until the validation loss value does not decrease for 20 consecutive training batches to complete the training. The Nash-Sutcliffe efficiency coefficient (NSE, where a closer NSE to 1 indicates better model performance and NSE < 0 indicates that the model is inferior to the mean baseline), root mean square error (RMSE, where a smaller RMSE indicates higher prediction accuracy, with units the same as flow rate (cms or m³ / s)), and flood peak error indices (flood peak flow relative error: |(Qpeak_pred-Qpeak_obs)| / Qpeak_obs; peak occurrence time error: |Tpeak_pred-Tpeak_obs| (hours)) were calculated using the test set. The trained river flow residual correction model was then tested, and the tested river flow residual correction model was deployed. For the deployment of the river flow residual correction model, in specific implementation, the tested river flow residual correction model can be saved as a model file in .json or .pkl format and encapsulated as a RESTful API interface: the interface response time is controlled within 500ms to meet the real-time forecasting requirements.
[0081] For resource-constrained edge devices, a model compression technique is employed to compress the river flow residual correction model. This includes: feature selection: retaining the Top-30 features based on importance ranking; tree pruning: limiting the maximum tree depth and number of trees in XGBoost; and quantization acceleration: using int8 quantization to reduce computational complexity. The compressed model maintains over 95% of the original model's accuracy, while inference speed is improved by 2-5 times.
[0082] A model performance monitoring mechanism was established: real-time tracking of forecast errors (RMSE, NSE); regular (e.g., quarterly) retraining of the model using the latest data; and triggering model updates when forecast errors exceed a threshold. Incremental learning or online learning methods were used to ensure that the model always adapts to the latest hydrological characteristics of the watershed.
[0083] The real-time physics prediction data output module is specifically used for: Real-time meteorological data and real-time hydrological observation data are acquired. After preprocessing the real-time meteorological data and real-time hydrological observation data, they are input into the physical hydrological model group after the physical model parameters have been calibrated by the genetic algorithm (the objective function is to minimize the negative value of NSE) to obtain real-time physical prediction data.
[0084] The weight coefficient search module is specifically used for: The optimal weight coefficients are selected by iterating through the values of the weight coefficients of the residuals using the constrained regression optimization method (constrained regression method), the feature-based dynamic weight prediction method (feature prediction method), and the sliding window local search method (sliding search method). This involves dynamically adjusting the fusion weights of the physical hydrological model group and the river flow residual correction model based on model performance and hydrological conditions to achieve optimal forecasting results. Specifically, through an adaptive weighting strategy, the optimal fusion method can be automatically selected under different hydrological conditions, significantly improving forecast stability. The constrained regression optimization method fixes the optimal weights through global optimization; the feature-based dynamic weight prediction method predicts the optimal weights in real time based on current hydrological and meteorological conditions by constructing a weight prediction model; and the sliding window local search method adjusts the weights in real time based on model performance within a sliding time window using a local greedy search strategy.
[0085] In the channel flow forecasting module, the predicted channel flow = total predicted flow + weighting coefficient * residual value.
[0086] In summary, the advantages of this invention are as follows: 1. A river flow residual correction model was created based on the XGBoost network, with a time-aware loss function. A large amount of historical meteorological data, historical hydrological observation data, and historical physical prediction data from the physical-hydrological model group were then acquired. These historical meteorological, hydrological, and physical prediction data were preprocessed, and 44-dimensional historical river flow features were extracted. A dataset was constructed based on these historical meteorological, physical prediction, and river flow features. The river flow residual correction model was then trained using the dataset and the time-aware loss function, and the trained model was tested and deployed. Next, real-time meteorological and hydrological observation data were input into the pre-trained physical-hydrological model group to obtain real-time physical prediction data. 44-dimensional real-time river flow features were extracted from these data and input into the river flow residual correction model to obtain the residual values of the physical-hydrological model group. Finally, an adaptive weight optimization strategy was used to search for the weights of the residual values. The weighting coefficients are used to obtain the final predicted river flow, based on the total predicted flow, residual values, and weighting coefficients. Channel flow forecasting is then performed based on this predicted flow. This involves constructing a hybrid framework of "physical model as baseline, dynamic correction via machine learning" to systematically improve the accuracy and reliability of channel flow forecasting. Specifically, it doesn't simply replace or statically combine two models; instead, it first uses a hydrological model with physical mechanisms (physical-hydrological model set) to generate a basic forecast (real-time physical prediction data), and then uses a channel flow residual correction model to predict the residual values of the physical-hydrological model set. An adaptive weighting optimization strategy is introduced to dynamically adjust the intensity of residual correction based on real-time hydrological conditions. Finally, the weighted residuals are compensated to the forecast values of the physical hydrological model group to obtain the final result. This architecture not only preserves the interpretability and physical constraints of the physical hydrological model group, but also utilizes the powerful fitting ability of the data-driven model to correct the systematic biases of the physical hydrological model group under scenarios such as complex underlying surfaces and extreme rainfall. At the same time, the time-aware loss function is used to optimize the forecast accuracy of key periods such as flood peaks, which ultimately greatly improves the accuracy and reliability of river flow forecasts.
[0087] 2. By combining physical hydrological models (such as the SCS-CN runoff model and the Nash unit hydrograph model) with the XGBoost machine learning model, the physical model provides a prediction basis based on physical mechanisms, while the XGBoost model learns residuals through a data-driven approach to correct the biases of the physical model. This fusion approach not only utilizes the interpretability of the physical model but also leverages the advantages of machine learning in handling nonlinear relationships and complex patterns, making river flow forecasts more accurate and reliable. In particular, it demonstrates stronger robustness in the prediction of extreme events (such as floods), showing a significant improvement over single-model methods.
[0088] 3. During the model training phase, a time-aware loss function was introduced. This function dynamically adjusts the importance of errors at different time points through a weighting function, thereby more effectively capturing the time-dependent characteristics of river flow. This helps the model better learn dynamic processes such as flood peak evolution and baseflow decay, reducing prediction lag or lead errors and improving the time-series consistency of forecasts. Compared with traditional mean square error loss, time-aware loss is more adaptable to the non-stationarity of hydrological data, enhancing the practicality of the model in long-term forecasts.
[0089] 4. By extracting 44-dimensional river flow features from multi-source data (historical meteorological, hydrological observation, and physical prediction data), including diverse features such as intermediate processes of physical models, rainfall statistics, and time periodicity, and performing preprocessing steps such as time alignment and missing value handling, this meticulous feature engineering ensures the integrity, consistency, and representativeness of the input data. It can capture the key driving factors of watershed response, provide high-quality input for model training, thereby reducing the risk of overfitting and improving the generalization ability of forecasts.
[0090] 5. By dividing the dataset into training, validation, and test sets (70%:15%:15%) in chronological order, and employing hyperparameter tuning and early stopping strategies (such as ensuring the loss does not decrease after 20 consecutive validation batches), systematic training and evaluation of the model were achieved. During the testing phase, multiple metrics, including the Nash-Sutcliffe efficiency coefficient, were used for validation, ensuring the model's performance on unknown data. This rigorous process avoids overfitting, improves the model's stability in actual deployment, and meets the high reliability requirements of hydrological forecasting.
[0091] 6. In the real-time forecasting stage, real-time physical prediction data is generated through physical hydrological models, and residual values are output using the XGBoost model. Then, the weight coefficients are dynamically adjusted by combining adaptive weight optimization strategies (such as constrained regression and sliding window local search). This mechanism allows the system to automatically optimize the correction amount according to the characteristics of real-time data, making the final forecast (predicted river flow = total predicted flow + weight coefficient * residual value) more adaptive and accurate, especially suitable for rapid response to climate change or sudden hydrological events.
[0092] 7. By integrating the physical hydrological model group with the XGBoost model in the form of residual prediction, the physical model provides the basic prediction, while the machine learning model is responsible for learning the residual error. This well-defined structure retains the mechanistic transparency of the physical model and makes up for its shortcomings through data-driven methods. At the same time, adaptive weight optimization allows the fusion strategy to be adjusted under different hydrological conditions, which enhances flexibility and interpretability and facilitates customized adjustments according to needs in practical applications.
[0093] 8. To address the high parameter sensitivity, the XGBoost residual learning mechanism is introduced to automatically correct the systematic bias caused by parameter uncertainty in the physical hydrological model group. Even if the parameter calibration of the physical hydrological model group is not accurate enough, the river flow residual correction model can achieve intelligent compensation by learning historical error patterns, significantly reducing the model's dependence on parameter accuracy and improving model robustness. To address the poor forecasting capability for extreme events, multi-time-window rainfall statistics, rainfall pattern classification, and flow lag characteristics are constructed, and a time-aware loss function is innovatively introduced, enabling XGBoost to fully explore the nonlinear response patterns under extreme rainfall. In flood peak forecasting, compared with traditional physical models (error > 90%), the relative error is significantly controlled within 15%-45%, with the TW-MSE mechanism further reducing the error by 8%-12%, achieving a breakthrough in the accurate capture of key hydrological events. To address the lack of physical constraints, a complete physical hydrological process framework (SCS-CN runoff generation model, Nash unit hydrograph confluence model, Muskingum channel evolution model, and exponentially decaying baseflow model) is retained to ensure that the prediction results conform to water balance and hydrological physical laws. The channel flow residual correction model only learns the residual correction term, rather than directly predicting the flow, thus maintaining good interpretability and physical consistency while improving accuracy. To address the poor fusion effect of fixed weights, an adaptive weight learning ensemble strategy (constrained regression, feature prediction, and sliding search) is introduced. This strategy can dynamically adjust the fusion ratio between the physical hydrological model group and the channel flow residual correction model according to different hydrological conditions and model performance. The weight of the physical hydrological model group is increased when it performs well during the dry season, and its weight is increased when the channel flow residual correction model has higher accuracy during the flood peak season, achieving the optimal fusion effect of "complementary advantages and dynamic balance".
[0094] 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 method for predicting river flow based on a physical hydrological model and XGBoost, characterized in that: Includes the following steps: Step S1: Create a river flow residual correction model based on the XGBoost network, and set the loss function of the river flow residual correction model as the time-aware loss function; Step S2: Acquire a large amount of historical meteorological data, historical hydrological observation data, and historical physical prediction data of the physical hydrological model group; the physical hydrological model group includes the pre-trained SCS-CN runoff generation model, Nash unit hydrograph confluence model, Muskingum channel evolution model, and exponential decay baseflow model. Step S3: Preprocess the historical meteorological data, historical hydrological observation data and historical physical prediction data, and extract 44-dimensional historical river flow characteristics. Construct a dataset based on the historical meteorological data, historical physical prediction data and historical river flow characteristics. Step S4: Train the river flow residual correction model using the dataset and the time-aware loss function, and test and deploy the trained river flow residual correction model. Step S5: Obtain real-time meteorological data and real-time hydrological observation data, and input the real-time meteorological data and real-time hydrological observation data into the physical hydrological model group to obtain real-time physical prediction data; Step S6: Extract 44-dimensional real-time river flow characteristics from the real-time meteorological data, real-time hydrological observation data, and real-time physical prediction data; Step S7: Input the real-time hydrological observation data, real-time physical prediction data and real-time river flow characteristics into the deployed river flow residual correction model to obtain the residual value of the total predicted flow of the physical hydrological model group. Step S8: Search for the weight coefficients of the residual value using an adaptive weight optimization strategy; Step S9: Obtain the final predicted river flow using the total predicted flow output by the physical hydrological model group, the residual value output by the river flow residual correction model, and the weighting coefficients. Perform channel flow forecasting based on the predicted river flow.
2. The river flow forecasting method based on physical hydrological models and XGBoost as described in claim 1, characterized in that: In step S1, the formula for the time-aware loss function is: ; in, This represents the loss value of the time-aware loss function; N represents the total number of time points included in a single computation used to train the model. Represents the weighting function; Represents the true residual; This represents the predicted residual value; In step S2, the historical meteorological data includes at least rainfall, temperature, wind speed, and timestamp; The historical hydrological observation data includes at least measured flow rate, water level data, and timestamps; The historical physical prediction data includes excess permeability yield, unit runoff, channel runoff, base flow, and total predicted flow; total predicted flow = channel runoff + base flow. The SCS-CN runoff model is used to calculate excess permeability runoff; the Nash unitline runoff model is used to calculate unitline runoff based on excess permeability runoff; the Muskingum channel evolution model is used to calculate channel runoff based on unitline runoff; and the exponentially decaying baseflow model is used to calculate baseflow based on soil moisture content and superimpose it with surface runoff to form total runoff.
3. The river flow forecasting method based on physical hydrological models and XGBoost as described in claim 1, characterized in that: Step S3 specifically involves: The historical meteorological data, historical hydrological observation data, and historical physical prediction data are preprocessed, including time alignment, missing value handling, outlier handling, data consistency check, and data standardization. 44-dimensional historical river flow characteristics are then extracted from the preprocessed historical meteorological data, historical hydrological observation data, and historical physical prediction data. The historical river flow characteristics include 5-dimensional physical model intermediate process characteristics, 15-dimensional rainfall statistical characteristics, 4-dimensional rainfall pattern classification characteristics, 2-dimensional anterior impact characteristics, 6-dimensional flow lag characteristics, 6-dimensional time periodicity characteristics, 3-dimensional watershed response characteristics, and 3-dimensional model residual characteristics. A dataset is constructed based on the aforementioned historical meteorological data, historical physical prediction data, and historical river flow characteristics.
4. The river flow forecasting method based on physical hydrological models and XGBoost as described in claim 1, characterized in that: Step S4 specifically involves: Based on the chronological order, the dataset is divided into a training set, a validation set, and a test set in a ratio of 70%:15%:15%. The river flow residual correction model is trained by selecting a preset training batch from the training set. After each training batch is completed, the validation loss value of the time-aware loss function is calculated through the validation set, and the hyperparameters of the river flow residual correction model are tuned until the validation loss value does not decrease for 20 consecutive training batches to complete the training. The Nash-Sutcliffe efficiency coefficient, root mean square error, and flood peak error index are calculated using the test set to test the trained river flow residual correction model. The river flow residual correction model that passes the test is then deployed. Step S5 specifically involves: Real-time meteorological data and real-time hydrological observation data are acquired. After preprocessing the real-time meteorological data and real-time hydrological observation data, they are input into a physical hydrological model group after the physical model parameters have been calibrated by a genetic algorithm to obtain real-time physical prediction data.
5. The river flow forecasting method based on physical hydrological models and XGBoost as described in claim 1, characterized in that: Step S8 specifically involves: The optimal weight coefficient is selected by iterating through the weight coefficient values of the residual values using the constrained regression optimization method, the feature-based dynamic weight prediction method, and the sliding window local search method, respectively. In step S9, the predicted river flow = total predicted flow + weighting coefficient * residual value.
6. A river flow forecasting system based on a physical hydrological model and XGBoost, characterized in that: Includes the following modules: The river flow residual correction model creation module is used to create a river flow residual correction model based on the XGBoost network, and the loss function of the river flow residual correction model is set as the time-aware loss function. The historical data acquisition module is used to acquire a large amount of historical meteorological data, historical hydrological observation data, and historical physical prediction data of the physical hydrological model group; the physical hydrological model group includes the pre-trained SCS-CN runoff generation model, the Nash unit hydrograph confluence model, the Muskingum channel evolution model, and the exponential decay baseflow model. The dataset construction module is used to preprocess the historical meteorological data, historical hydrological observation data and historical physical prediction data, extract 44-dimensional historical river flow characteristics, and construct a dataset based on the historical meteorological data, historical physical prediction data and historical river flow characteristics. The river flow residual correction model training module is used to train the river flow residual correction model using the dataset and the time-aware loss function, and to test and deploy the trained river flow residual correction model. The real-time physical prediction data output module is used to acquire real-time meteorological data and real-time hydrological observation data, and input the real-time meteorological data and real-time hydrological observation data into the physical hydrological model group to obtain real-time physical prediction data. The real-time river flow feature extraction module is used to extract 44-dimensional real-time river flow features from the real-time meteorological data, real-time hydrological observation data, and real-time physical prediction data. The residual value output module is used to input the real-time hydrological observation data, real-time physical prediction data and real-time river flow characteristics into the deployed river flow residual correction model to obtain the residual value of the total predicted flow of the physical hydrological model group. The weight coefficient search module is used to search for the weight coefficients of the residual value through an adaptive weight optimization strategy. The channel flow forecasting module is used to obtain the final predicted river flow through the total predicted flow output by the physical hydrological model group, the residual value output by the channel flow residual correction model, and the weighting coefficient, and to perform channel flow forecasting based on the predicted river flow.
7. A river flow forecasting system based on a physical hydrological model and XGBoost as described in claim 6, characterized in that: In the river flow residual correction model creation module, the formula for the time-aware loss function is: ; in, This represents the loss value of the time-aware loss function; N represents the total number of time points included in a single computation used to train the model. Represents the weighting function; Represents the true residual; This represents the predicted residual value; In the historical data acquisition module, the historical meteorological data includes at least rainfall, temperature, wind speed, and timestamp; The historical hydrological observation data includes at least measured flow rate, water level data, and timestamps; The historical physical prediction data includes excess infiltration yield, unit line runoff, channel runoff, base flow, and total predicted flow; total predicted flow = channel runoff + base flow; the SCS-CN runoff model is used to calculate excess infiltration yield; the Nash unit line runoff model is used to calculate unit line runoff based on excess infiltration yield; the Muskingum channel evolution model is used to calculate channel runoff based on unit line runoff; the exponentially decaying baseflow model is used to calculate base flow based on soil moisture content, and is superimposed with surface runoff to form total runoff.
8. The river flow forecasting system based on a physical hydrological model and XGBoost as described in claim 6, characterized in that: The dataset construction module is specifically used for: The historical meteorological data, historical hydrological observation data, and historical physical prediction data are preprocessed, including time alignment, missing value handling, outlier handling, data consistency check, and data standardization. 44-dimensional historical river flow characteristics are then extracted from the preprocessed historical meteorological data, historical hydrological observation data, and historical physical prediction data. The historical river flow characteristics include 5-dimensional physical model intermediate process characteristics, 15-dimensional rainfall statistical characteristics, 4-dimensional rainfall pattern classification characteristics, 2-dimensional anterior impact characteristics, 6-dimensional flow lag characteristics, 6-dimensional time periodicity characteristics, 3-dimensional watershed response characteristics, and 3-dimensional model residual characteristics. A dataset is constructed based on the aforementioned historical meteorological data, historical physical prediction data, and historical river flow characteristics.
9. A river flow forecasting system based on a physical hydrological model and XGBoost as described in claim 6, characterized in that: The river flow residual correction model training module is specifically used for: Based on the chronological order, the dataset is divided into a training set, a validation set, and a test set in a ratio of 70%:15%:15%. The river flow residual correction model is trained by selecting a preset training batch from the training set. After each training batch is completed, the validation loss value of the time-aware loss function is calculated through the validation set, and the hyperparameters of the river flow residual correction model are tuned until the validation loss value does not decrease for 20 consecutive training batches to complete the training. The Nash-Sutcliffe efficiency coefficient, root mean square error, and flood peak error index are calculated using the test set to test the trained river flow residual correction model. The river flow residual correction model that passes the test is then deployed. The real-time physics prediction data output module is specifically used for: Real-time meteorological data and real-time hydrological observation data are acquired. After preprocessing the real-time meteorological data and real-time hydrological observation data, they are input into a physical hydrological model group after the physical model parameters have been calibrated by a genetic algorithm to obtain real-time physical prediction data.
10. A river flow forecasting system based on a physical hydrological model and XGBoost as described in claim 6, characterized in that: The weight coefficient search module is specifically used for: The optimal weight coefficient is selected by iterating through the weight coefficient values of the residual values using the constrained regression optimization method, the feature-based dynamic weight prediction method, and the sliding window local search method, respectively. In the channel flow forecasting module, the predicted channel flow = total predicted flow + weighting coefficient * residual value.