GNN and Transformer fused sewage treatment prediction method and device and storage medium

The iFEGformer model, which integrates GNN and Transformer, solves the shortcomings of existing sewage treatment prediction models in processing high-dimensional time series data, achieves more accurate sewage treatment predictions, combines the advantages of GNN and Transformer, and improves the prediction performance of the model.

CN120654906AActive Publication Date: 2025-09-16TSINGHUA SHENZHEN INTERNATIONAL GRADUATE SCHOOL +3
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511164229.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-20
Publication Date
2025-09-16
Estimated Expiration
2045-08-20

AI Technical Summary

Technical Problem

Existing sewage treatment prediction models have difficulty capturing long-distance dependencies when processing high-dimensional time series data, and traditional neural networks are ineffective when processing complex spatial structure data, resulting in insufficient accuracy in sewage treatment predictions.

Method used

The iFEGformer model, which is a fusion of GNN and Transformer, is used to predict sewage treatment data by combining GNN and Transformer neural networks through constructing a high-dimensional feature matrix, dimensionality reduction processing, process similarity graph construction and longitudinal feature encoding.

Benefits of technology

The accuracy and robustness of sewage treatment predictions are improved, which can more comprehensively reflect the complexity of the sewage treatment process, fully utilize the advantages of GNN and Transformer, and capture spatial structural characteristics and temporal dependencies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120654906A_ABST
    Figure CN120654906A_ABST
Patent Text Reader

Abstract

The invention provides a GNN and Transform fused sewage treatment prediction method and device and a storage medium, and relates to the field of sewage data analysis and treatment. The method comprises the following steps: acquiring process information of a sewage treatment plant and water inlet and outlet monitoring data arranged according to a time sequence, constructing a high-dimensional feature matrix and carrying out dimension reduction treatment to obtain a sewage dimension reduction feature matrix, then constructing a prediction model, carrying out digital coding on the process information through coding blocks of the model, generating a process similarity graph by using GNN of the model, and carrying out prediction on the process similarity graph. And taking the process similarity graph and the inflow dimensionality reduction feature as input, taking the outflow dimensionality reduction feature as target output, training a Transform of the model, and finally, performing prediction by using the trained model, and outputting outflow prediction data. The prediction model of the invention combines the advantages of GNN and Transform, gives consideration to the dependence of space structure and time sequence, and improves the prediction accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention mainly relates to the field of sewage data analysis and processing, and specifically to a sewage treatment prediction method, device and storage medium integrating GNN and Transformer. Background Art

[0002] At present, urbanization construction has intensified, and sewage treatment plants have entered a period of efficient operation. Sewage treatment plants are facing increasing pressure to meet emission standards. At the same time, enterprises are facing the need to improve quality and efficiency, move towards energy conservation and consumption reduction, and respond to social energy conservation and emission reduction goals.

[0003] In the actual production process of sewage treatment, data may be affected by extreme working conditions and thus exhibit more complex high-dimensional characteristics. Therefore, it is necessary to combine multiple models to enhance its ability to integrate more comprehensive data information.

[0004] A sewage treatment plant is a nonlinear system influenced by numerous factors and composed of multiple nonlinear processes. Sewage inflow, local geographical conditions, and the chemical reaction environment all play a significant role in influencing treatment efficiency. Furthermore, the treatment processes that comprise a sewage treatment system vary significantly in their ability to treat various pollutants. Effective modeling of sewage treatment process systems can help optimize treatment efficiency, improve the urban environment, and ensure compliance with relevant regulatory standards. This provides constructive decision-making support for sewage treatment plant process design, operational plan development, and overall management.

[0005] However, existing forecasting models are mostly based on single machine learning algorithms, such as linear regression and support vector machines. These models have limitations when processing high-dimensional time series data and struggle to capture long-range dependencies within the data. Traditional neural network models (such as recurrent neural networks (RNNs) and their variants, LSTMs and GRUs), while showing some advantages in processing time series data, are less effective when processing data with complex spatial structures. Summary of the Invention

[0006] The technical problem to be solved by the present invention is to address the shortcomings of the existing technology and provide a sewage treatment prediction method, device and storage medium that integrates GNN and Transformer.

[0007] The present invention solves the above technical problems with the following technical solution: a sewage treatment prediction method integrating GNN and Transformer, comprising the following steps: Obtaining process information of the sewage treatment plant and sewage monitoring data in a time series manner from a designated database, wherein the sewage monitoring data includes inlet monitoring data and outlet monitoring data; Constructing a high-dimensional feature matrix based on the inlet monitoring data and the outlet monitoring data, and performing dimensionality reduction processing on the high-dimensional feature matrix to obtain a sewage dimensionality reduction feature matrix, wherein the sewage dimensionality reduction feature matrix includes inlet dimensionality reduction features and outlet dimensionality reduction features; Constructing an iFEGformer sewage treatment prediction model, the iFEGformer sewage treatment prediction model includes a coding block, a GNN graph neural network and a Transformer neural network, digitally encoding the sewage treatment plant process information through the coding block, and performing process similarity processing on the encoded sewage treatment plant process information through the GNN graph neural network to obtain a process similarity graph, and using the process similarity graph and the influent dimensionality reduction features as inputs and the effluent dimensionality reduction features as target outputs, training the Transformer neural network for sewage treatment data prediction to obtain a trained iFEGformer sewage treatment prediction model; Import the inlet monitoring data to be predicted, and use the trained iFEGformer sewage treatment prediction model to predict sewage treatment data on the inlet monitoring data to obtain effluent prediction data.

