A sewage treatment prediction method and device based on GNN and transformer fusion and a storage medium

The iFEGformer model, which integrates GNN and Transformer, solves the problem that existing wastewater treatment prediction models struggle to capture long-distance dependencies in high-dimensional time series data, achieving more accurate wastewater treatment prediction and improving the model's adaptability and interpretability.

CN120654906BActive Publication Date: 2025-11-18TSINGHUA 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
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-20
Publication Date
2025-11-18
Estimated Expiration
2045-08-20

AI Technical Summary

Technical Problem

Existing wastewater treatment prediction models are mostly based on a single machine learning algorithm, which makes it difficult to effectively capture long-distance dependencies and complex spatial structures in high-dimensional time series data, resulting in insufficient accuracy in wastewater treatment prediction.

Method used

The iFEGformer model, which integrates GNN and Transformer, is used to perform end-to-end wastewater treatment prediction by constructing a high-dimensional feature matrix, performing dimensionality reduction, generating a process similarity graph, and encoding vertical features, combined with wastewater treatment plant process information and time series data.

Benefits of technology

It improves the accuracy and robustness of wastewater treatment prediction, can more comprehensively reflect the complexity of the wastewater treatment process, takes into account both spatial structural features and temporal dependencies, and enhances the predictive performance of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120654906B_ABST
    Figure CN120654906B_ABST
Patent Text Reader

Abstract

The application provides a sewage treatment prediction method and device combining GNN and a transformer and a storage medium, relates to the field of sewage data analysis and processing; process information of a sewage treatment plant and influent and effluent monitoring data arranged in a time sequence are acquired, a high-dimensional feature matrix is constructed and dimension reduction processing is performed, a sewage dimension reduction feature matrix is obtained, then, a prediction model is constructed, process information is digitally encoded through an encoding block of the model, a process similarity graph is generated by GNN of the model, the process similarity graph and the influent dimension reduction feature are used as input, and the effluent dimension reduction feature is used as target output, the transformer of the model is trained, finally, the trained model is used for prediction, and effluent prediction data is output. The prediction model combines the advantages of GNN and the transformer, takes into account spatial structure and time sequence dependence, and improves prediction accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention mainly relates to the field of wastewater data analysis and processing, specifically to a wastewater treatment prediction method, device, and storage medium that integrates GNN and Transformer. Background Technology

[0002] Currently, with the intensification of urbanization, sewage treatment plants are entering a period of high-efficiency operation. However, these plants are facing increasing pressure to meet emission standards, while also needing to improve their quality and efficiency, and develop towards energy conservation and emission reduction to meet societal energy conservation and emission reduction goals.

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

[0004] Wastewater treatment plants are nonlinear systems influenced by various factors and consisting of multiple nonlinear processes. Wastewater inflow conditions, local geographical conditions, and the environment in which chemical reactions occur are all important factors affecting wastewater treatment efficiency. Furthermore, the treatment processes within the wastewater treatment system have significantly different treatment capacities for various pollutants. Effective modeling of wastewater treatment process systems helps to further optimize wastewater treatment efficiency, improve the urban environment, and comply with relevant monitoring standards, thereby providing constructive decision-making support for the process design, operation plan development, and overall management of wastewater treatment plants.

[0005] However, existing predictive 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-distance dependencies in the data. Traditional neural network models (such as recurrent neural networks (RNNs) and their variants LSTM and GRU) have shown certain advantages in processing time series data, but they perform poorly when dealing with data with complex spatial structures. Summary of the Invention

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

[0007] The technical solution of this invention to solve the above-mentioned technical problems is as follows: A wastewater treatment prediction method integrating GNN and Transformer, comprising the following steps:

[0008] The wastewater treatment plant process information is obtained from a designated database, and wastewater monitoring data is obtained in a time-series manner. The wastewater monitoring data includes influent monitoring data and effluent monitoring data.

[0009] A high-dimensional feature matrix is ​​constructed based on the influent monitoring data and the effluent monitoring data, and the high-dimensional feature matrix is ​​then subjected to dimensionality reduction processing to obtain a wastewater dimensionality-reduced feature matrix, which includes influent dimensionality-reduced features and effluent dimensionality-reduced features.

[0010] An iFEGformer wastewater treatment prediction model is constructed, comprising an encoding block, a GNN graph neural network, and a Transformer neural network. The encoding block performs digital encoding on the wastewater treatment plant process information, and the GNN graph neural network performs process similarity processing on the encoded wastewater treatment plant process information to obtain a process similarity map. The process similarity map and the influent dimensionality reduction features are used as inputs, and the effluent dimensionality reduction features are used as the target output to train the Transformer neural network for wastewater treatment data prediction, resulting in the trained iFEGformer wastewater treatment prediction model.

[0011] Import the influent monitoring data to be predicted, and use the trained iFEGformer wastewater treatment prediction model to predict the wastewater treatment data to obtain the effluent prediction data.

[0012] Another technical solution of the present invention to solve the above-mentioned technical problems is as follows: A wastewater treatment prediction device integrating GNN and Transformer, comprising:

[0013] The raw data acquisition module is used to acquire wastewater treatment plant process information from a specified database and to acquire wastewater monitoring data in a time-series manner. The wastewater monitoring data includes influent monitoring data and effluent monitoring data.

