A Water Quality Prediction Method Based on Spatiotemporal Dual-View Hypergraph Neural Network
By constructing a static prior hypergraph and a dynamic dual-view hypergraph, combined with a multi-stage gated fusion encoder, the accuracy and stability issues of multi-site, multi-parameter water quality prediction were solved, achieving high accuracy and interpretability of water quality prediction.
Patent Information
- Application Number
- CN202611379339.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-07
- Publication Date
- 2026-11-17
AI Technical Summary
Existing water quality prediction technologies struggle to achieve high-precision and stable predictions in scenarios with multiple stations and multiple water quality parameters, especially under dynamic environmental boundary conditions. Furthermore, existing methods cannot simultaneously distinguish between spatial connections between stations and the coupling relationship between different water quality parameters within the same station.
A spatiotemporal dual-view hypergraph neural network-based approach is adopted to construct a static prior hypergraph and a dynamic dual-view hypergraph. Multi-source features are integrated through a multi-stage gated fusion encoder to enhance the joint modeling capability of multi-site and multi-parameter water quality sequences.
It improves the accuracy, stability, and interpretability of water quality prediction, can adapt to dynamic environmental boundary conditions, and enhances the ability to model the spatiotemporal dependence of water quality sequences from multiple sites and with multiple parameters.
Smart Images