[0008] Another technical solution of the present invention to solve the above technical problems is as follows: a sewage treatment prediction device integrating GNN and Transformer, comprising: A raw data acquisition module is used to obtain process information of the sewage treatment plant from a designated database and to obtain sewage monitoring data in a time series manner, wherein the sewage monitoring data includes inlet monitoring data and outlet monitoring data; A data preprocessing module is used to construct a high-dimensional feature matrix based on the inlet monitoring data and the outlet monitoring data, and perform dimensionality reduction processing on the high-dimensional feature matrix to obtain a sewage dimensionality reduction feature matrix, wherein the sewage dimensionality reduction feature matrix includes inlet dimensionality reduction features and outlet dimensionality reduction features; A prediction model construction module is used to construct an iFEGformer sewage treatment prediction model, which includes a GNN graph neural network and a Transformer neural network. The sewage treatment plant process information is digitally encoded, and the encoded sewage treatment plant process information is processed by the GNN graph neural network to obtain a process similarity graph. The process similarity graph and the influent dimensionality reduction features are used as inputs, and the effluent dimensionality reduction features are used as target outputs. The Transformer neural network is trained to predict sewage treatment data to obtain a trained iFEGformer sewage treatment prediction model. The prediction module is used to import the water inlet monitoring data to be predicted, and use the trained iFEGformer sewage treatment prediction model to predict sewage treatment data on the water inlet monitoring data to obtain water outlet prediction data.

[0009] Another technical solution of the present invention to solve the above-mentioned technical problems is as follows: a sewage treatment prediction device integrating GNN and Transformer, comprising a memory, a processor, and a computer program stored in the memory and runnable on the processor, characterized in that when the processor executes the computer program, the sewage treatment prediction method integrating GNN and Transformer as described above is implemented.

[0010] Another technical solution of the present invention to solve the above technical problems is as follows: a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the sewage treatment prediction method of the GNN and Transformer fusion as described above.

[0011] The beneficial effects of the present invention are: combining the process information of the sewage treatment plant with the time series sewage monitoring data, and integrating multi-dimensional data, can more comprehensively reflect the complexity of the sewage treatment process and improve the accuracy of the prediction; the proposed iFEGformer model integrates the GNN graph neural network and the Transformer architecture, taking into account both spatial structural characteristics (process similarity) and temporal dependencies (sewage data change trends), giving full play to the advantages of GNN in processing structured data and Transformer in processing time series data, and providing a new technical means for sewage treatment prediction. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] Figure 1 A schematic diagram of the overall process of the sewage treatment prediction method using GNN and Transformer fusion provided in an embodiment of the present invention; Figure 2 A flowchart of the processing process of the iFEGformer neural network model provided by an embodiment of the present invention; Figure 3 A process similarity diagram provided for an embodiment of the present invention; Figure 4 A flowchart of the processing process of the Encoder Block provided in an embodiment of the present invention; Figure 5 This is a functional module block diagram of the sewage treatment prediction device that integrates GNN and Transformer according to an embodiment of the present invention. DETAILED DESCRIPTION

[0013] To make the technical solutions, advantages, and objectives of the present invention more clear, the following will provide a clear and complete description of the technical solutions of the embodiments of the present invention in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Other embodiments obtained by ordinary technicians in this field without creative work are all within the scope of protection of this application.

[0014] Example 1: Figure 1-Figure 2 As shown, the embodiment of the present invention provides a sewage treatment prediction method integrating GNN and Transformer, comprising the following steps: S1. Obtaining process information of a sewage treatment plant and sewage monitoring data in a time series manner from a designated database, wherein the sewage monitoring data includes inlet monitoring data and outlet monitoring data; S2. Constructing a high-dimensional feature matrix based on the inlet monitoring data and the outlet monitoring data, and performing dimensionality reduction processing on the high-dimensional feature matrix to obtain a sewage dimensionality reduction feature matrix, wherein the sewage dimensionality reduction feature matrix includes inlet dimensionality reduction features and outlet dimensionality reduction features; S3. Construct an iFEGformer sewage treatment prediction model, which includes a coding block, a GNN graph neural network, and a Transformer neural network. The coding block is used to digitally encode the sewage treatment plant process information, and the GNN graph neural network is used to perform process similarity processing on the encoded sewage treatment plant process information to obtain a process similarity graph. S4, using the process similarity graph and the inlet dimensionality reduction features as inputs and the outlet dimensionality reduction features as target outputs, training the Transformer neural network for sewage treatment data prediction to obtain a trained iFEGformer sewage treatment prediction model; S5. Import the inlet water monitoring data to be predicted, and use the trained iFEGformer sewage treatment prediction model to perform sewage treatment data prediction on the inlet water monitoring data to obtain effluent prediction data.