[0014] The data preprocessing module is used to construct a high-dimensional feature matrix based on the influent monitoring data and the effluent monitoring data, and to perform dimensionality reduction processing on the high-dimensional feature matrix to obtain a wastewater dimensionality-reduced feature matrix, wherein the wastewater dimensionality-reduced feature matrix includes influent dimensionality-reduced features and effluent dimensionality-reduced features.

[0015] The prediction model construction module is used to construct the iFEGformer wastewater treatment prediction model. The iFEGformer wastewater treatment prediction model includes a GNN graph neural network and a Transformer neural network. The wastewater treatment plant process information is digitally encoded, and the GNN graph neural network is used to perform process similarity processing on the encoded wastewater treatment plant process information to obtain a process similarity map. The process similarity map and the influent dimensionality reduction features are used as inputs, and the effluent dimensionality reduction features are used as the target output to train the Transformer neural network for wastewater treatment data prediction, resulting in the trained iFEGformer wastewater treatment prediction model.

[0016] The prediction module is used to import the influent monitoring data to be predicted, and use the trained iFEGformer wastewater treatment prediction model to predict the wastewater treatment data to obtain the effluent prediction data.

[0017] Another technical solution of the present invention to solve the above-mentioned technical problems is as follows: a wastewater treatment prediction device that integrates 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, it implements the wastewater treatment prediction method that integrates GNN and Transformer as described above.

[0018] Another technical solution of the present invention to solve the above-mentioned technical problems is as follows: a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the wastewater treatment prediction method that integrates GNN and Transformer as described above.

[0019] The beneficial effects of this invention are: by combining wastewater treatment plant process information with time-series wastewater monitoring data, multi-dimensional data fusion can more comprehensively reflect the complexity of the wastewater treatment process and improve the accuracy of prediction; the proposed iFEGformer model integrates GNN graph neural network and Transformer architecture, taking into account both spatial structural features (process similarity) and temporal dependencies (wastewater data change trends), giving full play to the advantages of GNN in processing structured data and Transformer in processing time-series data, providing a new technical means for wastewater treatment prediction. Attached Figure Description

[0020] Figure 1 A schematic diagram of the overall process of the wastewater treatment prediction method that integrates GNN and Transformer provided in an embodiment of the present invention;

[0021] Figure 2 A flowchart illustrating the processing procedure of the iFEGformer neural network model provided in this embodiment of the invention;

[0022] Figure 3 A process similarity diagram provided for embodiments of the present invention;

[0023] Figure 4 A flowchart illustrating the processing procedure of the Encoder Block provided in this embodiment of the invention;

[0024] Figure 5 This is a functional block diagram of a wastewater treatment prediction device that integrates GNN and Transformer, provided in an embodiment of the present invention. Detailed Implementation

[0025] To make the technical solutions, advantages, and objectives of the present invention clearer, 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, not all, embodiments of the present invention. Other embodiments obtained by those skilled in the art without creative effort are all within the protection scope of this application.

[0026] Example 1: As Figures 1-2 As shown in the figure, this invention provides a wastewater treatment prediction method that integrates GNN and Transformer, including the following steps:

[0027] S1. Obtain wastewater treatment plant process information from a designated database and obtain wastewater monitoring data in a time-series manner, wherein the wastewater monitoring data includes influent monitoring data and effluent monitoring data;

[0028] S2. Construct a high-dimensional feature matrix based on the influent monitoring data and the effluent monitoring data, and perform dimensionality reduction processing on the high-dimensional feature matrix to obtain a wastewater dimensionality-reduced feature matrix, wherein the wastewater dimensionality-reduced feature matrix includes influent dimensionality-reduced features and effluent dimensionality-reduced features.

[0029] S3. Construct the iFEGformer wastewater treatment prediction model, which includes an encoding block, a GNN graph neural network, and a Transformer neural network. The encoding block is used to digitally encode the process information of the wastewater treatment plant, and the GNN graph neural network is used to perform process similarity processing on the encoded wastewater treatment plant process information to obtain a process similarity map.

[0030] S4. Using the process similarity map and the influent dimensionality reduction features as inputs and the effluent dimensionality reduction features as the target output, train the Transformer neural network to predict wastewater treatment data, and obtain the trained iFEGformer wastewater treatment prediction model.

[0031] S3. Import the influent monitoring data to be predicted, and use the trained iFEGformer wastewater treatment prediction model to predict the wastewater treatment data to obtain the effluent prediction data.

[0032] In this embodiment, by combining wastewater treatment plant process information with time-series wastewater monitoring data, multi-dimensional data fusion can more comprehensively reflect the complexity of the wastewater treatment process and improve the accuracy of prediction.

[0033] The proposed iFEGformer model integrates GNN (Graph Neural Network) and Transformer architecture, taking into account both spatial structural features (process similarity) and temporal dependencies (wastewater data change trends). It fully leverages the advantages of GNN in processing structured data and Transformer in processing time series data, providing a new technical means for wastewater treatment prediction.

[0034] Regarding the acquisition of raw data, this embodiment combines data analysis with the internal construction of multiple wastewater treatment plants. The dataset mainly includes the following:

[0035] Design daily treatment capacity: The daily sewage treatment capacity of the sewage treatment plant at the initial design stage.

[0036] Current daily treatment capacity: The daily sewage treatment capacity of this sewage treatment plant in actual use.

[0037] Current operating load: The ratio of the designed daily treatment capacity to the current daily treatment capacity, reflecting the current operating load of the wastewater treatment plant.

[0038] Discharge standards: Water quality standards that wastewater treatment plant effluent must meet. Different water plants have different monitoring standards depending on their treatment level.

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

[0040] This embodiment combines wastewater treatment datasets from multiple wastewater treatment plants as raw data for wastewater treatment data analysis. These datasets primarily contain various measurement, monitoring, and operational data related to wastewater treatment, including the following:

[0041] Wastewater flow: Record the wastewater flow rate of the wastewater treatment plant to assess treatment capacity and plan resources;

[0042] Monitoring time: Records the time when the data was recorded in order to perform location encoding of the time series data;

[0043] Wastewater quality includes chemical oxygen demand (COD), ammonia nitrogen (NH3-N), total nitrogen (TN), total phosphorus (TP), and pH value.

[0044] Production and construction data recording: Records equipment malfunctions, anomalies, maintenance, and alarm information to help maintenance personnel identify and resolve problems in a timely manner.

[0045] Preferably, after acquiring the wastewater monitoring data, the method further includes a data preprocessing step for the wastewater monitoring data:

[0046] First, the influent monitoring data from different months and the effluent monitoring data from different months in the wastewater monitoring data are merged. Invalid columns, i.e., data items not included in the aforementioned wastewater treatment data, are removed from the merged data. Outliers are then removed based on production and construction markers: these outliers include missing values, NULL values, negative values, data from abnormal monitoring periods, and data from periods when the monitoring instrument is malfunctioning, under maintenance, shut down, undergoing calibration, or out of control. This completes the data cleaning process.

[0047] Next, using The criterion formulas calculate the upper and lower limits of the influent and effluent monitoring data, respectively. The criterion is:

[0048] ,

[0049] ,

[0050] in, This refers to the upper limit of influent monitoring data or the upper limit of effluent monitoring data. This refers to the lower limit of influent monitoring data or the lower limit of effluent monitoring data. For predicted values, Standard deviation;

[0051] Abnormal values ​​of influent monitoring data that are greater than the upper limit of the influent monitoring data and abnormal values ​​of influent monitoring data that are less than the lower limit of the influent monitoring data are removed; and abnormal values ​​of effluent monitoring data that are greater than the upper limit of the effluent monitoring data and abnormal values ​​of effluent monitoring data that are less than the lower limit of the effluent monitoring data are removed.

[0052] Missing values ​​in the influent and effluent monitoring data after outlier removal were imputed using Lagrange interpolation. The Lagrange interpolation formula is as follows:

[0053] ,

[0054] in, For the interpolation polynomial of influent or effluent monitoring data, For known influent or effluent monitoring data, Let n be a Lagrange polynomial, and n be the highest degree of the interpolation polynomial. , As the independent variable, The value of the current node's independent variable. The values ​​of the independent variables for the remaining nodes;

[0055] The influent and effluent monitoring data after missing value imputation were normalized using a normalization formula, which is:

[0056] ,

[0057] in, The mean, The maximum value among the influent or effluent monitoring data. It is the minimum value among the influent or effluent monitoring data.

[0058] The data preprocessing process in this embodiment, through steps such as merging data from different months, removing outliers, filling in missing values, and normalization, can effectively improve the quality and usability of the data, providing a more reliable data foundation for subsequent model training.

[0059] By using criteria to calculate upper and lower limits and removing outliers, we can avoid the interference of outliers on model training and improve the robustness of the model.

[0060] Using Lagrange interpolation 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.

[0061] Specifically, the wastewater monitoring data includes influent monitoring time (IN_TIME), influent production and construction marker (IN_TAG), influent flow rate (IN_FLOW), influent pH (IN_PH), influent chemical oxygen demand (IN_COD), influent ammonia nitrogen (IN_NH), influent total nitrogen (IN_TN), and influent total phosphorus (IN_TP); effluent monitoring time (OUT_TIME), effluent production and construction marker (OUT_TAG), effluent flow rate (OUT_FLOW), effluent pH (OUT_PH), effluent chemical oxygen demand (OUT_COD), effluent ammonia nitrogen (OUT_NH), effluent total nitrogen (OUT_TN), and effluent total phosphorus (OUT_TP). In other words, the high-dimensional feature matrix includes 14-dimensional time series data. .

[0062] A high-dimensional feature matrix is ​​constructed based on the influent monitoring data and the effluent monitoring data, and the high-dimensional feature matrix is ​​then subjected to dimensionality reduction processing, including:

[0063] A high-dimensional feature matrix is ​​constructed based on the influent monitoring data and the effluent monitoring data, represented as follows: ,in, This refers to the sample size for influent and effluent monitoring data. It represents the number of high-dimensional features;

[0064] For high-dimensional feature matrices Each column of high-dimensional features is standardized to obtain a standardized high-dimensional feature matrix. :

[0065] ,