Figure CN123115683A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of water environment monitoring and intelligent hydrological forecasting technology, and more specifically to a water quality prediction method based on a spatiotemporal dual-view hypergraph neural network. Background Technology
[0002] Accurate forecasting of watershed water environment is a core supporting means for water pollution prevention and control, water resource allocation, and ecological risk early warning. Current river water quality prediction technologies are mainly divided into two categories: mechanistic numerical models and data-driven deep learning models. However, both types of solutions have significant technical shortcomings. Traditional hydrological mechanism models such as WASP and EFDC simulate pollutant migration and transformation based on convection-diffusion-reaction equations. They require complete measured data on topography, pollution sources, and hydrological and meteorological conditions. Solving these models in large-scale watershed scenarios incurs extremely high computational costs, and the lack of boundary conditions easily leads to numerical instability. Furthermore, they are difficult to adapt to the need for simultaneous prediction of multiple stations and multiple water quality parameters, and their generalization ability is limited.
[0003] With the improvement of water environment monitoring networks, data-driven methods such as LSTM and spatiotemporal graph neural networks are gradually being applied to water quality time series prediction. Conventional time series models only explore patterns in the time dimension, ignoring the directional connectivity topology of upstream and downstream river networks and the biochemical coupling relationships of multiple indicators; traditional graph neural networks can only model pairwise relationships between stations, and cannot express high-order complex interactions of multiple stations and multiple water quality parameters, making it difficult to characterize the multi-component chemical reaction chains within water bodies. Existing hypergraph methods mostly adopt fixed static hyperedge structures, which cannot adapt to dynamically changing environmental boundaries such as flood season runoff and sudden pollution, and generally rely entirely on data fitting without embedding hydrophysical priors. In scenarios with sparse monitoring data and non-stationary sequences, they are prone to learning spurious correlations, resulting in a significant decrease in the accuracy of long-term time series predictions.
[0004] Meanwhile, existing spatiotemporal modeling schemes often struggle to simultaneously distinguish between spatial connections between stations and the coupling relationships between different water quality parameters within the same station; fixed topologies also struggle to adapt to changes in monitoring status over time. Hard threshold mapping can also cause abrupt changes in correlations, hindering end-to-end optimization. Therefore, a water quality prediction method is needed that can integrate static domain knowledge with dynamic dual-view higher-order relationships and adaptively adjust different information branches. Thus, a water quality prediction method based on a spatiotemporal dual-view hypergraph neural network is designed to address these issues, which is a problem urgently requiring solutions from those skilled in the art. Summary of the Invention
[0005] In view of this, the present invention provides a water quality prediction method based on a spatiotemporal dual-view hypergraph neural network: a static prior hypergraph is constructed using preset river network connectivity relationships and parameter coupling rules; a dynamic spatial view and a dynamic parameter view hypergraph are constructed using a continuous soft allocation mechanism; and multi-source features are integrated through a multi-stage gated fusion encoder, thereby enhancing the joint modeling capability of multi-site and multi-parameter water quality sequences, which is beneficial to improving the accuracy, stability, and interpretability of water quality prediction. To achieve the above objectives, the present invention adopts the following technical solution: A water quality prediction method based on a spatiotemporal dual-view hypergraph neural network includes: Acquire raw hydrological and environmental data of the river network and perform preprocessing; A spatiotemporal dual-view hypergraph neural network model is constructed, wherein the spatiotemporal dual-view hypergraph neural network model includes a heterogeneous spatiotemporal labeling module, a physical prior embedding module, a dynamic hypergraph generation module, a gated cascade encoder module, and a decoding output module connected in sequence, and the spatiotemporal dual-view hypergraph neural network model is trained. The preprocessed raw hydrological environmental data is input into a trained spatiotemporal dual-view hypergraph neural network model to obtain multivariate water quality prediction data for future periods of the river network.
[0006] Preferably, the heterogeneous spatiotemporal labeling module is used to normalize, project time-variables, factorize spatial-parameter embedding and phase injection of historical water quality observation data of river networks and output initial feature tensors; The physical prior embedding module constructs a spatial connectivity prior matrix and a parameter coupling network prior matrix based on preset river network connectivity relationships and water quality parameter coupling rules, and concatenates them along the hyperedge dimension to obtain a static physical prior hypergraph. The dynamic hypergraph generation module relies on the intermediate features obtained from the forward operation of the neural network, and adopts a continuous soft allocation mechanism to learn and generate dynamic spatial view hypergraphs and dynamic parameter view hypergraphs layer by layer. The gated cascade encoder module is used to combine the self-attention mechanism and hypergraph convolution operation to extract features from the dynamic spatial view hypergraph, dynamic parameter view hypergraph, and static physical prior hypergraph, and performs multi-stage fusion through an adaptive gating mechanism to complete deep feature encoding. The decoding output module is used to decode the deep feature encoding and restore the original dimensions of the data to obtain multivariate water quality prediction data for future time periods of the river network.
[0007] Preferably, the time-variable projection process includes: for the site and water quality parameters Each combination of variables has a length of [length]. The historical backtracking window is mapped to a feature dimension through a learnable time axis projection operation. The formula for a high-dimensional vector space is as follows: ; The time axis projection operation is implemented by a linear mapping or one-dimensional convolution acting on the historical time dimension. and These represent the learnable projection parameters and the bias, respectively. It is a non-linear activation function. Scale the output tensor to the standard hidden dimension, where B represents the batch size. This represents the normalized historical observation sequence of the s-th station and the p-th water quality parameter; The factorized space-parameter embedding is used to generate the site space embedding matrix. and water quality parameter embedding matrix And introduce the broadcast addition operator. By separating these orthogonal control factors, a structurally regularized representation is obtained. The formula is as follows: ; The phase injection is achieved through a sinusoidal encoding function. Standard phase label tensor Injected into the representation space; the phase encoding function is implemented using learnable embedding or sine / cosine encoding, and its expression is as follows: ; Received For the initial feature tensor, In mathematics, the spatial axis and the parameter axis are reconciled into a single global variable dimension. .
[0008] Preferably, the method for constructing the spatial connectivity prior matrix includes: Based on the upstream and downstream connectivity of monitoring stations in the river network, a set C of directional river segments pointing from upstream station u to downstream station d is pre-determined, and each directional river segment is used as a spatial prior hyperedge; (The last part, "m-th", appears to be a separate, unrelated statement and is left as is.) s Preset weights for each directional river segment In implementations that do not differentiate river segment weights, this value is set to 1; where, Indicates a directional river segment index. Indicates the number of prior hyperedges in the space; ; Parameter weights are set for different parameters based on their transport characteristics. ; Combining parameter weights, preset river segment weights, and upstream / downstream directional coefficients, a river segment connecting upstream station u and downstream station d is defined. The formula for assigning asymmetric association weights is as follows:
[0009] in, and These represent the directional weight coefficients of the upstream and downstream nodes, respectively; in one embodiment, , .
[0010] Preferably, the method for constructing the prior matrix of the parameter coupling network includes: Establish a parameter coupling coefficient matrix based on the predetermined physicochemical coupling relationship between water quality parameters. ; Set a preset coupling relationship retention threshold. Set the parameter coupling relationship that has not reached the threshold to zero; For each node representing station s and parameter p, its hyperedge relative to the parameter p The degree of correlation is determined by the following formula: ; This indicates that the node corresponding to station s and parameter p is related to the first... The coupling strength of the hyperedge parameter is given by matrix R, where the matrix elements are either preset non-negative coupling strengths or absolute values of correlation coefficients; subsequently, the two priors are concatenated along the hyperedge dimensions: ; in, This indicates the exact number of prior hyperedges in the parametrically coupled network.
[0011] Preferably, the process by which the dynamic hypergraph generation module generates the dynamic spatial view hypergraph and the dynamic parameter view hypergraph includes: setting learnable spatial prototype hyperedges and learnable parameter prototype hyperedges, wherein the prototype hyperedges are initialized according to a preset random distribution and optimized end-to-end during model training; the temperature scaling continuous correlation mapping formula for the dynamic spatial view is as follows: ; in, , Represents the prototype hyperedge of the learnable space Quantity; The temperature parameter is used to scale and adjust the smoothness of the soft-assigned weight distribution. This is the matrix transpose symbol; based on A parameterized reaction prototype vector The constructed dynamic parameter view hypergraph is used to characterize the dynamic coupling relationship between water quality parameters as the input state changes, as shown in the following formula: ; By stitching hyperedges together, the spatial view and the parametric view are bound into a unified matrix and assembled into a complete data-driven structure component for the m-th encoder layer, as shown in the following formula: .
[0012] Preferably, the process of deep feature encoding completed by the gated cascade encoder module includes: The initial feature tensor The input is fed into the multi-head self-attention module, which calculates the query Q, key K, and value V matrix and performs attention operations. After layer normalization, the intermediate hidden representation after attention mechanism processing is obtained, as shown in the following expression: ; in, It's about scaling the bottleneck dimension. Then the aggregated attention head is scaled; Hypergraph convolution is performed on the dynamic spatial view hypergraph, the dynamic parameter view hypergraph, the static physical prior hypergraph, and the combined hypergraph, respectively, and the contribution of each branch to the encoding result is controlled by the corresponding adaptive gating factor; each branch can be extracted and fused in parallel, or fused in multiple stages according to a preset order; one multi-stage fusion method is as follows: ; ; ; ; in, The node-by-node gating factor is obtained by passing the corresponding branch features through a gating network. A composite hypergraph formed by stitching dynamic and static views along the hyperedge dimension; Final encoder output The following is obtained by fusing self-attention features and hypergraph features using learnable weights:
[0013] in, and It is a learnable balance coefficient.
[0014] Preferably, when training the spatiotemporal dual-view hypergraph neural network model, mean squared error loss is used in the standardized data domain, and regularization is performed through weight decay. The total loss function is expressed as follows: ; in, Represents the true observation tensor in the normalized domain. Represents the set of trainable parameters. Indicates optional regularization weights; static physical prior hypergraphs are not updated as trainable parameters.
[0015] Compared with existing technologies, this invention utilizes static domain priors and dynamic dual-view hypergraphs to jointly describe the spatial connections and parameter coupling relationships of river networks. It maintains the differentiability of the dynamic mapping process through continuous soft allocation and uses multi-stage adaptive gating to adjust the contribution of each branch, thereby enhancing the spatiotemporal dependency modeling capability of multi-site and multi-parameter water quality sequences. This is beneficial for improving prediction accuracy, stability, and result interpretation capabilities. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0017] Figure 1 The flowchart of the water quality prediction method provided by the present invention. Detailed Implementation
[0018] The technical solutions of the embodiments 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, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] This invention discloses a water quality prediction method based on a spatiotemporal dual-view hypergraph neural network, comprising: Acquire raw hydrological and environmental data of the river network and perform preprocessing; A spatiotemporal dual-view hypergraph neural network model is constructed, wherein the spatiotemporal dual-view hypergraph neural network model includes a heterogeneous spatiotemporal labeling module, a physical prior embedding module, a dynamic hypergraph generation module, a gated cascade encoder module, and a decoding output module connected in sequence, and the spatiotemporal dual-view hypergraph neural network model is trained. The preprocessed raw hydrological environmental data is input into a trained spatiotemporal dual-view hypergraph neural network model to obtain multivariate water quality prediction data for future periods of the river network.
[0020] In a specific embodiment of the present invention, a spatiotemporal dual-view hypergraph neural network method (ST-DualHG) is provided. Figure 1The overall workflow of ST-DualHG is shown as follows: Step S101: Acquire and preprocess historical water quality observation data of multiple stations and parameters in the river network; Step S102: Perform heterogeneous spatiotemporal labeling and obtain initial feature tensors; Step S1031: Construct a static physical prior hypergraph based on preset river network connectivity and water quality parameter coupling rules; Step S1032: Generate dynamic spatial view hypergraph and dynamic parameter view hypergraph layer by layer based on intermediate features and continuous soft allocation mechanism; Step S104: Perform self-attention, hypergraph convolution, and multi-stage adaptive gating fusion to obtain deep feature encoding; Step S105: Decode and restore the original dimensions of the data, and output multivariate water quality prediction data for future periods. Specifically, the heterogeneous spatiotemporal labeling module is used to normalize, perform time-variable projection, factorized spatial-parameter embedding, and phase injection on the historical water quality observation data of the river network, and output the initial feature tensor. Normalization (Z-score standardization): Eliminates the dimensional differences of different water quality parameters, making the input signal values stable; Time-variable projection: The historical time series of each station-parameter combination is mapped to a fixed-dimensional feature vector through a learnable linear mapping of the time axis or one-dimensional convolution; Factorized spatial-parameter embedding (FSPE): Station embeddings and water quality parameter embeddings are set separately, and structural representations of each station-parameter combination are formed through broadcast addition; Phase injection: The phase index determined by the sampling period is mapped to the phase embedding to express the diurnal period or other preset periodic information. These four progressive steps complete the transformation from the original time series to a unified high-dimensional representation space, outputting the initial feature tensor X. (0) .
[0021] The physical prior embedding module constructs a spatial connectivity prior matrix and a parameter coupling network prior matrix based on the preset river network connectivity relationship and water quality parameter coupling rules, and splices the two along the hyperedge dimension to obtain a static physical prior hypergraph. The dynamic hypergraph generation module relies on the intermediate features obtained from the forward operation of the neural network, and adopts a continuous soft allocation mechanism to learn and generate dynamic spatial view hypergraphs and dynamic parameter view hypergraphs layer by layer. The gated cascade encoder module is used to combine the self-attention mechanism with hypergraph convolution operation to extract features of dynamic spatial view, dynamic parameter view and static physical prior hypergraph respectively, and perform multi-stage fusion through adaptive gating mechanism to complete deep feature encoding. The decoding output module is used to decode the deep feature encoding and restore the original dimensions of the data to obtain multivariate water quality prediction data for future periods of the river network.
[0022] It is important to note that raw hydrological environmental data refers to the raw multivariate water quality time series data collected from monitoring stations (including 4-hour resolution observation records of 7 parameters: conductivity, water temperature, pH, dissolved oxygen, turbidity, ammonia nitrogen, and total phosphorus at 23 stations). Historical water quality observation data of the river network is the specific term for the historical retrospective window formed after the data has been preprocessed. Both refer to different processing stages of the same dataset.
[0023] Changes in river water quality are influenced by multiple processes, including transport, diffusion, biochemical reactions, and external inputs. The convection-diffusion-reaction equation can be used as a conceptual description of these changes.
[0024] Where C represents the water quality component vector, D represents the dispersion coefficient, v represents the flow velocity, R(C) represents the component transformation term, and U represents the external input. This equation is used to illustrate the simultaneous spatial propagation and parameter coupling relationship of river water quality, and does not limit this invention to directly solving this equation. This invention utilizes static priors, dynamic dual-view hypergraphs, and gated fusion networks to learn the spatiotemporal dependencies in historical observation data, thereby reducing the data and computational burden required to directly establish complex mechanistic models.
[0025] Let the historical multivariate observation sequence be defined as a four-dimensional tensor. Where B represents the batch size, L is the historical backtracking window, S represents the number of spatial monitoring stations distributed across the river network, and P=7 indicates the water quality parameter targeted in this study. To maintain consistency with a unified graphical representation, the global variable dimension is defined as follows: From a hydrological perspective, these parameters encompass different physicochemical behaviors that determine transport patterns: conservative substances primarily controlled by long-distance advection (conductivity, water temperature), buffering systems (pH), and highly reactive variables prone to local degradation and sedimentation (dissolved oxygen, turbidity, ammonia nitrogen, and total phosphorus). Given a historical observation tensor X, the multivariate prediction task aims to predict the state tensor over the next T time steps. To ensure numerical stability and mitigate scale differences between variables of different units, the input signal is normalized using Z-score standardization: ; in, and They are the first The first site The time mean and standard deviation of each parameter (calculated based on the training set). It is a small constant added to prevent division by zero.
[0026] Specifically, the time-variable projection includes: for sites and water quality parameters Each specific combination of variables has a length of The historical backtracking window is mapped to a feature dimension through a learnable time axis projection operation. The unified high-dimensional space vector is given by the following formula: ; in, This indicates a learnable timeline projection operation. and These represent the learnable projection parameters and the bias, respectively. It is a non-linear activation function. Scale the output tensor to the standard hidden dimension, where B represents the batch size. This represents the normalized historical observation sequence of the s-th station and the p-th water quality parameter; The tilde above the tensor indicates the normalized tensor after Z-score standardization. The first colon in the subscript indicates taking all batches, the second colon indicates taking all historical time steps, s and p represent fixed site index and parameter index respectively, and the result is a two-dimensional matrix of shape B×L, that is, the complete normalized historical time series of site s on parameter p. The factorized space-parameter embedding is used to generate the site space embedding matrix. and water quality parameter embedding matrix And introduce the broadcast addition operator. By separating these orthogonal control factors, a structurally regularized representation is obtained. The formula is as follows: ; The phase injection is achieved through a sinusoidal encoding function. Standard phase label tensor Injected into the representation space; the phase encoding function is implemented using learnable embedding or sine / cosine encoding, and its expression is as follows: ; Received For the initial feature tensor, In mathematics, the spatial axis and the parameter axis are reconciled into a single global variable dimension. .
[0027] To simultaneously represent monitoring station identity, water quality parameter category, and periodic status, ST-DualHG employs time-variable projection, factorized spatial-parameter embedding (FSPE), and phase encoding. Time-variable projection: For each station... and parameters Each specific combination of variables has a length of Historical sequences are mapped to a learnable timeline through projection. The dimension indicates that the projection can be a linear layer or a one-dimensional convolution acting on the time axis.
[0028] ; The time axis projection operation is implemented by a linear mapping or one-dimensional convolution acting on the historical time dimension. and These represent the learnable projection parameters and the bias, respectively. It is a non-linear activation function. Scale the output tensor to the standard hidden dimension. This time projection effectively compresses continuous hydrological process sequences into historical feature markers while preserving the nonlinear transient time structure.
[0029] Spatial Factorization-Parameter Embedding (FSPE): Signals collected from river water quality monitoring stations are simultaneously governed by both geographical station location and parameter-specific behavior. To prevent data-driven overfitting and reduce parameter redundancy, an additive factorization mechanism is introduced to separate these orthogonal control factors. ; in, It encapsulates the unique baseline terrain boundaries and gravity routing characteristics of each site location, and Structural priors representing the chemical identity and stoichiometric affinity vectors of the seven target parameters were assigned. Broadcast adder operator. These dimensions are combined into a structured regularized representation The key point is that this factorization configuration will represent the parameter space from unconstrained... Complexity compressed to structure regularization The domain is subject to an inductive bias that forcibly introduces spatial location and chemical properties as independent physical drivers.
[0030] in, Indicates site identity or spatial location embedding. Indicates water quality parameter category embedding. Broadcast addition operator. This factorization approach separates the modeling of site factors from the modeling of parametric factors, and reduces the number of embedded parameters by... Reduced to .
[0031] Phase injection: Natural aquatic environments exhibit highly significant periodicity due to periodic radiative forcing and seasonal operating patterns. To transmit this invariant background rhythm information to a deep neural network without relying on heavy time attention overhead, a sinusoidal encoding function is used. Standard phase label tensor Injected into the representation space: Phase injection: Generate a phase index based on the position of the sampling time within a preset period, and then use a learnable phase embedding or sine / cosine coding function. Mapping to representation space:
[0032] The resulting unified tensor In mathematics, the spatial axis and the parameter axis are reconciled into a single global variable dimension. This serves as the initial state representation of hydrological information for subsequent dynamic and static superlayer blocks.
[0033] To introduce stable domain information into the data-driven structure, ST-DualHG constructs a static prior association matrix. This involves injecting unchanging, deterministic domain knowledge into the model, where... and These represent the number of spatial prior hyperedges and the number of parameter prior hyperedges, respectively. Static priors are used to represent predetermined river network connectivity and water quality parameter coupling relationships, and their structure remains unchanged during training and inference.
[0034] Specifically, the method for constructing the spatial connectivity prior matrix includes: Based on the upstream and downstream connectivity of monitoring stations in the river network, a set C of directional river segments pointing from upstream station u to downstream station d is pre-determined, and each directional river segment is used as a spatial prior hyperedge; (The last part, "m-th", appears to be a separate, unrelated statement and is left as is.) s Preset weights for each directional river segment In implementations that do not differentiate river segment weights, this value is set to 1; in, Indicates a directional river segment index. Indicates the number of prior hyperedges in the space; ; Parameter weights are set for different parameters based on their transport characteristics. ; Combining parameter weights, preset river segment weights, and upstream / downstream directional coefficients, a river segment connecting upstream station u and downstream station d is defined. The formula for assigning asymmetric association weights is as follows: ; ; in, and These represent the directional weight coefficients of the upstream and downstream nodes, respectively; in one embodiment, , .
[0035] In one specific embodiment, a set of directional river segments is established based on the upstream and downstream relationships of the monitoring stations. The number of river segments determines the spatial prior over the number of super-boundaries. Each global node index i corresponds to a station-parameter combination. If no additional distance information is used, the preset river segment weights for each river segment are... The default value is 1.
[0036] The preset river segment weights can be set to uniform values based on existing river network data; in other embodiments with reliable river segment length or hydrodynamic information, different weights can also be set based on the corresponding data. Parameter weights are set according to the relative transport characteristics of each water quality parameter. In one embodiment, conductivity and water temperature are set to 1.0, pH to 0.8, dissolved oxygen and turbidity to 0.7, and ammonia nitrogen and total phosphorus to 0.6. The spatial prior correlation matrix assigns asymmetric weights to upstream and downstream nodes of the same river segment according to the following formula: ; ; in, and These represent the directional weight coefficients of the upstream and downstream nodes, respectively; in one embodiment, , .set up As an inductive physical bias, it reflects the cumulative mass accumulation and downstream collection effects in natural drainage systems. The above values are a set of implementable examples and do not constitute a limitation on the scope of protection.
[0037] Specifically, the method for constructing the prior matrix of the parameter-coupled network includes: Establish a parameter coupling coefficient matrix based on the predetermined physicochemical coupling relationship between water quality parameters. The matrix elements represent the coupling strength between parameters; Set coupling relationship preservation threshold Set the parameter coupling relationship that has not reached the threshold to zero; For each node representing station s and parameter p, its hyperedge relative to the parameter p The degree of correlation is determined by the following formula: ; The "otherwise" in the formula indicates that no effective coupling relationship is set between parameter p and parameter mp; This indicates that the node corresponding to station s and parameter p is related to the first... The coupling strength of the hyperedge parameter is given by matrix R, where the matrix elements are either preset non-negative coupling strengths or absolute values of correlation coefficients; subsequently, the two priors are concatenated along the hyperedge dimensions: ; in, This indicates the number of prior hyperedges.
[0038] In one specific embodiment, the following is set The parameters are given prior hyperedges, and non-negative parameter coupling coefficients are pre-defined based on knowledge of water quality. A parameter coupling coefficient matrix is then established based on the pre-determined physicochemical coupling relationships between the water quality parameters. Set a preset coupling relationship retention threshold. And set the parameter coupling relationships that do not reach the threshold to zero; the threshold is used to filter the pre-set main parameter coupling relationships and does not represent the statistical significance test results.
[0039] For each node representing station s and parameter p, its hyperedge relative to the parameter p The degree of correlation is determined by the following formula: ; This represents the parameter coupling relationships within a site; its value indicates the coupling strength, not the direction of positive or negative correlation. Concatenating the spatial prior and the parameter prior along the hyperedge dimension yields a unified static prior hypergraph. .
[0040] Static prior hypergraphs provide relatively stable river network connectivity and parameter coupling relationships, but relying solely on a fixed structure makes it difficult to cover potential higher-order dependencies formed by changes in water quality over time. Therefore, this invention further establishes a dynamic dual-view hypergraph generated layer by layer from intermediate features. The dynamic hypergraph uses temperature-scaling Softmax for continuous soft assignment, enabling nodes to connect multiple prototype hyperedges with different membership degrees while maintaining the differentiability of the graph construction process, thus adapting to changes in relational structure under different input windows.
[0041] Specifically, the process by which the dynamic hypergraph generation module generates dynamic spatial view hypergraphs and dynamic parameter view hypergraphs includes: Learnable spatial prototype hyperedges and learnable parameter prototype hyperedges are configured. Prototype parameters are initialized according to a preset random distribution and updated based on the loss function gradient during end-to-end training; the dynamic spatial view employs a temperature-scaled continuous correlation mapping. ; in, , Represents the prototype hyperedge of the learnable space Quantity; The temperature parameter is used to scale and adjust the smoothness of the soft-assigned weight distribution. based on A parameterized reaction prototype vector The constructed dynamic parameter view hypergraph is used to characterize the dynamic coupling relationship between water quality parameters as the input state changes, while temperature scaling τ controls the softness or hardness of node assignment to these hyperedges. Specifically, after calculating the matching score of a node with each prototype hyperedge, τ is used as the denominator to scale the score as a whole: the smaller τ is, the sharper the distribution of the Softmax output, and the more likely the node is to be "hard" assigned to the hyperedge with the highest matching degree; the larger τ is, the smoother the distribution, and the node maintains a continuous and gentle connection weight with multiple hyperedges. The purpose of introducing temperature scaling is to avoid the gradient breakage problem caused by traditional hard assignment (binarized 0 / 1 connection), making the assignment process fully differentiable, thereby being able to characterize real physical processes such as the continuous mixing gradient of pollutants in the river system. The formula is as follows: ; By stitching hyperedges together, the spatial view and the parametric view are bound into a unified matrix and assembled into a complete data-driven structure component for the m-th encoder layer, as shown in the following formula: .
[0042] In one specific embodiment, a dynamic spatial view hypergraph A learnable space prototype hyperedge is generated; prototype parameters are initialized according to a preset random distribution and optimized end-to-end. The temperature scaling continuous correlation mapping is as follows: ; in The scaling temperature parameter is used to adjust the smoothness of the soft-assigned weight distribution.
[0043] based on A parameterized reaction prototype vector The constructed dynamic parameter view hypergraph is used to characterize the dynamic coupling relationship between water quality parameters as the input state changes: ; Finally, the spatial view and the parameter view are bound into a unified matrix by hyperedge splicing, and assembled into a complete data-driven structure component for the m-th encoder layer.
[0044] .
[0045] Specifically, the process of deep feature encoding completed by the gated cascade encoder module includes: The initial feature tensor The input is fed into the multi-head self-attention module, which calculates the query Q, key K, and value V matrix and performs attention operations. After layer normalization, the intermediate hidden representation after attention mechanism processing is obtained, as shown in the following expression: ; in, It's about scaling the bottleneck dimension. Then the aggregated attention head is scaled; Hypergraph convolution is performed on the dynamic spatial view, dynamic parameter view, static physical prior, and combined hypergraph, respectively, and the contribution of each branch to the encoding result is controlled by the corresponding adaptive gating factor; the branches can be extracted in parallel and then fused, or fused in multiple stages according to a preset order; one multi-stage fusion method is as follows: ; ; ; ; in, The node-by-node gating factor is obtained by passing the corresponding branch features through a gating network. A composite hypergraph formed by stitching dynamic and static views along the hyperedge dimension; Final encoder output The following is obtained by fusing self-attention features and hypergraph features using learnable weights: ; in, and It is a learnable balance coefficient.
[0046] It is important to note that The final output of the heterogeneous spatiotemporal tokenization module is the unified representation tensor obtained after four steps: normalization, time-variable projection, factorization of spatial-parameter embedding, and phase injection. It is the starting point of the entire encoder stack and is also known as the initial state representation. This represents the input of the m-th encoder layer (m=1,2,…,M), where m is greater than 1. It receives the output of the previous layer encoder. .
[0047] Therefore, the attention formula uses... Because the same self-attention mechanism is executed in every encoder layer, each time using the current intermediate hidden state of that layer as input, instead of always returning to the initial tensor.
[0048] In one specific embodiment, each encoder layer first utilizes multi-head self-attention to acquire nonlocal dependencies between nodes, then performs hypergraph propagation using a dynamic spatial view, a dynamic parameter view, and a static prior, and performs multi-stage fusion through adaptive gating. This structure is a neural network feature fusion process that does not require direct solution of the convection-diffusion-reaction equation. Self-attention between global variables is used to capture nonlocal correlations beyond direct river network connections. The layer input tensor X(m) first passes through the multi-head self-attention module to obtain an intermediate attention representation: ; in, This represents the key dimension of each attention head. This indicates the output projection matrix.
[0049] Hypergraph Convolution and Dynamic-Static Decoupling: Feature propagation on data-driven and deterministic topological graphs leverages local spectral hypergraph convolution. For any incidence matrix H mapping vertices to hyperedges, the nonlinear message-passing operator is formalized as: ; in This represents a trainable filter matrix. Let these represent the node degree matrix and the hyperedge degree matrix, respectively. The key point is that feature propagation relies on an explicit dynamic-static decoupling control concept. Static prior... It remains completely frozen and unchanged throughout the entire training and inference phases. In contrast, the dynamic association matrix... and It is generated from the intermediate features of the current layer, and its generated network parameters are updated through backpropagation.
[0050] Furthermore, the process describes how features propagate messages across both data-driven and physical prior hypergraphs, and why the two should be decoupled. For any incidence matrix H that maps nodes to hyperedges, the convolution operator performs the following two steps: (1) Through H T The features of each node are aggregated onto each hyperedge according to their association weights—like a "discussion group" where information about the members is gathered. (2) Through the learnable filter W hyper After the transformation, the aggregated information of the hyperedge is distributed back to each node via H—each member receives influence from other members of the same discussion group. The degree normalization matrix D... v D e This is used to balance the propagation strength and prevent nodes with too many connections or superedges from dominating the computation.
[0051] The same hypergraph propagation operator can be applied to both static prior hypergraphs and dynamic dual-view hypergraphs. Static priors represent predetermined domain relations, while dynamic hypergraphs represent learnable relations that change with input features. The two types of structures participate in feature encoding through gating fusion.
[0052] The intermediate features of each encoder layer regenerate a dynamic spatial view and a dynamic parameter view hypergraph, enabling the model to adjust the association strength between nodes and prototype hyperedges for different input windows.
[0053] Multi-stage gating fusion: Adaptive gating networks are set for the dynamic spatial view, dynamic parameter view, static prior and combined hypergraph respectively. The gating value is calculated from the node features of the corresponding branch and is used to control the propagation contribution of the branch.
[0054] The dynamic dual view and the static prior are concatenated along the hyperedge dimension to form a composite hypergraph. Subsequently, a feasible multi-stage integration process is as follows: ; ; ; ; These equations sequentially resolve spatial advection, stoichiometric reactions, static prior propagation, and global convergence. The final encoder output... The following is obtained by fusing self-attention features and hypergraph features using learnable weights:
[0055] in and This is a learnable balancing coefficient used to adjust the relative contributions of the self-attention branch and the hypergraph branch.
[0056] Specifically, when training the spatiotemporal dual-view hypergraph neural network model, mean squared error loss is used in the standardized data domain, and regularization can be optionally performed through weight decay. The total loss function is expressed as follows: ; in, Represents the true observation tensor in the normalized domain. Represents the set of trainable parameters. Indicates optional regularization weights; static physical prior hypergraphs are not updated as trainable parameters.
[0057] In a specific embodiment of the present invention, after M deep architecture iterations through the cascaded encoder module, a highly structured representation tensor is obtained. It is decoded back into the physical observation space to generate multi-step predictions.
[0058] Spatiotemporal detoxing: To map a continuously compressed representation over the full expected prediction range T, the latent deep state tensor is projected through a multilayer perceptron acting as a spatiotemporal decoder. To generate physically interpretable values that match actual watershed observations, the normalized predictions are transformed back to the original scaling dimension by reversing the initial Z-score transform: It utilizes the mean and standard deviation of the accurate background space parameters derived from the training baseline.
[0059] During training, mean squared error is used to compare the predicted values with the true values; in an alternative implementation, overfitting is suppressed by weight decay or equivalent L2 regularization of the optimizer.
[0060] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to the method section.
[0061] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A water quality prediction method based on a spatiotemporal dual-view hypergraph neural network, characterized in that, include: Acquire raw hydrological and environmental data of the river network and perform preprocessing; A spatiotemporal dual-view hypergraph neural network model is constructed, wherein the spatiotemporal dual-view hypergraph neural network model includes a heterogeneous spatiotemporal labeling module, a physical prior embedding module, a dynamic hypergraph generation module, a gated cascade encoder module, and a decoding output module connected in sequence, and the spatiotemporal dual-view hypergraph neural network model is trained. The preprocessed raw hydrological environmental data is input into a trained spatiotemporal dual-view hypergraph neural network model to obtain multivariate water quality prediction data for future periods of the river network.
2. The water quality prediction method based on a spatiotemporal dual-view hypergraph neural network according to claim 1, characterized in that, The heterogeneous spatiotemporal labeling module is used to normalize, time-variable projection, factorize spatial-parameter embedding and phase injection of historical water quality observation data of river networks and output the initial feature tensor. The physical prior embedding module constructs a spatial connectivity prior matrix and a parameter coupling network prior matrix based on the preset river network connectivity relationship and water quality parameter coupling rules, and splices the two along the hyperedge dimension to obtain a static physical prior hypergraph; the dynamic hypergraph generation module relies on the intermediate features obtained by the forward operation of the neural network, and adopts a continuous soft allocation mechanism to learn and generate dynamic spatial view hypergraph and dynamic parameter view hypergraph layer by layer. The gated cascade encoder module is used to combine self-attention mechanism and hypergraph convolution operation to extract features of dynamic spatial view hypergraph, dynamic parameter view hypergraph and static physical prior hypergraph respectively, and perform multi-stage fusion through adaptive gating mechanism to complete deep feature encoding; The decoding output module is used to decode the deep feature encoding and restore the original dimensions of the data to obtain multivariate water quality prediction data for future periods of the river network.
3. The water quality prediction method based on a spatiotemporal dual-view hypergraph neural network according to claim 2, characterized in that, The time-variable projection process includes: for the site and water quality parameters Each combination of variables has a length of [length]. The historical backtracking window is mapped to a feature dimension through a learnable time axis projection operation. The formula for a high-dimensional vector space is as follows: ; The time axis projection operation is implemented by a linear mapping or one-dimensional convolution acting on the historical time dimension. and These represent the learnable projection parameters and the bias, respectively. It is a non-linear activation function. Scale the output tensor to the standard hidden dimension, where B represents the batch size. This represents the normalized historical observation sequence of the s-th station and the p-th water quality parameter; The factorized space-parameter embedding is used to generate the site space embedding matrix. and water quality parameter embedding matrix And introduce the broadcast addition operator. By separating these orthogonal control factors, a structurally regularized representation is obtained. The formula is as follows: ; The phase injection is achieved through a sinusoidal encoding function. Standard phase label tensor Injected into the representation space; the phase encoding function is implemented using learnable embedding or sine / cosine encoding, and its expression is as follows: ; Received For the initial feature tensor, In mathematics, the spatial axis and the parameter axis are reconciled into a single global variable dimension. .
4. The water quality prediction method based on a spatiotemporal dual-view hypergraph neural network according to claim 2, characterized in that, The method for constructing the spatial connectivity prior matrix includes: Based on the upstream and downstream connectivity of monitoring stations in the river network, a set C of directional river segments pointing from upstream station u to downstream station d is pre-determined, and each directional river segment is used as a spatial prior hyperedge; (The last part, "m-th", appears to be a separate, unrelated statement and is left as is.) s Preset weights for each directional river segment In implementations that do not differentiate river segment weights, this value is set to 1; where, Indicates a directional river segment index. Indicates the number of prior hyperedges in the space; ; Parameter weights are set for different parameters based on their transport characteristics. ; Combining parameter weights, preset river segment weights, and upstream / downstream directional coefficients, a river segment connecting upstream station u and downstream station d is defined. The formula for assigning asymmetric association weights is as follows: in, and These represent the directional weight coefficients of the upstream and downstream nodes, respectively; in one embodiment, , .
5. A water quality prediction method based on a spatiotemporal dual-view hypergraph neural network according to claim 2, characterized in that, The method for constructing the prior matrix of the parameter-coupled network includes: Establish a parameter coupling coefficient matrix based on the predetermined physicochemical coupling relationship between water quality parameters. ; Set coupling relationship preservation threshold Set the parameter coupling relationship that has not reached the threshold to zero; For each node representing station s and parameter p, its hyperedge relative to the parameter p The degree of correlation is determined by the following formula: ; This indicates that the node corresponding to station s and parameter p is related to the first... The coupling strength of the hyperedge parameter is given by matrix R, where the matrix elements are either preset non-negative coupling strengths or absolute values of correlation coefficients; subsequently, the two priors are concatenated along the hyperedge dimensions: ; in, This indicates the exact number of prior hyperedges in the parametrically coupled network.
6. The water quality prediction method based on a spatiotemporal dual-view hypergraph neural network according to claim 2, characterized in that, The process by which the dynamic hypergraph generation module generates dynamic spatial view hypergraphs and dynamic parametric view hypergraphs includes: Learnable spatial prototype hyperedges and learnable parameter prototype hyperedges are set. The prototype hyperedges are initialized according to a preset random distribution and optimized end-to-end during model training. The temperature scaling continuous correlation mapping formula for the dynamic spatial view is as follows: ; in, , Represents the prototype hyperedge of the learnable space Quantity; The temperature parameter is used to scale and adjust the smoothness of the soft-assigned weight distribution. This is the matrix transpose symbol; based on A parameterized reaction prototype vector The constructed dynamic parameter view hypergraph is used to characterize the dynamic coupling relationship between water quality parameters as the input state changes, as shown in the following formula: ; By stitching hyperedges together, the spatial view and the parametric view are bound into a unified matrix and assembled into a complete data-driven structure component for the m-th encoder layer, as shown in the following formula: 。 7. The water quality prediction method based on a spatiotemporal dual-view hypergraph neural network according to claim 2, characterized in that, The process by which the gated cascade encoder module completes deep feature encoding includes: The initial feature tensor The input is fed into the multi-head self-attention module, which calculates the query Q, key K, and value V matrix and performs attention operations. After layer normalization, the intermediate hidden representation after attention mechanism processing is obtained, as shown in the following expression: ; in, It's about scaling the bottleneck dimension. Then the aggregated attention head is scaled; Hypergraph convolution is performed on the dynamic spatial view hypergraph, the dynamic parameter view hypergraph, the static physical prior hypergraph, and the combined hypergraph, respectively, and the contribution of each branch to the encoding result is controlled by the corresponding adaptive gating factor; each branch can be extracted and fused in parallel, or fused in multiple stages according to a preset order; one multi-stage fusion method is as follows: ; ; ; ; in, , which is the node-by-node gating factor obtained by passing the corresponding branch features through the gating network. A composite hypergraph formed by stitching dynamic and static views along the hyperedge dimension; Final encoder output The following is obtained by fusing self-attention features and hypergraph features using learnable weights: in, and It is a learnable balance coefficient.
8. The water quality prediction method based on a spatiotemporal dual-view hypergraph neural network according to claim 1, characterized in that, When training the spatiotemporal dual-view hypergraph neural network model, mean squared error loss is used in the standardized data domain, and regularization is performed through weight decay. The total loss function is expressed as follows: ; in, Represents the true observation tensor in the normalized domain. Represents the set of trainable parameters. Indicates optional regularization weights; static physical prior hypergraphs are not updated as trainable parameters.
