Hydrological flow long sequence prediction method and system of improved state space model
By using the improved state-space model HydroMamba, combined with multi-source data processing and an autoregressive mechanism, the problems of high computational complexity and low prediction accuracy in hydrological flow forecasting are solved, achieving efficient and accurate long-sequence hydrological flow forecasting.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHEJIANG YUANSUAN TECH CO LTD
- Filing Date
- 2026-04-03
- Publication Date
- 2026-05-05
AI Technical Summary
Existing hydrological flow prediction methods suffer from high computational complexity, difficulty in parameter calibration, weak adaptability to extreme hydrological scenarios, and long-term memory forgetting issues. Furthermore, data-driven models show a significant decrease in prediction accuracy and stability when predicting long-term data.
An improved state-space model, HydroMamba, is adopted. Time-series sample pairs are constructed through multi-source data processing and sliding window method, and trained in combination with the HydroMamba model. Traffic prediction is achieved by using an autoregressive mechanism. It includes an input embedding layer, a Mamba stacked encoding layer and an output mapping layer. The autoregressive mechanism and an anti-overfit objective function are used to improve the model's prediction performance on unseen data.
It achieves efficient long-sequence hydrological data modeling, balances computational efficiency and prediction accuracy, significantly improves prediction performance on unseen data, is highly adaptable, and is suitable for engineering applications.
Smart Images