[0066] in, This is the mean vector of each column of high-dimensional features. The standard deviation vector of each column of high-dimensional features. Represented as feature dimension;

[0067] For the standardized high-dimensional feature matrix Covariance processing is performed to obtain the covariance matrix. ,in, ,

[0068] And for the covariance matrix Perform eigenvalue decomposition to obtain ,in, , These are the feature values ​​of the high-dimensional features, and the feature values ​​are sorted in descending order. , For each eigenvalue, there is a unit eigenvector. ;

[0069] Before choosing The eigenvectors corresponding to the largest eigenvalues ​​form the projection matrix. ,in, ,

[0070] Through projection matrix For the standardized high-dimensional feature matrix Dimensionality reduction is performed to obtain the wastewater dimension-reduced feature matrix, represented as follows: ,in, .

[0071] The dimensionality reduction process of the high-dimensional feature matrix in this embodiment reduces the dimensionality of the high-dimensional feature matrix through steps such as standardization, covariance matrix calculation and eigenvalue decomposition. This can effectively reduce the dimensionality of the data, reduce computational complexity and improve the training efficiency of the model.

[0072] The dimensionality reduction process preserves the main feature information of the data, which helps to highlight the features that are more valuable for wastewater treatment prediction and further improves the predictive performance of the model.

[0073] The resulting wastewater dimensionality-reduced feature matrix is ​​easier for the model to process and analyze, providing a better data structure for subsequent prediction model construction.

[0074] Preferably, the process information of the wastewater treatment plant is digitally encoded using the encoding block, including:

[0075] The emission standard column corresponding to the process section of the wastewater treatment plant is obtained from the wastewater treatment plant process information, and the emission standard column is converted into a numerical type and represented as follows:

[0076] ,

[0077] in, This provides the original emission standard information corresponding to the process section of the i-th wastewater treatment plant. for The numerical result after digital encoding will be converted to the value 1 if the information in the emission standard column is Level A, and to the value 0 if the information in the emission standard column is Level B.

[0078] The process treatment columns corresponding to the process segments of the wastewater treatment plant are obtained from the wastewater treatment plant process information. Each treatment process in the process treatment column is encoded using the One-Hot encoding method to obtain a binary matrix. :

[0079] ;

[0080] Where i-th represents the i-th wastewater treatment plant and j-th represents the j-th treatment process;

[0081] For example, if there are three main treatment processes (A, B, C), a three-column binary matrix is ​​generated, with each column corresponding to one process. If a wastewater treatment plant uses process A, the value of that column is 1, and the values ​​of the other columns are 0.

[0082] The biological treatment tank column corresponding to the process section of the wastewater treatment plant is obtained from the wastewater treatment plant process information. The biological treatment tank column is encoded using Label encoding to generate a numerical vector. :

[0083] ,

[0084] in, ( ) is a label, This column contains information on the biological treatment tanks used in wastewater treatment plants. Biological treatment tanks are biological / chemical reaction tanks. This column records the processes used in each plant's biological treatment tanks, such as A2O and CASS tanks. Due to the large number of categories, labels are used. For example, if there are three types of biological treatment tanks (X, Y, Z), they are coded as 0, 1, and 2 respectively.

[0085] Define the rows of the Boolean value matrix as a specific wastewater treatment plant and the columns as a specific process section to obtain the Boolean value matrix. and utilize , , and Construct a Boolean matrix X for all wastewater treatment plants, representing the process information of each numbered wastewater treatment plant:

[0086] .

[0087] It should be understood that each plant and each process section is represented using a Boolean matrix. Each row of the Boolean matrix corresponds to a wastewater treatment plant, and each column corresponds to a process section. If a plant uses a certain process section, the value at the corresponding position is 1; otherwise, it is 0.

[0088] All the processed features are combined into a feature matrix X. Each row of the feature matrix X corresponds to a wastewater treatment plant, and each column corresponds to a feature.

[0089] In this embodiment, the digital encoding process of the wastewater treatment plant process information quantifies the process information of the wastewater treatment plant (such as discharge standards, treatment processes, types of biological treatment tanks, etc.) through digital encoding. This enables these non-numerical process information to participate in the model calculation in numerical form, enriching the input features of the model.

[0090] Digitally encoded process information can more intuitively reflect the process characteristics of wastewater treatment plants, which helps to improve the interpretability of the model and makes it easier for technicians to understand the model's decision-making process.

[0091] By uniformly encoding the process information of different wastewater treatment plants, the model can better learn the commonalities and differences between different processes, thereby improving its generalization ability to data from different wastewater treatment plants.

[0092] Preferably, such as Figure 2 As shown, process similarity processing is performed on the process information of the numbered wastewater treatment plants to obtain a process similarity diagram, including:

[0093] Graph structure definition:

[0094] Node: Each wastewater treatment plant is a node, and the node's characteristics are the encoded process information matrix X;

[0095] Edge weight (similarity): The degree of association between nodes is calculated using Euclidean distance and a similarity function.

[0096] Specifically, the wastewater treatment plant is treated as a node in the graph, and the node is defined. and nodes Euclidean distance between :

[0097] ,

[0098] in, Characteristic matrix The number of columns,

[0099] Define similarity function :

[0100] ,

[0101] Constructing an adjacency matrix ,in, Represents a node and nodes Similarity between them:

[0102] ,

[0103] Since the graph is undirected, then It is a symmetric matrix:

[0104] ,

[0105] Based on similarity Define the message passing function M:

[0106] ,

[0107] in, For the normalized adjacency matrix, node In the Hidden states of a layer (i.e., feature representations);

[0108] like Figure 2 As shown, the Basis Generator is based on the normalized adjacency matrix. Construct node feature base, local feature base and global feature base, wherein the node feature base is used to extract features of a single wastewater treatment plant, the local feature base is used to capture the relationship between features of each wastewater treatment plant, and the global feature base is used to extract the overall features of the graph;

[0109] Linear layer mapping weights of appropriate size are applied to the node feature bases, local feature bases, and global feature bases. Based on the weights corresponding to each feature base, the feature bases are accumulated to obtain the process feature matrix, i.e., the process similarity map (e.g., ...). Figure 3 As shown), the process feature matrix is:

[0110] ,

[0111] in, Let k be the characteristic basis function. As a global feature base, The node feature matrix, For the first The weight matrix of each linear layer This is the similarity matrix between nodes. This is the weight matrix for the similarity terms.

[0112] In this embodiment, the node feature base uses the following formula to respectively apply to the original features. Perform row and column normalization using the following formulas:

[0113] ,

[0114] ,

[0115] For dense adjacency matrices or large datasets, this part can be decomposed using a low-rank decomposition, with the specific formula as follows:

[0116]

[0117] in, .

[0118] The local feature basis generation method first constructs a self-loop, and then, based on a set number of message propagations... The loop executes message passing, difference operations, and normalization operations sequentially, specifically generating the base using the message passing method described above.

[0119] ,

[0120] in, It is a message passing function.

[0121] Perform a difference operation to generate higher-order basis functions through recurrence relations.

[0122] ,

[0123] Perform standardized operations; the specific formula is as follows:

[0124] ,

[0125] The global eigenbasis generation method calculates the symmetric normalized Laplacian matrix, as shown in the following formula:

[0126] ,

[0127] It can also be decomposed into low rank.

[0128] This embodiment is based on the process similarity processing of GNN. By constructing a process similarity graph, the process correlation between different wastewater treatment plants can be mined, enabling the model to make full use of this correlation information for learning and prediction, thereby further improving the accuracy and reliability of the prediction.

[0129] By using GNN to process the process similarity graph, the advantages of GNN in processing graph structure data are fully utilized, which can better capture the complex relationships and mutual influences between wastewater treatment plants.

[0130] By constructing and fusing node feature bases, local feature bases, and global feature bases, a more representative process feature matrix was obtained, providing richer feature information for subsequent Transformer model training.

[0131] Preferably, such as Figure 2 As shown, the process similarity map and the influent dimensionality reduction features are used as inputs, and the effluent dimensionality reduction features are used as the target output to train the Transformer neural network for wastewater treatment data prediction, resulting in the trained iFEGformer wastewater treatment prediction model, which includes:

[0132] First, feature aggregation features of each wastewater treatment plant are extracted from the process similarity map (i.e., the aggregation information of the corresponding part is extracted), and the feature aggregation features and the influent dimensionality reduction features corresponding to each wastewater treatment plant are normalized.

[0133] Specifically, a standardization operation is performed on each input feature, where... For the mean, The standard value is given by the following formula:

[0134] .

[0135] Next, the normalized features of each wastewater treatment plant and the influent dimensionality reduction features are encoded using a vertical feature encoding method to obtain multiple time-series features. These multiple time-series features are used as inputs to the Encoder block of the Transformer neural network, and the effluent dimensionality reduction features are used as the target output. The Transformer neural network is then trained to predict wastewater treatment data, resulting in the trained iFEGformer wastewater treatment prediction model.

[0136] In this embodiment, vertical feature encoding is performed, including the following steps: transposing the input dimension, transposing the covariates, concatenating the covariates, performing a linear transformation, and Dropout. Specifically:

[0137] Transpose the input dimension, moving the time step dimension (T) to the end to facilitate subsequent feature processing by variable (V). The specific formula is as follows:

[0138] ,

[0139] If covariates exist (C) represents the covariate dimension:

[0140] ,

[0141] By concatenating covariates (such as timestamps and seasonal features), the model's ability to capture complex patterns is enhanced. The specific formula is as follows:

[0142] ,

[0143] Perform a linear mapping to map the features to The specific formula is as follows:

[0144] ,

[0145] Dropout is a technique that randomly sets parameters to zero with a set probability.

[0146] The training process of the Transformer neural network in this embodiment, through the processing of longitudinal feature encoding and Encoder blocks, can fully extract the temporal features in the dimensionality reduction features of the influent, enabling the model to better capture the patterns and trends in time series data, thereby improving the ability to predict indicators such as effluent water quality.

[0147] By using process similarity maps and influent dimensionality reduction features as inputs and effluent dimensionality reduction features as the target output for training, the Transformer neural network can better learn the input-output relationship in the wastewater treatment process, optimize the model's parameters and structure, and improve the model's predictive performance.

[0148] It achieves end-to-end learning from input data to prediction results, reducing reliance on manual feature engineering and improving the automation and adaptability of the model.