[0015] In this embodiment, the multi-dimensional data fusion is combined with the sewage treatment plant process information and time series sewage monitoring data to more comprehensively reflect the complexity of the sewage treatment process and improve the accuracy of the prediction; The proposed iFEGformer model integrates the GNN graph neural network and Transformer architecture, taking into account both spatial structural characteristics (process similarity) and temporal dependencies (sewage data change trends), giving full play to the advantages of GNN in processing structured data and Transformer in processing time series data, and providing a new technical means for sewage treatment prediction.

[0016] Regarding the acquisition of raw data, this example conducts data analysis based on the internal construction conditions of multiple sewage treatment plants. The dataset mainly includes the following contents: Designed daily treatment capacity: the daily sewage treatment capacity of the sewage treatment plant during initial design.

[0017] Current daily processing capacity: the actual daily sewage processing capacity of the sewage treatment plant.

[0018] Current operating load: The ratio of the designed daily treatment capacity to the current daily treatment capacity, which reflects the current carrying load of the sewage treatment plant.

[0019] Emission standards: The water quality standards that the effluent from a sewage treatment plant must meet. Different water plants have different monitoring standards depending on their treatment level.

[0020] Sewage treatment plant process thermal coding: The thermal coding is generated based on the collected process information of each sewage treatment plant. If the process exists in the treatment process, the corresponding item is set to 1, otherwise it is set to 0.

[0021] This example uses a sewage treatment data set from multiple sewage treatment plants as raw data to conduct sewage treatment data analysis. This data set primarily includes various measurement, monitoring, and operational data related to sewage treatment, including the following: Wastewater Flow: Recording wastewater flows from wastewater treatment plants to assess treatment capacity and plan resources; Monitoring time: record the recording time of the data in order to perform position coding of time series data; Wastewater quality: including chemical oxygen demand (COD), ammonia nitrogen (NH3-N), total nitrogen (TN), total phosphorus (TP), and pH value.

[0022] Production and construction marking data: records equipment failure, abnormalities, maintenance and alarm information to help operation and maintenance personnel identify and solve problems in a timely manner.

[0023] Preferably, after obtaining the sewage monitoring data, the method further includes the step of preprocessing the sewage monitoring data: First, the sewage monitoring data from different months of influent monitoring data is merged, as is the effluent monitoring data from different months. Invalid columns in the merged data are removed, i.e., data items not included in the sewage treatment data. Outliers are removed based on production and construction markers: these include missing values, NULL values, negative values, data from abnormal monitoring periods, and data from monitoring instrument failures, maintenance periods, outages, calibration periods, and periods of loss of control. This completes the data cleaning process.

[0024] Next, use The criterion formula calculates the upper limit and lower limit of the water inlet monitoring data and the water outlet monitoring data respectively. The standard formula is: , , in, is the upper limit of the inlet monitoring data or the outlet monitoring data, is the lower limit value of the inlet monitoring data or the lower limit value of the outlet monitoring data, is the predicted value, is the standard deviation; Remove abnormal values ​​of the inlet monitoring data that are greater than the upper limit of the inlet monitoring data, and remove abnormal values ​​of the inlet monitoring data that are less than the lower limit of the inlet monitoring data; remove abnormal values ​​of the outlet monitoring data that are greater than the upper limit of the outlet monitoring data, and remove abnormal values ​​of the outlet monitoring data that are less than the lower limit of the outlet monitoring data; The Lagrange interpolation formula is used to fill missing values ​​in the inlet monitoring data and outlet monitoring data after outlier removal. The Lagrange interpolation formula is: , in, is the interpolation polynomial of the inlet monitoring data or the outlet monitoring data, is the known inlet monitoring data or outlet monitoring data, is a Lagrange basis polynomial. If n is the highest degree of the interpolation polynomial, then , is the independent variable, is the current node independent variable value, are the independent variable values ​​of the remaining nodes; The inlet monitoring data and outlet monitoring data after missing value filling are normalized using the normalization formula, which is: , in, is the mean, is the maximum value of the inlet monitoring data or outlet monitoring data, It is the minimum value of the inlet monitoring data or the outlet monitoring data.

[0025] The data preprocessing process of this embodiment can effectively improve the quality and usability of data by merging data from different months, removing outliers, filling missing values, and normalizing data, providing a more reliable data foundation for subsequent model training. Using the rule formula to calculate the upper and lower limits and eliminate abnormal data can avoid the interference of outliers on model training and improve the robustness of the model; Using the Lagrange interpolation method to fill in missing data can restore the original characteristics of the data to a certain extent and reduce the impact of missing data on the prediction results.

[0026] Specifically, the sewage monitoring data includes inlet monitoring time IN_TIME, inlet production and construction tag IN_TAG, inlet flow IN_FLOW, inlet pH IN_PH, inlet chemical oxygen demand IN_COD, inlet ammonia nitrogen IN_NH, inlet total nitrogen IN_TN, inlet total phosphorus IN_TP, outlet monitoring time OUT_TIME, outlet production and construction tag OUT_TAG, outlet flow OUT_FLOW, outlet pH OUT_PH, outlet chemical oxygen demand OUT_COD, outlet ammonia nitrogen OUT_NH, outlet total nitrogen OUT_TN, and outlet total phosphorus OUT_TP. That is, the high-dimensional feature matrix includes 14-dimensional time series data .