Figure CN121980968A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of interdisciplinary technology of hydrological and meteorological forecasting and artificial intelligence, and in particular to a method and system for long-sequence hydrological flow forecasting using an improved state-space model. Background Technology
[0002] Runoff forecasting is of great significance in scenarios such as flood control and drought relief scheduling and optimal allocation of water resources. Current mainstream hydrological flow forecasting methods can be divided into two main categories: physical process-driven models and data-driven models, but both types of methods have significant technical bottlenecks.
[0003] Physical process-driven models rely on high-precision hydrogeographic parameters (such as topographic slope and soil permeability) to construct physical extrapolation relationships, which have problems such as high computational complexity, difficulty in calibrating key parameters, and weak adaptability to extreme hydrological scenarios.
[0004] While data-driven models based on deep learning reduce the dependence on physical parameters, different architectures still have limitations: RNN / LSTM series models have basic time series modeling capabilities, but their parallel computing efficiency is low and they suffer from long sequence memory forgetting problems. When processing hydrological data with a long historical window of more than 60 days, the prediction accuracy and stability drop significantly. Another mainstream model solves the parallel computing problem through the self-attention mechanism, but the computational complexity of this mechanism increases quadratically with the sequence length, significantly increasing memory usage and computation time. Moreover, its global correlation modeling method does not capture the continuous fluid dynamics characteristics in the hydrological process naturally enough. Summary of the Invention
[0005] In view of this, the purpose of this invention is to provide an improved method and system for long-sequence hydrological flow prediction using a state-space model. This method is computationally efficient, utilizes the discretization of the continuous state equations of the state-space model to capture long-distance meteorological-hydrological lag effects that are difficult to capture by traditional cyclic models, and significantly improves the model's predictive performance on unseen data by processing the skewed distribution of hydrological data through logarithmic transformation and combining it with an anti-overfit objective function. It also has high practical application value.
[0006] In a first aspect, embodiments of the present invention provide an improved method for predicting long-sequence hydrological discharge using a state-space model, the method comprising: Collect multi-source data for the watershed to be predicted, including daily-scale meteorological driving factors, hydrological monitoring data, and temporal characteristic data; The multi-source data is subjected to data cleaning, nonlinear distribution correction, time feature encoding, and data normalization to obtain the processed multi-source data. The processed multi-source data is used to construct time series sample pairs using the sliding window method. The time series sample pairs include an input sequence and a target sequence. A HydroMamba model is constructed based on the time-series samples, and the HydroMamba model is trained and the optimal hyperparameter combination is searched. Based on the trained HydroMamba model, an autoregressive mechanism is used to achieve traffic prediction and result reconstruction.
[0007] Furthermore, the processed multi-source data is used to construct time-series sample pairs using the sliding window method. Each time-series sample pair includes an input sequence and a target sequence, comprising: Define core parameters, which include historical sequence length, future prediction length, and sliding step size; Based on the t-th sample in the time series, determine the input window and the target window; where t is greater than or equal to the sum of the historical sequence length and the future prediction length; Determine the total time series length; The total number of samples constructed is calculated based on the total time series length, the historical series length, and the future prediction length. The total number of constructed samples is divided according to a preset ratio to obtain a training set, a validation set, and a test set; The input sequence is determined based on the input window, and the target sequence is determined based on the target window; Determine the input feature vector and target vector at each time step; Wherein, the end time of the input sequence is t-1, and the start time of the target sequence is t.
[0008] Furthermore, the HydroMamba model includes an input embedding layer, a Mamba stacked coding layer, and an output mapping layer. Constructing the HydroMamba model based on the time-series sample pairs includes: In the input embedding layer, the standardized input feature vector, linear projection matrix, and embedding layer bias term at time τ are defined. Based on the standardized input feature vector at time τ, the linear projection matrix, and the embedding layer bias term, calculate the high-dimensional feature vector and the embedded input sequence at time τ, respectively. The Mamba stacked coding layer comprises k MambaBlocks connected in series. The input of the kth MambaBlock is the output of the previous layer, and the initial input is the embedded input sequence. Normalization, state space modeling, and residual connection processing are performed on each MambaBlock to obtain the output features of the MambaBlock. In the output mapping layer, the encoded high-dimensional features are converted into traffic prediction values, and a prediction sequence is output based on the traffic prediction values.
[0009] Furthermore, normalization, state-space modeling, and residual connection processing are performed on a single MambaBlock to obtain the output features of the MambaBlock, including: Normalize each MambaBlock to obtain a normalized feature vector; The normalized feature vectors are projected to obtain the projected parameter matrix. The projected parameter matrix is used to dynamically update the state vector through a structured state-space model; The state vector is transformed into the output features of the Mamba module; The output features of the Mamba module are added to the original input features of the MambaBlock to obtain the output features of the MambaBlock.
[0010] Furthermore, in the output mapping layer, the encoded high-dimensional features are converted into traffic prediction values, including: The encoded features are processed by RMSNorm to obtain normalized encoded features. The normalized encoded features are regularized using the Dropout mechanism to obtain regularized encoded features. The regularized encoded features are mapped to the traffic prediction values.
[0011] Furthermore, the HydroMamba model is trained, and the optimal combination of hyperparameters is searched, including: Retrieve historical input windows and guidance sequences; Construct a combined input matrix based on the historical input window and the guiding sequence; Obtain the lower triangular causal convolution mask during the selective scanning process of the Mamba module; Calculate the basic loss and overfitting penalty term; Construct a composite loss function based on the base loss and the overfitting penalty term; Minimize the composite loss function using the Adam optimizer; The optimal combination of hyperparameters is searched using a Bayesian optimization framework.
[0012] Furthermore, based on the trained HydroMamba model, an autoregressive mechanism is employed to achieve traffic prediction and result reconstruction, including: Use the data from the N days prior to the time t to be predicted as the initial input; Determine the target time for the k-th prediction; The initial input is concatenated with the meteorological factors of the current prediction step and the historical prediction values to obtain the updated feature vector; The updated feature vector is input into the trained HydroMamba model to obtain the standardized prediction value at the current time. Update the traffic forecast value from the previous moment to the standardized forecast value for the current moment; After repeating the cycle M times, a standardized prediction sequence for the next M days is obtained. The standardized prediction value at the current moment is destandardized to obtain the transformed flow rate; The transformed flow rate is then subjected to an inverse Log1p transformation to obtain the true-scale flow rate prediction value. Calculate the mean absolute error based on the predicted actual scale flow rate; When the Nash efficiency coefficient is greater than or equal to the first preset threshold and the mean absolute error is less than or equal to the second preset threshold, the prediction result meets the requirements of engineering applications.
[0013] Furthermore, the multi-source data undergoes data cleaning, nonlinear distribution correction, time feature encoding, and data normalization to obtain processed multi-source data, including: The multi-source data is subjected to data integrity verification, missing data completion, and outlier processing. The original measured flow rate is converted into the transformed flow rate; The accumulated days of the year are converted into periodic numerical features using sine-cosine encoding; The original feature data is normalized to obtain standardized feature data.
[0014] Secondly, embodiments of the present invention provide an improved state-space model-based long-sequence hydrological flow prediction system, the system comprising: The data acquisition module is used to collect multi-source data of the watershed to be predicted. The multi-source data includes daily meteorological driving factors, hydrological monitoring data and temporal characteristic data. The processing module is used to perform data cleaning, nonlinear distribution correction, time feature encoding, and data normalization on the multi-source data to obtain the processed multi-source data. A time-series sample pair construction module is used to construct time-series sample pairs from the processed multi-source data using a sliding window method. The time-series sample pairs include an input sequence and a target sequence. The model building and training module is used to build a HydroMamba model based on the time series samples, train the HydroMamba model, and search for the optimal combination of hyperparameters. The prediction module is used to predict traffic and restore results based on the trained HydroMamba model using an autoregressive mechanism.
[0015] Thirdly, embodiments of the present invention provide an electronic device, including a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the processor executes the computer program to implement the method described above.
[0016] This invention provides an improved state-space model for long-sequence hydrological flow prediction, comprising: collecting multi-source data of the watershed to be predicted, including daily-scale meteorological driving factors, hydrological monitoring data, and temporal feature data; performing data cleaning, nonlinear distribution correction, temporal feature encoding, and data normalization on the multi-source data to obtain processed multi-source data; constructing time-series sample pairs using the sliding window method, each time-series sample pair including an input sequence and a target sequence; constructing a HydroMamba model based on the time-series sample pairs, training the HydroMamba prediction model, and searching for the optimal hyperparameter combination; using an autoregressive mechanism to achieve flow prediction and result restoration based on the trained HydroMamba model; achieving high computational efficiency by discretizing the continuous state equation of the state-space model, which can capture long-distance meteorological-hydrological lag effects that are difficult to capture by traditional cyclic models; and significantly improving the model's predictive performance on unseen data by processing the skewed distribution of hydrological data through logarithmic transformation and combining it with an anti-overfitting objective function, thus demonstrating high practical application value.
[0017] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained in accordance with the structures particularly pointed out in the description, claims and drawings.
[0018] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0019] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0020] Figure 1 Flowchart of the improved state-space model for long-sequence hydrological flow prediction provided in Embodiment 1 of the present invention; Figure 2 A schematic diagram illustrating the overall implementation process of the improved state-space model-based long-sequence hydrological flow prediction method provided in Embodiment 1 of the present invention. Figure 3 This is a schematic diagram of the overall architecture of the HydroMamba model provided in Embodiment 1 of the present invention; Figure 4 This is a simulation diagram of runoff prediction based on the HydroMamba model provided in Embodiment 1 of the present invention; Figure 5 This is a schematic diagram of a long-sequence hydrological flow prediction system based on an improved state-space model provided in Embodiment 2 of the present invention. Detailed Implementation
[0021] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0022] To facilitate understanding of this embodiment, the embodiments of the present invention will be described in detail below.
[0023] Example 1: Figure 1 The flowchart illustrates the long-sequence hydrological flow prediction method using an improved state-space model provided in Embodiment 1 of the present invention.
[0024] Reference Figure 1 The method includes the following steps: Step S101: Collect multi-source data of the watershed to be predicted. The multi-source data includes daily meteorological driving factors, hydrological monitoring data and temporal characteristic data. Step S102 involves performing data cleaning, nonlinear distribution correction, time feature encoding, and data normalization on the multi-source data to obtain the processed multi-source data. Here, multi-source data fusion and standardized preprocessing are used to eliminate data noise and dimensional differences, providing high-quality input for the model.
[0025] Step S103: The processed multi-source data is used to construct time series sample pairs using the sliding window method. The time series sample pairs include the input sequence and the target sequence. Here, a sliding window method is used to construct "input-target" time series sample pairs to match historical information with future prediction targets, providing supervised learning data for the model.
[0026] Step S104: Construct the HydroMamba model based on the time series sample pairs; Specifically, the HydroMamba model adopts a three-level architecture of "input embedding-feature encoding-output mapping". Its core innovation lies in introducing an improved Mamba module as the feature encoding backbone to achieve long sequence modeling with linear complexity.
[0027] Step S105: Train the HydroMamba model and search for the optimal combination of hyperparameters; Step S106: Based on the trained HydroMamba model, an autoregressive mechanism is used to achieve traffic prediction and result restoration.
[0028] This application addresses the problem of how to achieve high-precision modeling of long-sequence hydrological data while ensuring linear computational complexity and improving efficiency, thus balancing the core contradiction between the long-dependency capture capability and computational efficiency of traditional models.
[0029] Furthermore, refer to Figure 2 S1: Multi-source data fusion and standardized preprocessing. Input of raw multi-source data (SWE, PRCP, flow rate, date); then perform integrity verification to determine if the missing data rate is less than or equal to 5%; S1.1 Data cleaning, linear interpolation completion, and negative value pruning; S1.2 Nonlinear correction and Log1p transformation (flow rate); S1.3 Time feature encoding and Sin / Cos periodic transformation; S1.4 Data normalization and StandardScaler; standardization of the feature matrix.
[0030] S2: Sliding window sample pair construction. Parameter definition: L_hist=60 days, L_pred=7 days, Step=1 day; Sliding window split: Source:[N,60,5], Target:[N,7,1]; Dataset partition: training / validation / test (7:1.5:1.5); Finally, the training set / validation set / test set are constructed.
[0031] S3: HydroMamba Model Construction and Training: Optuna Hyperparameter Optimization (Layers, d_model, Dropout); Model Architecture (RMSNorm+SSM+Res); Hybrid training strategy (historical sequence + guide sequence), causal mask control; Composite loss function calculation: Loss = MSE + • Penalty (NSE); backpropagation and parameter update (Adam optimizer); finally, the optimal model parameters are obtained (Best Model).
[0032] S4: Autoregressive Prediction and Result Restoration: Initial Input Construction (Test Data for the first N days); Autoregressive Rolling Prediction including Predicting the Current Step and Updating the Input Sequence; Destandardization; Inverse Log1p Transformation Performance evaluation (MSE, MAE, NSE); final prediction results ( ).
[0033] Step S102 includes the following steps: Step S201: Perform data integrity verification, missing data completion, and outlier handling on the multi-source data; Specifically, data cleaning involves collecting multi-source data from the watershed to be predicted, with core data including daily-scale meteorological driving factors (snow water equivalent). Unit: mm; Precipitation (Unit: mm) Hydrological monitoring data (measured flow rate) (Unit: m³ / s) and time characteristic data (year-to-day) The data processing flow and specific methods are as follows: 1) Data integrity verification: The following formula is used to detect the missing data rate. When the missing data rate exceeds 5%, the reliability of the data source needs to be reassessed:
[0034] 2) Missing data completion: For data with a missing rate ≤ 5%, linear interpolation is used for completion. For the first missing data in the time series... missing values The calculation formula is:
[0035] in, , They are respectively Using the two most recent valid data points before and after a given time point, this method can preserve the linear trend of the data.
[0036] 3) Outlier handling: a) Negative value handling: For , For negative values appearing in the data, the lower limit clipping method is used directly, and the formula is:
[0037]
[0038] b) Anomaly detection: Outliers are identified using the 3σ criterion. First, the mean of the feature data is calculated. and standard deviation Data is considered outlier when it meets the following conditions, and the outlier correction formula is as follows:
[0039] The outlier correction formula is:
[0040] in, , , For the valid data before and after outliers, using a 3-point mean correction can reduce the impact of extreme values on the sequence.
[0041] Step S202: Convert the original measured flow rate into the transformed flow rate; Specifically, nonlinear distribution correction: hydrological flow The data generally exhibits a right-skewed long-tailed distribution (i.e., many small-volume samples and few large-volume samples). Directly inputting this data into the model will cause the training gradient to be biased towards small-volume samples. This step uses the Log1p transformation (an improved form of the logarithmic transformation) to convert it into an approximately normal distribution, as follows: Transformation formula:
[0042] in, Original measured flow rate (unit: (Value range ≥ 0) The transformed flow rate (unitless).
[0043] The purpose of introducing the constant 1 is to avoid When = 0, meaningless calculation of log(0) occurs. When =0, =0; when When = 1000 m³ / s, ≈6.91, achieving compression of large flow values.
[0044] Step S203: Convert the accumulated days of the year into periodic numerical features using sine-cosine encoding; Specifically, time-related coding: Hydrological flow is significantly affected by seasonality (such as the summer flood season and the winter dry season), so the accumulated days of the year are used directly. (Values ranging from 1 to 366) can make it difficult for the model to identify periodic patterns. This step uses sine-cosine encoding to... It is transformed into a periodic numerical feature, as follows: 1) Encoding principle: Utilizing the periodicity (period of 2π) of the sine and cosine functions, the encoding... Mapping to the [0, 2π) interval ensures consistent coding values for the same date each year, highlighting seasonal cycles.
[0045] 2) Specific formula:
[0046]
[0047] Variable definition: Yearly accumulated days (1≤ ≤366), 365.25 is the average number of days in a year considering leap years; , The encoded features all have values in the range [-1, 1]. Together, they constitute a two-dimensional periodic feature, which can uniquely determine... Corresponding date position (e.g.) When =1, ≈0.017, ≈1; When =183, ≈1, ≈0.017).
[0048] 3) Feature function: This encoding enables the model to directly learn seasonal information such as "January 1st is close to December 31st" and "June 1st and July 1st are both in the flood season", which improves the model's ability to capture cyclical patterns.
[0049] Finally, the model input factors are integrated into , , , and Together, they form a multidimensional feature matrix for subsequent modeling.
[0050] Step S204: Normalize the original feature data to obtain standardized feature data.
[0051] Specifically, data normalization: the dimensions of different input factors differ greatly (e.g., The unit is mm. The absence of units (which can lead to large bias vectors in gradient updates during model training) is addressed in this step using the StandardScaler normalization method to eliminate the influence of units, as follows: 1) Normalization formula:
[0052] Variable definition: For the original feature data (including , , , , ), The mean of the features in the training set. The standard deviation of the training set features. These are the standardized features (mean is 0, standard deviation is 1).
[0053] 2) Calculation of statistics:
[0054]
[0055] in, The number of samples in the training set is used. -1 is used to calculate the standard deviation in order to achieve unbiased estimation.
[0056] 3) Key constraints: All normalized parameters ( , All calculations are based solely on the training set. These parameters must be reused directly for the validation and test sets. The formula is as follows:
[0057]
[0058] The above process can avoid the leakage of test set information and ensure the objectivity of model evaluation.
[0059] Furthermore, step S103 includes the following steps: Step S301: Define the core parameters, which include the historical sequence length, the future prediction length, and the sliding step size; Specifically, the core parameters are defined as follows: a) Length of historical sequence The value range is 7, 15, or 30 days, determined based on the watershed hydrological response time (small watersheds have rapid runoff, so the range is 30 days). =7; large river basins have slow confluence, so take... =30); b) Future forecast length Values range from 3, 7, and 15 days, matching the lead time of numerical weather forecasts (e.g., short-term forecasts). =3, medium-term forecast takes =15); c) Sliding step size The time frame is fixed at 1 day, meaning that adjacent sample windows differ by only 1 day in the time dimension, maximizing the utilization of data information.
[0060] Step S302: Based on the t-th sample in the time series, determine the input window and the target window; where t is greater than or equal to the sum of the historical sequence length and the future prediction length; Specifically, the formula for constructing the sample window is: For the time series, the first One sample ( ≥ + ), its input window and target window They are respectively:
[0061]
[0062] in, for Input feature vector at time step (dimension) ,Include , , , , ). for The target vector at time (dimension) ,Include , , ).
[0063] Step S303: Determine the total time series length; Step S304: Calculate the total number of samples constructed based on the total time series length, historical series length, and future prediction length; Specifically, the sample dimension is calculated as follows: The dimension of a single input sample is The dimension of a single target sample is If the total time series length is Then the total number of samples that can be constructed is:
[0064] For example, =365 days =7、 When =3, =365-7-3+1=356 samples.
[0065] Step S305: Divide the total number of constructed samples according to a preset ratio to obtain a training set, a validation set, and a test set; Specifically, the dataset is divided as follows: by The dataset is divided into training, validation, and test sets, using the following formula:
[0066]
[0067]
[0068] When dividing the data, maintain the continuity of the time series and avoid disrupting the temporal relationships.
[0069] Step S306: Determine the input sequence based on the input window, and determine the target sequence based on the target window; Step S307: Determine the input feature vector and target vector for each time step; The input sequence ends at time t-1, and the target sequence begins at time t.
[0070] Specifically, each time series sample pair consists of two parts: an input sequence (Source) and a target sequence (Target). Input sequence (Source): consisting of "history" Core meteorological factors + history Time characteristics + history The data consists of "daily traffic data" and is the basic input to the model, specifically defined as:
[0071] The input feature vector at each time step is defined as follows:
[0072] : Momentary snow water equivalent, standardized value range ; : Rainfall at any time, range of values after standardization ; : The time-time sine code has a value range of [-1, 1]. : The time cosine encoding is used, with values ranging from [-1, 1]. : Flow rate after time change, and its range after standardization .
[0073] Target sequence: consisting of "future" Core meteorological factors + future The "Daily Traffic Data" consists of labels for supervised learning of the model, specifically defined as:
[0074] The target vector at each time step is defined as follows:
[0075] , ( ):future Snow water equivalent and precipitation for a given day can be obtained in advance using ECMWF or GFS numerical weather prediction models, and the standardized values can be taken within a certain range. ; ( ):future The measured flow rate after the day-to-day transformation is the core prediction target of the model, and its standardized value range is... .
[0076] The temporal connection between the target sequence and the input sequence is as follows: the input sequence ends at time t-1, and the target sequence begins at time t, ensuring continuity in the time dimension. This partitioning method strictly adheres to the continuity of time series, avoiding data leakage issues.
[0077] Furthermore, refer to Figure 3 The HydroMamba model consists of an input layer, a Mamba stacked encoding layer, and an output mapping layer. In the input layer, the input sequence is Source[Batch,L,D_in], followed by a linear embedding layer. In the Mamba encoder (stacked N layers), RMSnorm, the internal structure of the Mamba Block, and the input projection (Linear Proj) are discussed. ; In the SSM branch, causal convolution (Conv1d), SiLU activation, SSM core, discretization ( (A, B, C), Selective Scan, [Causal Mask Control]. In the gated branch, SiLU is activated. The final output projection (LinearProj)... .
[0078] In the output mapping layer, there are RMSNorm, Dropout (regularization), and Linear projection. Prediction results [Batch,L,1].
[0079] Step S104 includes the following steps: Step S401: In the input embedding layer, define the standardized input feature vector, linear projection matrix, and embedding layer bias term at time τ. Step S402: Based on the standardized input feature vector, linear projection matrix, and embedding layer bias term at time τ, calculate the high-dimensional feature vector and the embedded input sequence at time τ, respectively. Specifically, the overall mathematical expression of the model is as follows:
[0080] Where {Source} is the input sequence , For the predicted future Flow after weather change , These are the learnable parameters of the model (including the embedding layer matrix, Mamba module parameters, etc.).
[0081] Input embedding layer: Maps low-dimensional input features to a high-dimensional latent space, enhancing feature representation and providing rich information for subsequent encoding. Specific formulas and parameter definitions: a) Mapping formula:
[0082]
[0083] b) Definition of variables and parameters: : The standardized input feature vector at time τ, dimension ; Linear projection matrix, dimension , The dimension of the latent space (values can be 32, 64, or 128, depending on the data size); Embedding layer bias term, dimension The initial value is set to 0; : The high-dimensional feature vector after embedding at time τ, dimension ; : The embedded input sequence, dimension .
[0084] c) Calculation example: when hour, The matrix is 64×5. Matrix multiplication is used to expand the 5-dimensional features to 64 dimensions, improving the model's ability to capture complex features.
[0085] Step S403: The Mamba stacked coding layer consists of k MambaBlocks connected in series. The input of the kth MambaBlock is the output of the previous layer, and the initial input is the embedded input sequence. Normalization, state space modeling, and residual connection processing are performed on a single MambaBlock to obtain the output features of the MambaBlock. In step S404, the encoded high-dimensional features are converted into traffic prediction values in the output mapping layer, and a prediction sequence is output based on the traffic prediction values.
[0086] Furthermore, step S403 includes the following steps: Step S501: Normalize a single MambaBlock to obtain the normalized feature vector; Step S502: Project the normalized feature vectors to obtain the projected parameter matrix; Step S503: The projected parameter matrix is dynamically updated using a structured state space model to update the state vector. Step S504: Transform the state vector into the output features of the Mamba module; Step S505: Add the output features of the Mamba module to the original input features of the MambaBlock to obtain the output features of the MambaBlock.
[0087] Specifically, the Mamba stacked encoding layer: the core feature extraction module of the model, is composed of... A series of MambaBlocks are connected together ( 4 or 6 layers (more layers mean stronger modeling capabilities but higher computational costs), the first The input to each MambaBlock is the output of the previous layer, and the initial input is the embedded input sequence. The input-output relationship is as follows:
[0088] in, (The input for layer 0 is the embedded input sequence). For the first The output of each MambaBlock For the final encoded feature sequence (dimension) A single MambaBlock contains three sub-modules: "Normalization - State-space Modeling - Residual Connection," as detailed below: A single MambaBlock contains three sub-modules: "Normalization - State-space Modeling - Residual Connection", as detailed below: a) Normalization operation: RMSNorm (Root Mean Square Normalization) is used instead of the traditional BatchNorm to avoid the influence of batch size on the normalization effect. The formula is:
[0089] The input feature vector of MambaBlock (at time τ), dimension ; : The One component; : To prevent small constants with denominators of zero from having fixed values ; Normalized feature vectors, dimension Its root mean square of each component is 1, which can stabilize the gradient propagation of deep networks.
[0090] Compared to BatchNorm, RMSNorm relies only on the internal features of a single sample to calculate statistics, making it more suitable for online inference scenarios involving time-series data.
[0091] b) Selective State-Space Modeling: The core of the improved Mamba module, it achieves selective focusing on key hydrological information (such as SWE abrupt changes and PRCP peaks) by dynamically adjusting state transition parameters, while maintaining... The computational complexity is linear. Specifically, it includes three steps: "input projection - state update - output projection". 1) Input projection: Projecting the normalized feature vectors The projection is the input form of the state space, and the formula is:
[0092]
[0093]
[0094]
[0095] in, , , , The projection matrix (all dimensions are 1) ), , , , For projection bias (all dimensions are) ), The dimension of the state space (with values of...) 1 / 2, such as hour ), , , , The projected parameter matrix (all dimensions are 1) ).
[0096] 2) State Update: Based on the discretization formula of the Structured State-Space Model (SSM), the state vector is dynamically updated. The formula is as follows:
[0097] in, Let τ be the state vector (dimension). ), (The initial state is the zero vector). Indicates will Transform into a diagonal matrix (dimension) This formula embodies a selectivity mechanism: when When a component is close to 1, retain historical state information; when... When the input approaches zero, forget historical information and focus on the current input.
[0098] 3) Output projection: Transform the state vector into the feature space output, the formula is:
[0099] in, The output features (dimensions) of the Mamba module Extended to via residual join .
[0100] pass By dynamically adjusting state retention weights, the model can selectively focus on key hydrological information (such as SWE mutations during snowmelt), achieving global context modeling while controlling computational complexity. .
[0101] c) Residual Connections: To address the gradient decay problem in deep networks, the output features of the Mamba module are element-wise added to the input of the Block, using the following formula:
[0102] : Residual projection matrix, dimension , used to Dimensions from Expand to ,and Dimension matching; The original input features of MambaBlock (time τ), dimension ; : Output features of MambaBlock (time τ), dimension .
[0103] The role of residual connections is to ensure that when the parameters of deep networks are updated in a small amount, the original input features can be directly passed to subsequent layers, thus ensuring effective gradient propagation.
[0104] This residual connection mechanism ensures that gradients are effectively propagated to shallow networks, avoiding gradient decay issues during deep model training.
[0105] Furthermore, step S404 includes the following steps: Step S601: Perform RMSNorm processing on the encoded features to obtain normalized encoded features; Step S602: The normalized coding features are regularized using the Dropout mechanism to obtain the regularized coding features. Step S603: Map the regularized encoding features to traffic prediction values.
[0106] Specifically, the output mapping layer transforms the encoded high-dimensional features into traffic prediction values, comprising three steps: normalization, regularization, and linear projection. This ensures prediction accuracy and suppresses overfitting. The specific formula is as follows: 1) Normalization: Apply RMSNorm processing to the encoded feature X_enc, using the following formula:
[0107] in, For the first The output features of each MambaBlock (at time τ), dimension .
[0108] 2) Regularization: The Dropout mechanism is used to randomly discard some features to suppress model overfitting. The formula is:
[0109] in, For a random mask vector (dimension) The probability that each element is 1 is The probability that it is 0 is ( This is the Dropout probability (values 0.1, 0.2, or 0.3), enabled during training and disabled during inference.
[0110] 3) Linear projection: Maps the processed features to predicted flow rates, using the following formula:
[0111] in, To output the projection matrix (dimensions) ), For output bias (dimension) ), The transformed flow predicted at time τ (after standardization, dimension) ).
[0112] The final predicted sequence output is:
[0113] Dimensions It matches the dimension of OBS_RUN_LOG in the target sequence.
[0114] The overall computational logic of the output mapping layer can be simplified as follows:
[0115] Wherein, Dropout probability A value of 0.1-0.3 can effectively suppress overfitting.
[0116] Furthermore, step S105 includes the following steps: Step S701: Obtain the historical input window and the guidance sequence; Step S702: Construct a combined input matrix based on the historical input window and the guiding sequence; Step S703: Obtain the lower triangular causal convolution mask during the selective scanning process of the Mamba module; Step S704: Calculate the basic loss and overfitting penalty term; Step S705: Construct a composite loss function based on the basic loss and the overfitting penalty term; Step S706: Minimize the composite loss function using the Adam optimizer; Step S707: Use the Bayesian optimization framework to search for the optimal combination of hyperparameters.
[0117] Specifically, a hybrid training strategy based on teacher forcing is adopted to balance training efficiency (parallel computing) and prediction accuracy (autoregressive consistency). The specific process and formula are as follows: 1) Construction of training mode input: To achieve batch parallel training, a combined input matrix of "historical sequence + guidance sequence" is constructed. The formula is:
[0118] in, For historical input window (dimension) (consistent with Source in S2) For guiding sequence (dimension) The formula for constructing the guiding sequence is:
[0119]
[0120]
[0121] In other words, the flow characteristics in the pilot sequence use "real flow shifted one position to the right," ensuring that the model, when predicting the flow at time τ, only relies on information from time τ-1 and earlier, avoiding the leakage of future information. Combined input matrix The overall dimension is .
[0122] 2) Causal Mask Control: To further strengthen timing constraints, a lower triangular causal convolution mask is introduced during the selective scanning process of the Mamba module. The formula is:
[0123] This masking mechanism strengthens temporal constraints at the data level, ensuring that model predictions conform to the temporal logic of hydrological processes.
[0124] in, This is the index of the current computation time step. For the historical time step index used in the calculation, For dimension The lower triangular matrix. The mask is applied during the state update process, and the formula is adjusted to:
[0125] Ensure that when the model calculates the output at time τ, it can only obtain the input information at and before time τ. hour, The historical state is masked, which is completely consistent with the time-series logic of hydrological prediction.
[0126] 3) Composite Loss Function Optimization: To simultaneously optimize prediction error and generalization ability, a composite loss function of "basic loss + overfitting penalty" is constructed. The specific formula and definition are as follows: a) Basic Loss: The mean squared error (MSE) is used to measure the deviation between the predicted and actual values. The formula is:
[0127] in, The actual transformed flow rate (after standardization) at time τ. To predict the number of steps.
[0128] b) Overfitting penalty term: A penalty term is constructed based on the difference in Nash efficiency coefficients (NSE). The NSE calculation formula is as follows:
[0129] When the difference between the NSE of the training set and the validation set exceeds a threshold, an overfitting penalty is triggered. The penalty term is calculated as follows:
[0130] in (Penalty coefficient) (Threshold) , These are the NSE values for the training and validation sets, respectively.
[0131] c) Composite Loss Function: Combines the basic loss and overfitting penalty, the formula is as follows: During model training, the Adam optimizer minimizes... Optimizer parameters: Initial learning rate Weight decay coefficient = Momentum parameters , .
[0132] By optimizing the composite loss function, the model can improve prediction accuracy while effectively avoiding overfitting and enhancing generalization ability.
[0133] 4) Hyperparameter adaptive optimization: The optimal combination of hyperparameters is searched using a Bayesian optimization framework, specifically defined as follows: a) Hyperparameter search space, as shown in Table 1: Table 1
[0134] b) Optimize the objective function: Using the overall score of the validation set as the objective, the formula is:
[0135] During the search process, each iteration trains for 100 epochs, selecting... The combination of hyperparameters with the largest value is taken as the optimal solution. For example, the optimal hyperparameters for a certain watershed data are: , , Batch_Size=64 .
[0136] Furthermore, step S106 includes the following steps: Step S801: Use the data from the N days prior to the time t to be predicted as the initial input; Step S802: Determine the target time for the k-th prediction; Specifically, the initial input is constructed as follows: for the time to be predicted. The former Using the data from the previous day as the initial input, the formula is:
[0137] ( ) in, Dimensions Each component is a standardized value, where... , The results are standardized based on historical measured data. This is the result of flow standardization after historical transformation.
[0138] Step S803: Concatenate the initial input with the meteorological factors of the current prediction step and the historical prediction values to obtain the updated feature vector; Step S804: Input the updated feature vector into the trained HydroMamba model to obtain the standardized prediction value at the current time. Step S805: Update the traffic forecast value from the previous moment to the standardized forecast value for the current moment; Step S806: After repeating the cycle M times, a standardized prediction sequence for the next M days is obtained; Specifically, hourly rolling forecast: initialization (Using the flow rate at the last historical moment as the initial value), it is executed based on a "prediction-update-repredict" loop. The second prediction, the first Second-rate( The prediction process is as follows: 1) Definition of prediction time: the first The target time for this prediction is:
[0139] 2) Input Update: The initial input is concatenated with the meteorological factors and historical forecast values of the current forecast step. The formula is as follows:
[0140] in, Indicates will Slide one time step to the left (remove the earliest time) (data) for The newly added feature vector at time step 1 is given by the formula:
[0141] Variable definition: , for Standardized results of real-time weather forecast data (reusing the above) ), , for Time encoding of a moment This is the traffic forecast value from the previous time step. After the update... The dimension is still .
[0142] 3) Single-step prediction: Input the trained HydroMamba model to obtain the standardized prediction value at the current time step, using the following formula:
[0143] in, These are the optimal parameters for the trained model.
[0144] 4) State Update: Update current_flow to the current predicted value, using the following formula:
[0145] At the same time, X_init is updated to X_update to prepare for the next prediction.
[0146] After repeating the cycle M times, a standardized prediction sequence for the next M days is obtained:
[0147] The dimension is [M, 1], which is used to prepare for the subsequent result reconstruction.
[0148] The core logic of rolling forecasting is as follows: using historical N-day features as the initial input, the model predicts the current flow rate, and then concatenates the predicted value with the weather forecast factor for the next moment as a new input. This process is repeated to complete multiple-step forecasting, ensuring that each step relies only on historical and predicted information.
[0149] Step S807: Denormalize the standardized prediction value at the current moment to obtain the transformed flow rate; Step S808: Perform an inverse Log1p transformation on the transformed flow rate to obtain the predicted flow rate at the true scale. Step S809: Calculate the mean absolute error based on the predicted actual scale flow rate. Step S810: When the Nash efficiency coefficient is greater than or equal to the first preset threshold and the mean absolute error is less than or equal to the second preset threshold, the prediction result meets the engineering application requirements. Note that the prediction result must be de-standardized before evaluation can be performed.
[0150] Specifically, the prediction result restoration: The OBS_RUN_LOG_pred_norm output by the model is the standardized and transformed flow value, which needs to be restored to the measured flow at the true scale through two steps of "de-standardization-inverse transformation". The specific formula is as follows: 1) Destandardization: Restores the standardized forecast values to the transformed flow scale. The formula is:
[0151] in, These are the standard deviation and mean of the training set OBS_RUN_LOG, respectively, and OBS_RUN_LOG_pred is the transformed flow rate after destandardization (unitless).
[0152] 2) Inverse Log1p Transform: This transforms the flow rate back to the actual measured flow rate at the true scale. The formula is:
[0153] in, Let τ be the final true-scale flow prediction value (unit: m³ / s). hour, This is consistent with the logic of the original data.
[0154] Prediction performance validation: The mean absolute error (MAE) and Nash efficiency coefficient (NSE) were used to evaluate the prediction performance. The formula for calculating MAE is as follows:
[0155] When NSE≥0.8 and MAE≤50m³ / s, the model prediction results meet the requirements of engineering applications.
[0156] Combining the inverse standardization and inverse transform processes, the final reduction formula can be simplified to:
[0157] This process enables accurate conversion of model output to real-world traffic scale.
[0158] The model architecture logic is as follows: After the input data is processed by the embedding layer, it is passed to the MambaBlock stacked layer for feature extraction, and then processed by the normalization layer and the linear output layer to finally obtain the prediction result. The internal structure of a single MambaBlock is that the input is processed sequentially through normalization, convolutional layer, state space module, and gated perceptron, and then output through residual connection.
[0159] The autoregressive inference process is as follows: Input a sequence containing historical weather and flow data, combine the weather factors of the first day to predict the flow of the first day, append the predicted flow to the input sequence, combine the weather factors of the second day to predict the flow of the second day, repeat this process M times, and finally output the flow sequence for the next M days.
[0160] This embodiment selects multi-year historical hydrological and meteorological observation data from a typical hydrological basin station as the experimental object, and applies the hydrological flow long-sequence prediction method based on the improved Mamba state-space model (referred to as HydroMamba) proposed in this invention. The experimental environment is built on the deep learning framework PyTorch, and the hardware platform is configured as follows: .
[0161] The specific implementation process of this embodiment is as follows: 1. Multi-source data fusion and standardized preprocessing (1) Data cleaning and integrity verification: A total of 12,510 diurnal records (12,510 rows) were collected for this watershed, including fields such as year (YR), month (MNTH), date (DY), snow water equivalent (SWE), precipitation (PRCP), and measured flow (OBS_RUN). After integrity verification, the missing data rate for the key fields (SWE, PRCP, OBS_RUN) was 0.0%, indicating good data quality and no need for interpolation completion.
[0162] (2) Outlier handling: Negative values were detected in the measured flow rate (OBS_RUN). After lower limit pruning, the minimum flow rate was 0.0 m³ / s and the maximum flow rate was 19.3769 m³ / s, eliminating physically unreasonable negative flow rate data.
[0163] (3) Nonlinear distribution correction: To address the long-tail distribution characteristics of hydrological flow data, the Log1p transformation formula is adopted. The original flow is processed. The transformed logarithmic flow (OBS_RUN_LOG) has a mean of 0.8207 and a standard deviation of 0.5260. The data distribution is closer to a normal distribution, which is beneficial to the convergence of the model gradient.
[0164] (4) Time feature coding: Sine-cosine coding is used to transform the accumulated days of a year into a periodic feature. The encoded... The value range is [-0.9999, 0.9999]. The values range from [-0.9999, 0.9999], with the mean approaching 0 and the standard deviation being approximately 0.707, constructing a time feature with the characteristic of being connected end to end.
[0165] (5) Data normalization: Based on the training set statistics, the input features are standardized using StandardScaler. The key normalization parameters obtained are as follows: Snow water equivalent (SWE): mean =76.1706, standard deviation ; Precipitation (PRCP): Mean =3.1282, standard deviation =5.2562; Logarithmic flow (OBS_RUN_LOG): Mean =0.8207, standard deviation =0.5260.
[0166] The test set and validation set strictly reuse the above parameters to avoid information leakage.
[0167] 2. Construction of time-series sample pairs based on sliding window (1) Window parameter settings: To capture long-sequence dependencies and adapt to medium-term forecasting needs, the historical sequence length N = 60 days, the future forecast length M = 7 days, and the sliding step size is 1 day.
[0168] (2) Dataset partitioning: To maintain the continuity of the time series, the total data was divided into training, validation, and test sets in a ratio of approximately 7:1.5:1.5.
[0169] Training set: 8,691 samples, used for model parameter updates; Validation set: 1,870 samples, used for hyperparameter optimization and early stopping control; Test set: 1,871 samples, used for final performance evaluation.
[0170] (3) Sample dimensions: The constructed single input sample has dimensions of [60, 5] (60 days × 5 features), and the target sequence has dimensions of [7, 1] (7 days × 1 traffic feature).
[0171] 3. Construction and Training of the HydroMamba Prediction Model (1) Adaptive optimization of hyperparameters: A Bayesian optimization framework was used to search for the key hyperparameters of the HydroMamba model in 20 rounds.
[0172] The optimal combination of hyperparameters was finally determined as follows: Model latent space dimension ( ): 64 Number of MambaBlock stacking layers ( ): 4 State space dimension ( ): 64 Dropout probability: 0.2733 Optimizer learning rate ( ):
[0173] Training batch size :64 (2) Implementation of hybrid training strategy: The model is constructed based on optimal hyperparameters, employing a hybrid input method of "historical sequence + guide sequence" and incorporating causal masking control. A composite loss function is used for training over 150 epochs.
[0174] The training logs show that the model converges well: In the early stages of training (Epoch 0): the training set loss was as high as 0.9341, the validation set loss was 0.1431, and the validation set NSE was only 0.6460, indicating that the model was not yet fitted.
[0175] Mid-training (Epoch 60): The training set loss rapidly decreased to 0.0101, and the validation set NSE improved to 0.9760, indicating that the model had learned significant hydrological patterns.
[0176] Late training stage (Epoch 130): The validation set NSE reached a peak of 0.9811, with a corresponding overall score of 0.98125. At this point, the training set loss stabilized at around 0.0087, indicating that the model maintained high accuracy without overfitting.
[0177] 4. Flow prediction and result correction based on autoregressive mechanism (1) Rolling prediction and result restoration: The trained optimal model is used to perform autoregressive rolling predictions on the test set. The standardized results output by the model are then subjected to inverse standardization and inverse Log1p transformation formulas. Restore to actual traffic volume (unit: ).
[0178] (2) Predictive performance evaluation: The mean squared error (MSE), mean absolute error (MAE), coefficient of determination (R²), and Nash efficiency coefficient (NSE) were used to quantitatively evaluate the model's performance on the training, validation, and test sets. The results are shown in Table 2. Table 2
[0179] This invention, through architectural innovation and process optimization, possesses significant advantages over existing technologies: high computational efficiency, with inference memory usage and time increasing linearly with the length of the input sequence, making it suitable for processing high-frequency or long-cycle hydrological data; strong long-sequence memory capability, utilizing the discretization of continuous state equations in the state-space model to capture long-distance meteorological-hydrological lag effects (such as the lag of snowmelt runoff) that are difficult for traditional cyclic models to capture; outstanding generalization ability, significantly improving the model's predictive performance on unseen data by processing the skewed distribution of hydrological data through logarithmic transformation and combining it with an anti-overfitting objective function; and high practical application value, with a lightweight model structure (fewer parameters than mainstream models with equivalent performance), making it easy to deploy on edge computing devices for real-time flood early warning.
[0180] Reference Figure 4 , Figure 4 Figures (a)–(f) present scatter plots of observed and simulated flow rates for the training, validation, and test sets, along with the corresponding residual distributions. Figure 4 (a) is a scatter plot comparing observed values and simulated values in the training set. Figure 4 (c) is a scatter plot comparing the observed values with the simulated values to verify the results. Figure 4 (e) is a scatter plot comparing the observed and simulated values in the test set. The point cloud is closely distributed above or near the 1:1 reference line, indicating that the HydroMamba model can capture the runoff variation characteristics of different sample intervals well. Figure 4 (b) is the residual plot of the training set. Figure 4 (d) is the residual plot of the validation set. Figure 4 In the middle (f), the residual plot of the test set is shown with the simulated flow rate as the horizontal axis. Most of the residuals are concentrated around 0 and do not show obvious systematic bias, indicating that the model has small systematic error and good generalization ability in the training, validation and testing stages.
[0181] Example 2: Figure 5 This is a schematic diagram of a long-sequence hydrological flow prediction system based on an improved state-space model provided in Embodiment 2 of the present invention.
[0182] Reference Figure 5 The system includes: The data acquisition module is used to collect multi-source data of the watershed to be predicted. The multi-source data includes daily meteorological driving factors, hydrological monitoring data and temporal characteristic data. The processing module is used to perform data cleaning, nonlinear distribution correction, time feature encoding, and data normalization on multi-source data to obtain processed multi-source data. The time series sample pair construction module is used to construct time series sample pairs from processed multi-source data using the sliding window method. The time series sample pairs include the input sequence and the target sequence. The model building and training module is used to build a HydroMamba model based on time-series samples, train the HydroMamba model, and search for the optimal combination of hyperparameters. The prediction module is used to predict traffic and restore results based on the trained HydroMamba model using an autoregressive mechanism.
[0183] This invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the improved state-space model hydrological flow long-sequence prediction method provided in the above embodiments.
[0184] This invention also provides a computer-readable medium having processor-executable non-volatile program code, on which a computer program is stored. When the computer program is run by a processor, it executes the steps of the improved state-space model for long-sequence hydrological flow prediction method described in the above embodiments.
[0185] The computer program product provided in the embodiments of the present invention includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the preceding method embodiments. For specific implementation, please refer to the method embodiments, which will not be repeated here.
[0186] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and apparatus described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0187] Furthermore, in the description of the embodiments of the present invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention based on the specific circumstances.
[0188] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0189] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0190] Finally, it should be noted that the above-described embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. An improved state-space model for long-sequence prediction of hydrological discharge, characterized in that, The method includes: Collect multi-source data of the watershed to be predicted, including daily-scale meteorological driving factors, hydrological monitoring data and temporal characteristic data; The multi-source data is subjected to data cleaning, nonlinear distribution correction, time feature encoding, and data normalization to obtain the processed multi-source data. The processed multi-source data is used to construct time series sample pairs using the sliding window method. The time series sample pairs include an input sequence and a target sequence. A HydroMamba model is constructed based on the time-series samples, the HydroMamba model is trained, and the optimal combination of hyperparameters is searched. Based on the trained HydroMamba model, an autoregressive mechanism is used to achieve traffic prediction and result reconstruction.
2. The improved state-space model method for long-sequence prediction of hydrological discharge according to claim 1, characterized in that, The processed multi-source data is used to construct time-series sample pairs using the sliding window method. Each time-series sample pair includes an input sequence and a target sequence, comprising: Define core parameters, which include historical sequence length, future prediction length, and sliding step size; Based on the t-th sample in the time series, determine the input window and the target window; where t is greater than or equal to the sum of the historical sequence length and the future prediction length; Determine the total time series length; The total number of samples constructed is calculated based on the total time series length, the historical series length, and the future prediction length. The total number of constructed samples is divided according to a preset ratio to obtain a training set, a validation set, and a test set; The input sequence is determined based on the input window, and the target sequence is determined based on the target window; Determine the input feature vector and target vector at each time step; Wherein, the end time of the input sequence is t-1, and the start time of the target sequence is t.
3. The improved state-space model method for long-sequence prediction of hydrological discharge according to claim 1, characterized in that, The HydroMamba model includes an input embedding layer, a Mamba stacked coding layer, and an output mapping layer. The HydroMamba model is constructed based on the time-series sample pairs, including: In the input embedding layer, the standardized input feature vector, linear projection matrix, and embedding layer bias term at time τ are defined. Based on the standardized input feature vector at time τ, the linear projection matrix, and the embedding layer bias term, calculate the high-dimensional feature vector and the embedded input sequence at time τ, respectively. The Mamba stacked coding layer comprises k MambaBlocks connected in series. The input of the kth MambaBlock is the output of the previous layer, and the initial input is the embedded input sequence. Normalization, state space modeling, and residual connection processing are performed on each MambaBlock to obtain the output features of the MambaBlock. In the output mapping layer, the encoded high-dimensional features are converted into traffic prediction values, and a prediction sequence is output based on the traffic prediction values.
4. The improved state-space model method for long-sequence prediction of hydrological discharge according to claim 3, characterized in that, Normalization, state-space modeling, and residual connection processing are performed on a single MambaBlock to obtain the output features of the MambaBlock, including: Normalize each MambaBlock to obtain a normalized feature vector; The normalized feature vectors are projected to obtain the projected parameter matrix. The projected parameter matrix is used to dynamically update the state vector through a structured state-space model; The state vector is transformed into the output features of the Mamba module; The output features of the Mamba module are added to the original input features of the MambaBlock to obtain the output features of the MambaBlock.
5. The improved state-space model method for long-sequence prediction of hydrological discharge according to claim 3, characterized in that, In the output mapping layer, the encoded high-dimensional features are converted into traffic prediction values, including: The encoded features are processed by RMSNorm to obtain normalized encoded features. The normalized encoded features are regularized using the Dropout mechanism to obtain regularized encoded features. The regularized encoded features are mapped to the traffic prediction values.
6. The improved state-space model method for long-sequence prediction of hydrological discharge according to claim 1, characterized in that, The HydroMamba model is trained, and the optimal combination of hyperparameters is searched, including: Retrieve historical input windows and guidance sequences; Construct a combined input matrix based on the historical input window and the guiding sequence; Obtain the lower triangular causal convolution mask during the selective scanning process of the Mamba module; Calculate the basic loss and overfitting penalty term; Construct a composite loss function based on the base loss and the overfitting penalty term; Minimize the composite loss function using the Adam optimizer; The optimal combination of hyperparameters is searched using a Bayesian optimization framework.
7. The improved state-space model method for long-sequence prediction of hydrological discharge according to claim 1, characterized in that, Based on the trained HydroMamba model, an autoregressive mechanism is used to achieve traffic prediction and result reconstruction, including: Use the data from the N days prior to the time t to be predicted as the initial input; Determine the target time for the k-th prediction; The initial input is concatenated with the meteorological factors of the current prediction step and the historical prediction values to obtain the updated feature vector; The updated feature vector is input into the trained HydroMamba model to obtain the standardized prediction value at the current time. Update the traffic forecast value from the previous moment to the standardized forecast value for the current moment; After repeating the cycle M times, a standardized prediction sequence for the next M days is obtained. The standardized prediction value at the current moment is destandardized to obtain the transformed flow rate; The transformed flow rate is then subjected to an inverse Log1p transformation to obtain the true-scale flow rate prediction value. Calculate the mean absolute error based on the predicted actual scale flow rate; When the Nash efficiency coefficient is greater than or equal to the first preset threshold and the mean absolute error is less than or equal to the second preset threshold, the prediction result meets the requirements of engineering applications.
8. The improved state-space model method for long-sequence prediction of hydrological discharge according to claim 1, characterized in that, The multi-source data undergoes data cleaning, nonlinear distribution correction, time feature encoding, and data normalization to obtain processed multi-source data, including: The multi-source data is subjected to data integrity verification, missing data completion, and outlier processing. The original measured flow rate is converted into the transformed flow rate; The accumulated days of the year are converted into periodic numerical features using sine-cosine encoding; The original feature data is normalized to obtain standardized feature data.
9. An improved state-space model-based long-sequence hydrological flow prediction system, characterized in that, The system includes: The acquisition module is used to collect multi-source data of the watershed to be predicted. The multi-source data includes daily-scale meteorological driving factors, hydrological monitoring data, and temporal characteristic data. The processing module is used to perform data cleaning, nonlinear distribution correction, time feature encoding, and data normalization on the multi-source data to obtain the processed multi-source data. A time-series sample pair construction module is used to construct time-series sample pairs from the processed multi-source data using a sliding window method. The time-series sample pairs include an input sequence and a target sequence. The model building and training module is used to build a HydroMamba model based on the time series samples, train the HydroMamba model, and search for the optimal combination of hyperparameters. The prediction module is used to predict traffic and restore results based on the trained HydroMamba model using an autoregressive mechanism.
10. An electronic device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, characterized in that, When the processor executes the computer program, it implements the method described in any one of claims 1 to 8.
Citation Information
Patent Citations
Runoff prediction method and system, storage medium and equipment
CN121212443A
Long-term streamflow forecast method and system based on process-data synergic drive
US11886967B1
Cited By
Wave prediction method and system fusing multi-source typhoon features
CN122221194A
A wave prediction method and system integrating multi-source typhoon characteristics
CN122221194B