[0149] Preferably, such as Figure 4 As shown, training the Transformer neural network for wastewater treatment data prediction includes:

[0150] The encoder block consists of multiple encoder blocks, which mainly contain two sub-layers: 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 allocating weights to capture key information. The feed-forward neural network (FFN) enhances the model's expressive power through non-linear transformations, capturing complex relationships between features.

[0151] Specifically, the processing procedure for the Encoder Block is as follows:

[0152] The output of the (n-1)th layer As input to the nth layer Attention weights are calculated using a full attention mechanism:

[0153] ,

[0154] Where Q is the query matrix, K is the key matrix, and V is the value matrix. The dimension of the key vector;

[0155] Multiple temporal features are processed using a feedforward neural network and attention weights to perform nonlinear transformation:

[0156] ,

[0157] in, It is a feedforward neural network;

[0158] Feedforward neural network (FFN) layers also include Dropout layers, which are used to randomly drop some neurons to prevent overfitting.

[0159] Next, the various time-series features after nonlinear transformation are mapped to the prediction length, as follows:

[0160] ,

[0161] in, , This is the weight matrix. For bias terms;

[0162] The dimensions of each mapped time-series feature are transposed back to their original dimensions, and the distribution of the original data is restored by activating the eucalyptus tree, as shown below:

[0163] ,

[0164] in, For decoder output, For the original input standard deviation For the original input The mean.

[0165] In this embodiment, the Transformer neural network training process calculates attention weights through a full attention mechanism, enabling the model to dynamically focus on more important parts of the input sequence, capture long-distance dependencies, and further improve the ability to model temporal features.

[0166] By using a feedforward neural network to perform nonlinear transformation on time-series features and mapping the transformed features to the prediction length, useful information in the features can be extracted more effectively, improving the model's expressive power and prediction accuracy.

[0167] Applying residual connections and layer normalization in each Encoder Block helps alleviate the vanishing gradient problem in deep networks, stabilizes the training process, and improves the training efficiency and performance of the model.

[0168] Finally, the loss assessment results, which aggregate the three loss assessment methods, are presented to demonstrate the effectiveness of the model. Specifically:

[0169] Set the effluent data as the output target of the model;

[0170] The dataset is divided into training and testing sets for training and validating the iFEGformer neural network model.

[0171] The dataset is a time series data of wastewater treatment.

[0172] Configure the loss function and optimizer for the iFEGformer neural network model.

[0173] The iFEGformer neural network model is trained and its prediction accuracy is evaluated using the following three metrics: Mean Squared Error (MSE), Root Mean Squared Error (RMSE), and Mean Absolute Error (MAE).

[0174] ,

[0175] ,

[0176] ,

[0177] Where m is the dimension of the output data, For the true value, Output the sequence mean for the model.

[0178] The iFEGformer neural network model has demonstrated outstanding performance in wastewater treatment data prediction. Evaluations based on MSE, RMSE, and MAE indicators have proven its advantages in prediction accuracy and robustness. This model can effectively handle high-dimensional time series data, and by combining graph neural networks and the Transformer architecture, it provides strong technical support for the operation and management of wastewater treatment plants.

[0179] Example 2: Figure 5 As shown, this embodiment of the invention also provides a wastewater treatment prediction device that integrates GNN and Transformer, comprising:

[0180] The raw data acquisition module is used to acquire wastewater treatment plant process information from a specified database and to acquire wastewater monitoring data in a time-series manner. The wastewater monitoring data includes influent monitoring data and effluent monitoring data.

[0181] The data preprocessing module is used to construct a high-dimensional feature matrix based on the influent monitoring data and the effluent monitoring data, and to perform dimensionality reduction processing on the high-dimensional feature matrix to obtain a wastewater dimensionality-reduced feature matrix, wherein the wastewater dimensionality-reduced feature matrix includes influent dimensionality-reduced features and effluent dimensionality-reduced features.

[0182] The prediction model construction module is used to construct the iFEGformer wastewater treatment prediction model. The iFEGformer wastewater treatment prediction model includes a GNN graph neural network and a Transformer neural network. The wastewater treatment plant process information is digitally encoded, and the GNN graph neural network is used to perform process similarity processing on the encoded wastewater treatment plant process information to obtain a process similarity map. The process similarity map and the influent dimensionality reduction features are used as inputs, and the effluent dimensionality reduction features are used as the target output to train the Transformer neural network for wastewater treatment data prediction, resulting in the trained iFEGformer wastewater treatment prediction model.

[0183] The prediction module is used to import the influent monitoring data to be predicted, and use the trained iFEGformer wastewater treatment prediction model to predict the wastewater treatment data to obtain the effluent prediction data.

[0184] Example 3: This embodiment of the invention also provides a wastewater treatment prediction device that integrates GNN and Transformer, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the wastewater treatment prediction method that integrates GNN and Transformer as described above.

[0185] Example 4: This embodiment of the invention also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the wastewater treatment prediction method that integrates GNN and Transformer as described above.

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

[0187] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described apparatus and unit can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0188] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.

[0189] The units described as separate components may or may not be physically separate. The 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 the units can be selected to achieve the purpose of the embodiments of the present invention, depending on actual needs.