[0027] Constructing a high-dimensional feature matrix based on the water inlet monitoring data and the water outlet monitoring data, and performing dimensionality reduction processing on the high-dimensional feature matrix, including: A high-dimensional feature matrix is ​​constructed based on the water inlet monitoring data and the water outlet monitoring data, which is expressed as ,in, is the number of samples of inlet monitoring data and outlet monitoring data, is a high-dimensional feature number; For high-dimensional feature matrices Each column of high-dimensional features is standardized to obtain the standardized high-dimensional feature matrix : , in, is the mean vector of each column of high-dimensional features, is the standard deviation vector of each column of high-dimensional features, Represented as feature dimension; After normalization, the high-dimensional feature matrix Perform covariance processing to obtain the covariance matrix ,in, , And the covariance matrix Perform eigenvalue decomposition and get ,in, , is the eigenvalue of the high-dimensional feature, and each eigenvalue is sorted in descending order, that is, , is the unit eigenvector corresponding to the eigenvalue, ; Before selection The eigenvectors corresponding to the largest eigenvalues ​​form the projection matrix ,in, , Through the projection matrix After normalization, the high-dimensional feature matrix Perform dimensionality reduction processing to obtain the sewage dimensionality reduction feature matrix, which is expressed as ,in, .

[0028] The dimensionality reduction process of the high-dimensional feature matrix in this embodiment is to reduce the dimensionality of the high-dimensional feature matrix through steps such as standardization, covariance matrix calculation and eigenvalue decomposition, which can effectively reduce the dimension of the data, reduce the computational complexity, and improve the training efficiency of the model; The dimensionality reduction process retains the main characteristic information of the data, which helps to highlight the more valuable features for sewage treatment prediction and further improve the prediction performance of the model; The obtained sewage dimensionality reduction feature matrix is ​​easier to be processed and analyzed by the model, providing a better data structure for the subsequent prediction model construction.

[0029] Preferably, the digital encoding process of the sewage treatment plant process information is performed by the encoding block, including: Obtain the emission standard column corresponding to the process section of the sewage treatment plant from the process information of the sewage treatment plant, and convert the emission standard column into a numerical value, which is expressed as: , If the information in the emission standard column is Level 1 A, it is converted to a value of 1; if the information in the emission standard column is Level 1 B, it is converted to a value of 0.

[0030] The process column corresponding to the process section of the sewage treatment plant is obtained from the process information of the sewage treatment plant, and each treatment process in the process column is encoded using the One-Hot encoding method to obtain a binary matrix : ; For example, if there are three main treatment processes (A, B, C), a three-column binary matrix is ​​generated, with each column corresponding to a process. If a wastewater treatment plant uses process A, the corresponding column has a value of 1, and the other columns have a value of 0.

[0031] Obtain the biochemical pool column corresponding to the process section of the sewage treatment plant from the process information of the sewage treatment plant, encode the biochemical pool column using Label encoding, and generate a numerical vector : , in, ( ) is a label, This column contains information about the biochemical pools used by wastewater treatment plants. A biochemical pool is a biological / chemical reaction pool. This column records the process used by each plant's biochemical pool, such as A2O or CASS. Because there are many different types, labels are used. For example, if there are three biochemical pool types (X, Y, and Z), they are coded as 0, 1, and 2, respectively.

[0032] Define the rows of the Boolean matrix as a sewage treatment plant and the columns of the Boolean matrix as a process stage to obtain the Boolean matrix , and use 、 、 and Construct the Boolean value matrix X of all sewage treatment plants, that is, the process information of the numbered sewage treatment plants: .

[0033] It should be understood that each process section of each plant is represented by a Boolean matrix. Each row of the Boolean matrix corresponds to a sewage treatment plant, and each column corresponds to a process section. If a plant uses a certain process section, the value of the corresponding position is 1, otherwise it is 0; Combine all the processed features mentioned above into a feature matrix X. Each row of the feature matrix X corresponds to a sewage treatment plant, and each column corresponds to a feature.

[0034] In this embodiment, the digital coding process of the sewage treatment plant process information of this embodiment quantifies the process information of the sewage treatment plant (such as emission standards, treatment processes, biochemical pool types, etc.) through digital coding. This allows these non-numerical process information to participate in the model calculation in the form of numerical values, thereby enriching the input features of the model. Digitally encoded process information can more intuitively reflect the process characteristics of the sewage treatment plant, help improve the interpretability of the model, and make it easier for technicians to understand the model's decision-making process; By uniformly encoding the process information of different sewage treatment plants, the model can better learn the commonalities and differences between different processes, thereby improving the generalization ability of data from different sewage treatment plants.

[0035] Preferably, if Figure 2 As shown in the figure, the process similarity processing is performed on the numbered sewage treatment plant process information to obtain a process similarity diagram, including: Graph structure definition: Node: Each sewage treatment plant is a node, and the node feature is the encoded process information matrix X; Edge weight (similarity): Calculates the degree of association between nodes using Euclidean distance and similarity functions.

[0036] Specifically, the sewage treatment plant is used as the node of the graph, and the node is defined and nodes Euclidean distance between : , in, is the feature matrix The number of columns, Define the similarity function : , Constructing the adjacency matrix ,in, Representation node and nodes Similarity between: , Since the graph is undirected, is a symmetric matrix: , Based on similarity Define the message passing function M: , in, is the normalized adjacency matrix, node In the The hidden state of the layer (i.e., feature representation); like Figure 2 As shown, BasisGenerator: Based on the normalized adjacency matrix Constructing a node feature base, a local feature base, and a global feature base, wherein the node feature base is used to extract the features of a single sewage treatment plant, the local feature base is used to capture the connections between the features of each sewage treatment plant, and the global feature base is used to extract the overall features of the graph; The node feature base, local feature base and global feature base are all mapped with linear layer weights of corresponding sizes. Based on the weights corresponding to each feature base, each feature base is accumulated to obtain the process feature matrix, i.e., the process similarity graph (e.g. Figure 3 As shown), the process feature matrix is: , in, is the kth characteristic basis function, is the global eigenvalue basis, is the node feature matrix, For the The weight matrix of the linear layer, is the similarity matrix between nodes, is the weight matrix of the similarity term, In this embodiment, the node feature base uses the following formulas to respectively calculate the original feature Perform row and column standardization. The specific formulas are as follows: , , For dense adjacency matrices or large data sizes, low-rank decomposition can be used for this part. The specific formula is as follows: in, .

[0037] The local feature base generation method first constructs a self-loop, and then according to the set number of message propagation Execute the loop, and perform message passing, difference operation, and normalization operation in sequence within the loop. Specifically, the basis is generated through the above message passing method: , in, is the message passing function, Perform differential operations and generate high-order basis functions through recursive relations. , Perform the standardization operation. The specific formula is as follows: , The global eigenbasis generation method calculates the symmetric normalized Laplace matrix. The specific formula is as follows: , It can also perform low-rank decomposition.

[0038] This embodiment uses the GNN-based process similarity processing to construct a process similarity graph, which can mine the process correlations between different sewage treatment plants. This allows the model to fully utilize this correlation information for learning and prediction, further improving the accuracy and reliability of the prediction. Using GNN to process the process similarity graph fully leverages GNN's advantages in processing graph-structured data and can better capture the complex relationships and mutual influences between sewage treatment plants. By constructing and fusing node feature bases, local feature bases, and global feature bases, a more representative process feature matrix is ​​obtained, providing richer feature information for subsequent Transformer model training.

[0039] Preferably, if Figure 2As shown, the process similarity graph and the influent dimensionality reduction features are used as inputs, and the effluent dimensionality reduction features are used as target outputs. The Transformer neural network is trained to predict sewage treatment data, and the trained iFEGformer sewage treatment prediction model is obtained, including: First, the feature aggregation features of each sewage treatment plant are extracted from the process similarity graph (i.e., the corresponding part of the aggregation information is extracted), and the feature aggregation features and the corresponding influent dimensionality reduction features of each sewage treatment plant are normalized; Specifically, a standardization operation is performed on each input feature, where: is the mean, is the standard value, and the specific formula is as follows: .

[0040] Next, the normalized feature aggregation features of each sewage treatment plant and the influent dimensionality reduction features are encoded using a longitudinal feature encoding method to obtain multiple time series features. The multiple time series features are used as the input of the Encoder encoding block of the Transformer neural network, and the effluent dimensionality reduction features are used as the target output. The Transformer neural network is trained for sewage treatment data prediction to obtain the trained iFEGformer sewage treatment prediction model.

[0041] In this embodiment, vertical feature encoding is performed, including the following steps: transposing input dimensions, transposing covariates, concatenating covariates, performing linear transformation, and Dropout. Specifically: Transpose the input dimension and move the time step dimension (T) to the end to facilitate subsequent feature processing by variables (V). The specific formula is as follows: , If there are covariates ((C) is the covariate dimension): , Splicing covariates, merging covariates (such as timestamps and seasonal features) into original features, enhances the model's ability to capture complex patterns. The specific formula is as follows: , Perform a linear mapping to map features to The specific formula is as follows: , Dropout is the process of randomly setting parameters to zero with a set probability.

[0042] The training process of the Transformer neural network in this embodiment, through longitudinal feature encoding and Encoder coding block processing, can fully extract the time series features in the influent dimensionality reduction features, so that the model can better capture the patterns and trends in the time series data, thereby improving the prediction ability of indicators such as effluent water quality; Using the process similarity graph and influent dimensionality reduction features as input and the effluent dimensionality reduction features as the target output for training, the Transformer neural network can better learn the input-output relationship in the sewage treatment process, optimize the model's parameters and structure, and improve the model's predictive performance. It achieves end-to-end learning from input data to prediction results, reduces reliance on manual feature engineering, and improves the automation and adaptability of the model.

[0043] Preferably, if Figure 4 As shown, the training of the Transformer neural network for sewage treatment data prediction includes: The encoder block consists of multiple encoder blocks, each of which primarily contains two sublayers: a full attention layer and a feed-forward neural network (FFN). The full attention layer allows the model to focus on all positions in the input sequence at each time step, dynamically assigning weights to capture key information. The feed-forward neural network (FFN) enhances the model's expressive power through nonlinear transformations, capturing complex relationships between features.