[0190] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0191] 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, in essence, or the part 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 to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0192] 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 within the protection scope of the present invention.

Claims

1. A wastewater treatment prediction method integrating GNN and Transformer, characterized in that, Includes the following steps: The wastewater treatment plant process information is obtained from a designated database, and wastewater monitoring data is obtained in a time-series manner. The wastewater monitoring data includes influent monitoring data and effluent monitoring data. A high-dimensional feature matrix is ​​constructed based on the influent monitoring data and the effluent monitoring data, and the high-dimensional feature matrix is ​​then subjected to dimensionality reduction processing to obtain a wastewater dimensionality-reduced feature matrix, which includes influent dimensionality-reduced features and effluent dimensionality-reduced features. An iFEGformer wastewater treatment prediction model is constructed. The iFEGformer wastewater treatment prediction model includes an encoding block, a GNN graph neural network, and a Transformer neural network. The process information of the wastewater treatment plant is digitally encoded through the encoding block, and the process similarity of the encoded wastewater treatment plant process information is processed through the GNN graph neural network to obtain a process similarity map. Using the process similarity map and the influent dimensionality reduction features as inputs and the effluent dimensionality reduction features as the target output, the Transformer neural network is trained to predict wastewater treatment data, resulting in the trained iFEGformer wastewater treatment prediction model. Import the influent monitoring data to be predicted, and use the trained iFEGformer wastewater treatment prediction model to predict the wastewater treatment data to obtain the effluent prediction data.

2. The wastewater treatment prediction method according to claim 1, characterized in that, After acquiring the wastewater monitoring data, the process also includes a data preprocessing step: The influent monitoring data from different months and the effluent monitoring data from different months in the wastewater monitoring data are merged. use The criterion formulas calculate the upper and lower limits of the influent and effluent monitoring data, respectively. The criterion is: , , in, This refers to the upper limit of influent monitoring data or the upper limit of effluent monitoring data. This refers to the lower limit of influent monitoring data or the lower limit of effluent monitoring data. For predicted values, Standard deviation, Abnormal values ​​of influent monitoring data that are greater than the upper limit of the influent monitoring data and abnormal values ​​of influent monitoring data that are less than the lower limit of the influent monitoring data are removed; and abnormal values ​​of effluent monitoring data that are greater than the upper limit of the effluent monitoring data and abnormal values ​​of effluent monitoring data that are less than the lower limit of the effluent monitoring data are removed. Missing values ​​in the influent and effluent monitoring data after outlier removal were imputed using Lagrange interpolation. The Lagrange interpolation formula is as follows: , in, For the interpolation polynomial of influent or effluent monitoring data, For known influent or effluent monitoring data, Let n be a Lagrange polynomial, and n be the highest degree of the interpolation polynomial. , As the independent variable, The value of the current node's independent variable. The values ​​of the independent variables for the remaining nodes; The influent and effluent monitoring data after missing value imputation were normalized using a normalization formula, which is: , in, The mean, Standard deviation, The maximum value among the influent or effluent monitoring data. It is the minimum value among the influent or effluent monitoring data.

3. The wastewater treatment prediction method according to claim 1, characterized in that, A high-dimensional feature matrix is ​​constructed based on the influent monitoring data and the effluent monitoring data, and the high-dimensional feature matrix is ​​then subjected to dimensionality reduction processing, including: A high-dimensional feature matrix is ​​constructed based on the influent monitoring data and the effluent monitoring data, represented as follows: ,in, This refers to the sample size for influent and effluent monitoring data. It represents the number of high-dimensional features; For high-dimensional feature matrices Each column of high-dimensional features is standardized to obtain a standardized high-dimensional feature matrix. : , in, This is the mean vector of each column of high-dimensional features. The standard deviation vector of each column of high-dimensional features. Represented as feature dimension; For the standardized high-dimensional feature matrix Covariance processing is performed to obtain the covariance matrix. ,in, , And for the covariance matrix Perform eigenvalue decomposition to obtain ,in, , These are the feature values ​​of the high-dimensional features, and the feature values ​​are sorted in descending order. , For each eigenvalue, there is a unit eigenvector. ; Before choosing The eigenvectors corresponding to the largest eigenvalues ​​form the projection matrix. ,in, ; Through projection matrix For the standardized high-dimensional feature matrix Dimensionality reduction is performed to obtain the wastewater dimension-reduced feature matrix, represented as follows: ,in, .