[0044] Specifically, the processing process of the Encoder Block is as follows: The output of layer n-1 As the input of the nth layer , calculate the attention weight through the full attention mechanism: , Among them, Q is the query matrix, K is the key matrix, and V is the value matrix. is the dimension of the key vector; Perform nonlinear transformation on multiple time series features through feedforward neural network and attention weights: , in, It is a feedforward neural network; The feedforward neural network layer (FFN) also includes a Dropout layer, which is used to randomly discard some neurons to prevent overfitting.

[0045] Next, each time series feature after nonlinear transformation is mapped to the prediction length, which is expressed as: , in, , is the weight matrix, is the bias term; The dimensions of each time series feature after mapping are transposed back to the original dimension, and the distribution of the original data is restored by activating the eucalyptus tree, which is expressed as: , in, is the decoder output, For the original input The standard deviation of For the original input The mean of .

[0046] In this embodiment, the Transformer neural network training process calculates attention weights through the full attention mechanism, enabling the model to dynamically focus on the more important parts of the input sequence, capture long-range dependencies, and further improve the modeling ability of time series features. Using a feedforward neural network to perform nonlinear transformation on time series features and mapping the transformed features to the prediction length can better extract useful information from the features and improve the model's expressiveness and prediction accuracy. Applying residual connections and layer normalization in each Encoder Block helps alleviate the gradient vanishing problem in deep networks, stabilizes the training process, and improves the training efficiency and performance of the model.

[0047] Finally, the loss assessment results of the three loss assessment methods are provided to prove the effectiveness of the model. Specifically: Set the outflow data as the output target of the model; The dataset is divided into training set and test set for training and validating the iFEGformer neural network model; The dataset is sewage treatment time series data; Configure the loss function and optimizer of the iFEGformer neural network model.

[0048] The iFEGformer neural network model is trained to evaluate the prediction accuracy using the following three evaluation indicators: MSE mean square error, RMSE root mean square error, and MAE mean absolute error. , , , Among them, m is the output data dimension, is the true value, Output the mean of the series for the model.

[0049] The iFEGformer neural network model has demonstrated outstanding performance in wastewater treatment data forecasting, demonstrating its superiority in both accuracy and robustness, as assessed by MSE, RMSE, and MAE. The model is capable of effectively processing high-dimensional time series data and, combined with graph neural networks and the Transformer architecture, provides powerful technical support for the operation and management of wastewater treatment plants.

[0050] Example 2: Figure 5 As shown, the embodiment of the present invention also provides a sewage treatment prediction device integrating GNN and Transformer, including: A raw data acquisition module is used to obtain process information of the sewage treatment plant from a designated database and to obtain sewage monitoring data in a time series manner, wherein the sewage monitoring data includes inlet monitoring data and outlet monitoring data; A data preprocessing module is used to construct a high-dimensional feature matrix based on the inlet monitoring data and the outlet monitoring data, and perform dimensionality reduction processing on the high-dimensional feature matrix to obtain a sewage dimensionality reduction feature matrix, wherein the sewage dimensionality reduction feature matrix includes inlet dimensionality reduction features and outlet dimensionality reduction features; A prediction model construction module is used to construct an iFEGformer sewage treatment prediction model, which includes a GNN graph neural network and a Transformer neural network. The sewage treatment plant process information is digitally encoded, and the encoded sewage treatment plant process information is processed by the GNN graph neural network to obtain a process similarity graph. The process similarity graph and the influent dimensionality reduction features are used as inputs, and the effluent dimensionality reduction features are used as target outputs. The Transformer neural network is trained to predict sewage treatment data to obtain a trained iFEGformer sewage treatment prediction model. The prediction module is used to import the water inlet monitoring data to be predicted, and use the trained iFEGformer sewage treatment prediction model to predict sewage treatment data on the water inlet monitoring data to obtain water outlet prediction data.

[0051] Example 3: An embodiment of the present invention also provides a sewage treatment prediction device that integrates GNN and Transformer, including a memory, a processor, and a computer program stored in the memory and runnable on the processor. When the processor executes the computer program, the sewage treatment prediction method that integrates GNN and Transformer as described above is implemented.

[0052] Example 4: An embodiment of the present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the sewage treatment prediction method of the GNN and Transformer fusion as described above is implemented.

[0053] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus.

[0054] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0055] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of units is merely a logical functional division. In actual implementation, other division methods may be used, such as combining or integrating multiple units or components into another system, or ignoring or not implementing certain features.

[0056] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected based on actual needs to achieve the objectives of the embodiments of the present invention.

[0057] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0058] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or all or part 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 for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the various embodiments of the method of the present invention. The aforementioned storage medium includes various media that can store program code, such as USB flash drives, mobile hard drives, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical disks.