4. The wastewater treatment prediction method according to claim 1, characterized in that, The wastewater treatment plant process information is digitally encoded using the encoding block, including: The emission standard column corresponding to the process section of the wastewater treatment plant is obtained from the wastewater treatment plant process information, and the emission standard column is converted into a numerical type and represented as follows: , in, This provides the original emission standard information corresponding to the process section of the i-th wastewater treatment plant. for The numerical result after digital encoding will be converted to the value 1 if the information in the emission standard column is Level A, and to the value 0 if the information in the emission standard column is Level B. The process treatment columns corresponding to the process segments of the wastewater treatment plant are obtained from the wastewater treatment plant process information. Each treatment process in the process treatment column is encoded using the One-Hot encoding method to obtain a binary matrix. : ; Where i-th represents the i-th wastewater treatment plant and j-th represents the j-th treatment process; The biological treatment tank column corresponding to the process section of the wastewater treatment plant is obtained from the wastewater treatment plant process information. The biological treatment tank column is encoded using Label encoding to generate a numerical vector. : , in, ( ) is a label, Information on the biological treatment tanks used in wastewater treatment plants; Define the rows of the Boolean value matrix as a specific wastewater treatment plant and the columns as a specific process section to obtain the Boolean value matrix. and utilize , , and Construct a Boolean matrix X for all wastewater treatment plants, representing the process information of each numbered wastewater treatment plant: 。 5. The wastewater treatment prediction method according to claim 4, characterized in that, Based on the GNN graph neural network, process similarity processing is performed on the encoded wastewater treatment plant process information to obtain a process similarity map, including: Treat the wastewater treatment plant as a node in the graph, and define the node. and nodes Euclidean distance between : , in, Characteristic matrix The number of columns, Define similarity function : , Constructing an adjacency matrix ,in, Represents a node and nodes Similarity between them: , Since the graph is undirected, then It is a symmetric matrix: , Based on similarity Define a message passing function: , in, For the normalized adjacency matrix, node In the The hidden state of the layer; Based on normalized adjacency matrix Construct node feature base, local feature base and global feature base, wherein the node feature base is used to extract features of a single wastewater treatment plant, the local feature base is used to capture the relationship between features of each wastewater 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 applied to the node feature bases, local feature bases, and global feature bases. Based on the weights corresponding to each feature base, the feature bases are accumulated to obtain the process feature matrix, i.e., the process similarity map. The process feature matrix is ​​as follows: , in, Let k be the characteristic basis function. As a global feature base, The node feature matrix, For the first The weight matrix of each linear layer This is the similarity matrix between nodes. This is the weight matrix for the similarity terms.

6. The wastewater treatment prediction method according to claim 4, characterized in that, Using the process similarity map and the influent dimensionality reduction features as inputs, and the effluent dimensionality reduction features as the target output, the Transformer neural network is trained for wastewater treatment data prediction, resulting in the trained iFEGformer wastewater treatment prediction model, including: The feature aggregation features of each wastewater treatment plant are extracted from the process similarity map, and the feature aggregation features and the corresponding influent dimensionality reduction features of each wastewater treatment plant are normalized. By using a vertical feature encoding method, multiple time-series features are obtained by encoding the normalized features of each wastewater treatment plant and the influent dimensionality reduction features. These multiple time-series features are used as inputs to the Encoder block of a Transformer neural network, and the effluent dimensionality reduction features are used as the target output. The Transformer neural network is then trained to predict wastewater treatment data, resulting in the trained iFEGformer wastewater treatment prediction model.

7. The wastewater treatment prediction method according to claim 6, characterized in that, Training the Transformer neural network for wastewater treatment data prediction includes: The encoder block consists of multiple encoder blocks, and the processing procedure for each encoder block is as follows: The first -1 layer output As input to the l-th layer Attention weights are calculated using a full attention mechanism: , Where Q is the query matrix, K is the key matrix, and V is the value matrix. The dimension of the key vector; Multiple temporal features are processed using a feedforward neural network and attention weights to perform nonlinear transformation: , in, It is a feedforward neural network; Mapping each time-series feature after nonlinear transformation to the prediction length is represented as follows: , in, , This is the weight matrix. For bias terms; The dimensions of each mapped time-series feature are transposed back to their original dimensions, and the distribution of the original data is restored by activating the eucalyptus tree, as shown below: , in, For decoder output, For the original input standard deviation For the original input The mean.

8. A wastewater treatment prediction device integrating GNN and Transformer, characterized in that, include: The raw data acquisition module is used to acquire wastewater treatment plant process information from a specified database and to acquire wastewater monitoring data in a time-series manner. The wastewater monitoring data includes influent monitoring data and effluent monitoring data. The data preprocessing module is used to construct a high-dimensional feature matrix based on the influent monitoring data and the effluent monitoring data, and to perform dimensionality reduction processing on the high-dimensional feature matrix to obtain a wastewater dimensionality-reduced feature matrix, wherein the wastewater dimensionality-reduced feature matrix includes influent dimensionality-reduced features and effluent dimensionality-reduced features. A prediction model construction module is used to construct the iFEGformer wastewater treatment prediction model. The iFEGformer wastewater treatment prediction model includes an encoding block, a GNN graph neural network, and a Transformer neural network. The encoding block performs digital encoding processing on the wastewater treatment plant process information, and the GNN graph neural network performs process similarity processing on the encoded wastewater treatment plant process information to obtain a process similarity map. The process similarity map and the influent dimensionality reduction features are used as inputs, and the effluent dimensionality reduction features are used as the target output to train the Transformer neural network for wastewater treatment data prediction, resulting in the trained iFEGformer wastewater treatment prediction model. The prediction module is used to import the influent monitoring data to be predicted, and use the trained iFEGformer wastewater treatment prediction model to predict the wastewater treatment data to obtain the effluent prediction data.

9. A wastewater 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, it implements the wastewater treatment prediction method that integrates GNN and Transformer as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program that, when executed by a processor, implements the wastewater treatment prediction method that integrates GNN and Transformer 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