[0059] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A sewage treatment prediction method integrating GNN and Transformer, characterized in that: The steps include: Obtaining process information of the sewage treatment plant and sewage monitoring data in a time series manner from a designated database, wherein the sewage monitoring data includes inlet monitoring data and outlet monitoring data; Constructing a high-dimensional feature matrix based on the inlet monitoring data and the outlet monitoring data, and performing dimensionality reduction processing on the high-dimensional feature matrix to obtain a sewage dimensionality reduction feature matrix, wherein the sewage dimensionality reduction feature matrix includes inlet dimensionality reduction features and outlet dimensionality reduction features; Constructing an iFEGformer sewage treatment prediction model, the iFEGformer sewage treatment prediction model includes a coding block, a GNN graph neural network, and a Transformer neural network. The coding block digitally encodes the sewage treatment plant process information, and the GNN graph neural network performs process similarity processing on the encoded sewage treatment plant process information to obtain a process similarity graph. Using the process similarity graph and the influent dimensionality reduction features as inputs and the effluent dimensionality reduction features as target outputs, the Transformer neural network is trained to predict sewage treatment data, thereby obtaining a trained iFEGformer sewage treatment prediction model; Import the inlet monitoring data to be predicted, and use the trained iFEGformer sewage treatment prediction model to predict sewage treatment data on the inlet monitoring data to obtain effluent prediction data.

2. The sewage treatment prediction method according to claim 1, characterized in that: After obtaining the sewage monitoring data, the method further includes the step of performing data preprocessing on the sewage monitoring data: Merging the inlet monitoring data of different months and the outlet monitoring data of different months in the sewage monitoring data; use The criterion formula calculates the upper limit and lower limit of the water inlet monitoring data and the water outlet monitoring data respectively. The standard formula is: , , in, is the upper limit of the inlet monitoring data or the outlet monitoring data, is the lower limit value of the inlet monitoring data or the lower limit value of the outlet monitoring data, is the predicted value, is the standard deviation, Remove abnormal values ​​of the inlet monitoring data that are greater than the upper limit of the inlet monitoring data, and remove abnormal values ​​of the inlet monitoring data that are less than the lower limit of the inlet monitoring data; remove abnormal values ​​of the outlet monitoring data that are greater than the upper limit of the outlet monitoring data, and remove abnormal values ​​of the outlet monitoring data that are less than the lower limit of the outlet monitoring data; The Lagrange interpolation formula is used to fill missing values ​​in the inlet monitoring data and outlet monitoring data after outlier removal. The Lagrange interpolation formula is: , in, is the interpolation polynomial of the inlet monitoring data or the outlet monitoring data, is the known inlet monitoring data or outlet monitoring data, is a Lagrange basis polynomial. If n is the highest degree of the interpolation polynomial, then , is the independent variable, is the current node independent variable value, are the independent variable values ​​of the remaining nodes; The inlet monitoring data and outlet monitoring data after missing value filling are normalized using the normalization formula, which is: , in, is the mean, is the standard deviation, is the maximum value of the inlet monitoring data or outlet monitoring data, It is the minimum value of the inlet monitoring data or the outlet monitoring data.

3. The sewage treatment prediction method according to claim 1, characterized in that: Constructing a high-dimensional feature matrix based on the water inlet monitoring data and the water outlet monitoring data, and performing dimensionality reduction processing on the high-dimensional feature matrix, including: A high-dimensional feature matrix is ​​constructed based on the water inlet monitoring data and the water outlet monitoring data, which is expressed as ,in, is the number of samples of inlet monitoring data and outlet monitoring data, is a high-dimensional feature number; For high-dimensional feature matrices Each column of high-dimensional features is standardized to obtain the standardized high-dimensional feature matrix : , in, is the mean vector of each column of high-dimensional features, is the standard deviation vector of each column of high-dimensional features, Represented as feature dimension; After normalization, the high-dimensional feature matrix Perform covariance processing to obtain the covariance matrix ,in, , And the covariance matrix Perform eigenvalue decomposition and get ,in, , is the eigenvalue of the high-dimensional feature, and each eigenvalue is sorted in descending order, that is, , is the unit eigenvector corresponding to the eigenvalue, ; Before selection The eigenvectors corresponding to the largest eigenvalues ​​form the projection matrix ,in, ; Through the projection matrix After normalization, the high-dimensional feature matrix Perform dimensionality reduction processing to obtain the sewage dimensionality reduction feature matrix, which is expressed as ,in, .

4. The sewage treatment prediction method according to claim 1, characterized in that: The digital coding process of the sewage treatment plant process information is performed by the coding block, including: Obtain the emission standard column corresponding to the process section of the sewage treatment plant from the process information of the sewage treatment plant, and convert the emission standard column into a numerical value, which is expressed as: , If the information in the emission standard column is Level 1 A, it is converted to a value of 1; if the information in the emission standard column is Level 1 B, it is converted to a value of 0; The process column corresponding to the process section of the sewage treatment plant is obtained from the process information of the sewage treatment plant, and each treatment process in the process column is encoded using the One-Hot encoding method to obtain a binary matrix : ; Obtain the biochemical pool column corresponding to the process section of the sewage treatment plant from the process information of the sewage treatment plant, encode the biochemical pool column using Label encoding, and generate a numerical vector : , in, ( ) is a label, Information on biochemical pools used in sewage treatment plants; Define the rows of the Boolean matrix as a sewage treatment plant and the columns of the Boolean matrix as a process stage to obtain the Boolean matrix , and use 、 、 and Construct the Boolean value matrix X of all sewage treatment plants, that is, the process information of the numbered sewage treatment plants: 。 5. The sewage treatment prediction method according to claim 4, characterized in that: Based on the GNN graph neural network, the encoded sewage treatment plant process information is processed for process similarity to obtain a process similarity graph, including: Take the sewage treatment plant as the node of the graph and define the node and nodes Euclidean distance between : , in, is the feature matrix The number of columns, Define the similarity function : , Constructing the adjacency matrix ,in, Representation node and nodes Similarity between: , Since the graph is undirected, is a symmetric matrix: , Based on similarity Define the message passing function: , in, is the normalized adjacency matrix, node In the The hidden state of the layer; Based on the normalized adjacency matrix Constructing a node feature base, a local feature base, and a global feature base, wherein the node feature base is used to extract the features of a single sewage treatment plant, the local feature base is used to capture the relationship between the features of each sewage treatment plant, and the global feature base is used to extract the overall features of the graph; Linear layer mapping weights of corresponding sizes are used for node feature bases, local feature bases, and global feature bases. Based on the weights corresponding to each feature base, each feature base is accumulated to obtain a process feature matrix, i.e., a process similarity graph. The process feature matrix is: , in, is the kth characteristic basis function, is the global eigenvalue basis, is the node feature matrix, For the The weight matrix of the linear layer, is the similarity matrix between nodes, is the weight matrix of the similarity term.

6. The sewage treatment prediction method according to claim 4, characterized in that: The process similarity graph and the influent dimensionality reduction features are used as inputs, and the effluent dimensionality reduction features are used as target outputs. The Transformer neural network is trained to predict sewage treatment data, and a trained iFEGformer sewage treatment prediction model is obtained, including: Extracting feature aggregation features of each sewage treatment plant from the process similarity graph, and normalizing each feature aggregation feature and the influent dimensionality reduction features corresponding to each sewage treatment plant; Through the vertical feature coding method, the normalized feature aggregation features of each sewage treatment plant and the influent dimensionality reduction features are encoded to obtain multiple time series features. The multiple time series features are used as the input of the Encoder coding block of the Transformer neural network, and the effluent dimensionality reduction features are used as the target output. The Transformer neural network is trained for sewage treatment data prediction to obtain the trained iFEGformer sewage treatment prediction model.

7. The sewage treatment prediction method according to claim 6, characterized in that: The Transformer neural network is trained to predict sewage treatment data, including: The Encoder block consists of multiple Encoder Blocks. The processing process of each Encoder Block is as follows: The output of layer n-1 As the input of the nth layer , calculate the attention weight through the full attention mechanism: , Among them, Q is the query matrix, K is the key matrix, and V is the value matrix. is the dimension of the key vector; Perform nonlinear transformation on multiple time series features through feedforward neural network and attention weights: , in, It is a feedforward neural network; Mapping each time series feature after nonlinear transformation to the prediction length is expressed as: , in, , is the weight matrix, is the bias term; The dimensions of each time series feature after mapping are transposed back to the original dimension, and the distribution of the original data is restored by activating the eucalyptus tree, which is expressed as: , in, is the decoder output, For the original input The standard deviation of For the original input The mean of .

8. A sewage treatment prediction device integrating GNN and Transformer, characterized in that: include: A raw data acquisition module is used to obtain process information of the sewage treatment plant from a designated database and to obtain sewage monitoring data in a time series manner, wherein the sewage monitoring data includes inlet monitoring data and outlet monitoring data; A data preprocessing module is used to construct a high-dimensional feature matrix based on the inlet monitoring data and the outlet monitoring data, and perform dimensionality reduction processing on the high-dimensional feature matrix to obtain a sewage dimensionality reduction feature matrix, wherein the sewage dimensionality reduction feature matrix includes inlet dimensionality reduction features and outlet dimensionality reduction features; A prediction model construction module is used to construct an iFEGformer sewage treatment prediction model, wherein the iFEGformer sewage treatment prediction model includes a coding block, a GNN graph neural network, and a Transformer neural network. The coding block is used to digitally encode the sewage treatment plant process information, and the GNN graph neural network is used to perform process similarity processing on the encoded sewage treatment plant process information to obtain a process similarity graph. The process similarity graph and the influent dimensionality reduction features are used as inputs, and the effluent dimensionality reduction features are used as target outputs. The Transformer neural network is trained to predict sewage treatment data to obtain a trained iFEGformer sewage treatment prediction model. The prediction module is used to import the water inlet monitoring data to be predicted, and use the trained iFEGformer sewage treatment prediction model to predict sewage treatment data on the water inlet monitoring data to obtain water outlet prediction data.

9. A sewage treatment prediction device integrating GNN and Transformer, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the sewage treatment prediction method of the GNN and Transformer fusion as described in any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium storing a computer program, which, when executed by a processor, implements the sewage treatment prediction method of the GNN and Transformer fusion as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Outlet water COD (Chemical Oxygen Demand) prediction method based on mixed attention mechanism and codec

    CN119397491A

  • Sewage flow prediction method and device, electronic equipment and computer storage medium

    CN120355013A