Water network water quality space-time prediction method based on generative neural network model
Through the water network water quality space-time prediction method based on the generative neural network model, the spatial and temporal information of water quality data is integrated, and the problem of insufficient consideration of spatial correlation in the water quality prediction model in the existing technology is solved, achieving efficient and accurate water quality space-time and time-time Forecast to meet the needs of modern water quality management.
Patent Information
- Application Number
- CN202411036556.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-11-26
AI Technical Summary
The existing water quality prediction model has shortcomings in the spatial correlation and complexity of processing water quality data, making it difficult to achieve efficient and real-time spatial prediction, and lacks systematic and automated methods, which cannot meet the rapid response and multi-step prediction needs of modern water quality management. .
The water quality prediction method based on the generative neural network model is adopted to obtain and clean the water quality monitoring data, format the spatial information and time alignment, determine the characteristic dimensions, and build a water quality prediction model containing the Transformer architecture, combining the adjacency matrix and Distance matrix improves the model's understanding of spatial correlation and prediction accuracy of water quality data.
Effectively integrate the time series characteristics and spatial topological information of water quality indicators, improve the accuracy and efficiency of water quality prediction, meet the needs of single-step and multi-step prediction, provide more accurate water quality management support, and promote water resource protection and pollution control.
Smart Images

Figure CN119025847A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of water quality prediction of water networks, and in particular to a method for spatiotemporal prediction of water quality of water networks based on a generative neural network model. Background Art
[0002] With the accelerated development of global industrialization and urbanization, water resource protection and management are facing unprecedented challenges. Water quality safety is directly related to human health, ecological balance and sustainable development of social economy. Therefore, accurate and efficient water quality prediction technology has become an important research topic in the field of environmental protection. In recent years, water pollution problems have occurred frequently, especially in natural water bodies such as rivers and lakes, which are increasingly complex and changeable due to the influence of industrial emissions, agricultural non-point source pollution, domestic sewage discharge and other factors. Traditional water quality monitoring and prediction methods, such as physical and chemical analysis methods and statistical regression models, are often difficult to accurately reflect the dynamic changes of water quality in real time, especially in the spatiotemporal prediction of water quality over a large range and long time scale.
[0003] At present, water quality prediction technology is gradually developing in the direction of intelligence and refinement. Among them, prediction models based on machine learning and deep learning have shown great potential in the field of water quality prediction due to their powerful data processing capabilities and nonlinear modeling advantages. However, although existing technologies have made certain progress in water quality prediction, there are still some shortcomings in practical applications: most existing water quality prediction models focus on time series analysis, and the spatial correlation and complexity of water quality data are not considered enough. The mutual influence of water quality status in space (such as the impact of upstream pollution on downstream water quality) is an important factor in environmental management, but how to effectively integrate spatial information and incorporate it into the prediction model is still an urgent problem to be solved. Water quality data usually has high-dimensional characteristics. How to screen out key influencing factors from massive data and reasonably determine the characteristic dimensions is crucial to model performance. However, this process often relies on manual experience and trial and error, and lacks systematic and automated methods. Rapid response and real-time prediction are urgent needs of modern water quality management. Traditional models have limited capabilities in processing real-time data streams and quickly updating prediction results, and it is difficult to meet the requirements of instant decision support. Current water quality prediction focuses on one-step-ahead prediction, while ignoring the accuracy of multi-step prediction. In view of the above problems, it is particularly important to develop a prediction method that can comprehensively consider the spatiotemporal characteristics of water quality data. It not only needs to have a high degree of prediction accuracy, but also needs to be able to efficiently process large-scale data, timely feedback on water quality change trends, and at the same time have good generalization ability and the ability to quickly adapt to new situations.
[0004] For example, a Chinese patent with the authorization announcement number CN107153874B discloses a water quality prediction method and system, which uses a method combining the ARIMA autoregressive integrated moving average model with the BP neural network to predict water quality time series data. The scheme described in the invention can predict a large amount of water quality data in the water area to be predicted, and has the characteristics of a large prediction range, high accuracy and high speed, which is convenient for multi-water source supervision, water quality early warning, and water pollution control.
[0005] For example, the patent application with publication number CN116050456A discloses a water quality prediction method and application. The specific scheme is: a water quality prediction method, including the following steps: using the whale optimization algorithm, taking the sample entropy as the fitness, optimizing the sample entropy of the time series, and obtaining the optimal variational mode decomposition modal number K; based on the optimal decomposition modal number K, through variational mode decomposition, decomposing the time series into K simpler subsequences of different frequency scales; using a multi-function recurrent fuzzy neural network to train and test the K subsequences separately, and adding the test results of each subsequence to obtain the final prediction result. This invention provides a new method for long-term and accurate prediction of water quality, which can achieve long-term and accurate prediction of water quality data.
[0006] The above patents all have the problem raised by this background technology: insufficient consideration of the spatial correlation and complexity of water quality data.
[0007] The information disclosed in this background technology section is only intended to enhance the understanding of the overall background of the invention and should not be regarded as an acknowledgement or any form of suggestion that the information constitutes the prior art already known to ordinary technicians in this field. Summary of the invention
[0008] The technical problem to be solved by the present invention is to overcome the defects of the prior art and provide a water network water quality spatiotemporal prediction method based on a generative neural network model to improve the accuracy, practicality and intelligence level of water network water quality prediction.
[0009] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0010] A method for spatiotemporal prediction of water quality in a water network based on a generative neural network model comprises the following steps:
[0011] As a preferred solution of the water network water quality spatiotemporal prediction method based on the generative neural network model of the present invention, wherein:
[0012] S1: Obtain water quality monitoring data set of water network, extract water quality index data and perform data cleaning on water quality index data;
[0013] S2: establishing a water quality index sequence based on the water quality index data, and performing smoothing on the water quality index sequence;
[0014] S3: Format the spatial information of water quality index data, obtain the spatial topological information of water quality index data, and perform time alignment of water quality index sequences;
[0015] S4: Determine the characteristic dimensions of the water quality indicator sequence;
[0016] S5: constructing a water quality prediction model, and training the water quality prediction model based on the water quality index sequence and the spatial topological information of the water quality index data;
[0017] S6: Collect real-time water quality index data, and perform spatiotemporal prediction of water quality based on the water quality prediction model.
[0018] As a preferred solution of the water network water quality spatiotemporal prediction method based on the generative neural network model of the present invention, wherein: the water network water quality monitoring data set includes water quality index data recorded by each monitoring station of the water network; the water quality index data includes total nitrogen value, dissolved oxygen, conductivity, total phosphorus value, pH value;
[0019] The data cleaning includes filling missing values and replacing abnormal values;
[0020] The water quality index sequence is a time series of each water quality index data of each monitoring site; the establishment method is as follows: standardize all water quality index data; organize each standardized water quality index data of each monitoring site into a water quality index sequence in chronological order;
[0021] The smoothing method is to smooth the water quality index data in the water quality index sequence through a sliding window, and the formula involved is as follows:
[0022]
[0023] Among them, x i represents the i-th element in any smoothed water quality index sequence; y i-j represents the ijth element in the water quality index sequence before smoothing; N is the sliding window size.
[0024] As a preferred solution of the water network water quality spatiotemporal prediction method based on the generative neural network model of the present invention, the method for obtaining the spatial topological information of the water quality index data is as follows:
[0025] Get the longitude and latitude coordinates of each monitoring site;
[0026] Calculate the distance between each monitoring site and all other monitoring sites based on their latitude and longitude coordinates;
[0027] Construct an adjacency matrix and a distance matrix for all monitoring sites; wherein the adjacency matrix is used to represent the adjacency relationship between monitoring sites, and the distance matrix is used to represent the distance between detection sites.
[0028] As a preferred solution of the water network water quality spatiotemporal prediction method based on the generative neural network model of the present invention, the form of the adjacency matrix is as follows:
[0029]
[0030] Among them, A represents the adjacency matrix, a ij represents the adjacency relationship between the ith monitoring station and the jth monitoring station. If the ith monitoring station is adjacent to the jth monitoring station, then a ij The value of is 1, otherwise, a ij The value of is 0; the value range of i and j is 1, 2, ..., n, where n is the total number of monitoring sites;
[0031] The rules for judging whether any two monitoring sites are adjacent are as follows: if the distance between any monitoring site a and any monitoring site b is less than the threshold distance, then monitoring site a and monitoring site b are adjacent; if the distance between monitoring site a and monitoring site b is not less than the threshold distance, and monitoring site a and monitoring site b are in the same tributary, then monitoring site a and monitoring site b are adjacent; if the distance between monitoring site a and monitoring site b is not less than the threshold distance, and monitoring site a and monitoring site b are not in the same tributary, then monitoring site a and monitoring site b are not adjacent.
[0032] As a preferred solution of the water network water quality spatiotemporal prediction method based on the generative neural network model of the present invention, the method for time alignment of the water quality index sequence is as follows:
[0033] S100: Select one monitoring site as a reference site; extract each water quality index sequence of the reference site as the reference sequence of each water quality index data; add all monitoring sites other than the reference site to the target site set;
[0034] S200: removing a monitoring site from the target site set, and extracting each water quality indicator sequence of the removed monitoring site as a target sequence for each water quality indicator sequence;
[0035] S300: aligning the target sequence of each water quality indicator with the reference sequence through dynamic time warping; if the target sequence of any water quality indicator is different from the reference sequence in length, interpolating and sampling the target sequence to make the target sequence and the reference sequence in length consistent;
[0036] S400: Repeat steps S200-S300 until the target site set is empty, completing the time alignment of the water quality indicator sequence.
[0037] As a preferred solution of the water network water quality spatiotemporal prediction method based on the generative neural network model of the present invention, the method for determining the characteristic dimension of the water quality index sequence is as follows:
[0038] S401: Calculate the autocorrelation coefficient of each lag order of any water quality index sequence; the formula is as follows:
[0039]
[0040] Among them, ρ k represents the autocorrelation coefficient of the water quality index sequence when the lag order is k; E(·) represents the mean value; x t represents the tth element in the water quality index sequence; x t+k represents the t+kth element in the water quality index sequence; μ represents the mean of all elements in the water quality index sequence;
[0041] S402: Calculate the standard error of the autocorrelation coefficient for each lag order; the formula is as follows:
[0042]
[0043] Among them, S(ρ k ) represents the autocorrelation coefficient ρ k The standard error of h It represents the autocorrelation coefficient of the water quality index series when the lag order is h;
[0044] S403: Construct the t statistic of each autocorrelation coefficient based on the autocorrelation coefficient and the standard error of the autocorrelation coefficient. The formula is as follows:
[0045]
[0046] Among them, t k represents the autocorrelation coefficient ρ k The t-statistic of
[0047] S404: Perform a significance test on the t statistic of each autocorrelation coefficient; calculate the lag order of the autocorrelation coefficient that is significantly not zero, and select the largest lag order as the characteristic dimension of the water quality indicator sequence.
[0048] As a preferred solution of the water network water quality spatiotemporal prediction method based on the generative neural network model of the present invention, the water quality prediction model includes a single-step prediction sub-model, a short-term prediction sub-model, and a medium-term prediction sub-model; the model input of any water quality prediction model includes each water quality index sequence of all detection sites, as well as the adjacency matrix and the distance matrix;
[0049] The structure of any water quality prediction model includes feature selection layer, feature mapping layer, position encoding layer, decoding layer, and output layer; among them:
[0050] The feature selection layer is configured with an autocorrelation feature selection algorithm for feature screening of model input;
[0051] The feature mapping layer is used to map the model input after feature screening into a high-dimensional vector;
[0052] The position coding layer is used to add position coding to the high-dimensional vector;
[0053] The decoding layer includes two consecutive Transformer decoders; each Transformer decoder includes a self-attention module and a feedforward neural network module; the self-attention module is used to capture the relationship between the unknown encoded high-dimensional vector or the feature vector output by the previous encoder, and output the self-attention vector; the feedforward neural network module is used to perform nonlinear transformation on the self-attention vector and output the feature vector;
[0054] The output layer is used to calculate and output the predicted value of the water quality index data of each water quality index sequence.
[0055] As a preferred solution of the water network water quality spatiotemporal prediction method based on the generative neural network model of the present invention, wherein: the number of neurons in the output layer of the single-step prediction sub-model is m·n, and the output is the predicted value of the water quality index data at a future time point of each water quality index sequence; wherein m is the number of types of water quality index sequences; n is the number of monitoring sites;
[0056] The number of neurons in the output layer of the short-term prediction sub-model is m·n·p, and the output is the predicted value of the water quality index data at p consecutive time points in the future of each water quality index sequence;
[0057] The number of neurons in the output layer of the mid-term prediction sub-model is m·n·q, and the output is the predicted value of the water quality index data at q consecutive time points in the future of each water quality index sequence;
[0058] Wherein, p and q are both positive integers, and 1<p<q.
[0059] As a preferred solution of the water network water quality spatiotemporal prediction method based on the generative neural network model of the present invention, the method for performing spatiotemporal water quality prediction is as follows:
[0060] Continuously collect real-time water quality index data from each monitoring site and transmit it to the central water quality monitoring system;
[0061] The central water quality monitoring system cleans and standardizes the real-time water quality index data of each monitoring site, updates each water quality index sequence of each monitoring site, calls the water quality prediction model, predicts each water quality index data of each monitoring site based on the updated water quality index sequence, and visualizes the prediction results.
[0062] Compared with the prior art, the beneficial effects achieved by the present invention are as follows:
[0063] By formatting the spatial information of water quality monitoring data and aligning it in time, this solution effectively integrates the time series characteristics of water quality indicators and spatial topological information. The use of adjacency matrix and distance matrix not only enhances the model's understanding of the spatial correlation of water quality data, but also promotes the model's prediction accuracy when considering the influence of geographical location, providing more accurate support for water quality management of complex water network systems.
[0064] The advanced Transformer architecture is adopted and targeted improvements are made, especially the introduction of the Decoder-on ly architecture and the unbiased high-dimensional mapping layer, which enables the model to focus on the generation task and improves the simulation ability of the dynamic changes of water pollution. This structural innovation not only optimizes the prediction efficiency, but also broadens the application flexibility of the model in single-step prediction and multi-step (short-term and medium-term) prediction, meeting the water quality prediction requirements under different management needs.
[0065] This invention promotes the intelligent process of water quality prediction technology and practice, and provides strong technical support for water resource protection, pollution control strategy formulation and ecological environment assessment. By improving prediction accuracy and efficiency, it helps environmental protection departments and related institutions to plan water resource utilization more scientifically, reduce the impact of pollution incidents, ensure public water safety, and promote ecological civilization construction and sustainable development of social economy. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. Among them:
[0067] Figure 1A flow chart of a method for spatiotemporal prediction of water quality in a water network based on a generative neural network model provided by the present invention;
[0068] Figure 2 A flow chart of a method for time alignment of water quality indicator sequences provided by the present invention;
[0069] Figure 3 A flow chart of a method for determining characteristic dimensions of a water quality index sequence provided by the present invention;
[0070] Figure 4 This is a schematic diagram of the structure of the water quality prediction model provided by the present invention. DETAILED DESCRIPTION
[0071] The technical solution of the present invention is described in detail below through the accompanying drawings and specific embodiments. It should be understood that the embodiments of the present invention and the specific features in the embodiments are detailed descriptions of the technical solution of the present invention, rather than limitations on the technical solution of the present invention. The embodiments of the present invention and the technical features in the embodiments may be combined with each other unless there is a conflict.
[0072] This embodiment introduces a water network water quality spatiotemporal prediction method based on a generative neural network model. Figure 1 , the method comprises the following steps:
[0073] S1: Obtain water quality monitoring data set of water network, extract water quality index data and perform data cleaning on water quality index data;
[0074] The water quality monitoring data set of the water network includes water quality index data recorded by each monitoring station of the water network; the water quality index data includes total nitrogen value, dissolved oxygen, conductivity, total phosphorus value, and pH value;
[0075] Total nitrogen value refers to the total amount of all forms of nitrogen in the sample, including organic nitrogen, ammonia nitrogen, nitrite nitrogen, nitrate nitrogen and nitrogen gas, etc., expressed as the mass of nitrogen element per liter of water. Excessive total nitrogen values are usually related to agricultural non-point source pollution, urban sewage discharge and industrial activities. Dissolved oxygen refers to the amount of oxygen dissolved in water. It is an important indicator for measuring the self-purification ability of water bodies and the living conditions of organisms. It is expressed as a percentage of saturation. Dissolved oxygen is directly related to the self-purification ability of water bodies and the living conditions of organisms. Conductivity is a measure of the ability of aqueous solutions to conduct electric current. It indirectly reflects the total amount of dissolved ions in water. It is expressed in micro-Siemens per centimeter or millisiemen per meter. It is an indicator for evaluating the purity and mineralization of water bodies. Total phosphorus is the total amount of all forms of phosphorus in water bodies, including dissolved and particulate phosphorus. It is a key indicator for evaluating the degree of eutrophication of water bodies. It is expressed as the mass of phosphorus element per liter of water. pH value is a basic parameter for measuring the acid-base balance of water quality. Different aquatic organisms adapt to different pH ranges. pH values beyond the appropriate range will cause pressure on the aquatic ecosystem and affect the survival and reproduction of organisms.
[0076] The data cleaning includes filling missing values and replacing outliers.
[0077] First, check whether there are missing values in the water quality monitoring data set of the water network, that is, the water quality index data is not recorded at certain time points or monitoring stations. For the data of the monitoring stations with missing values and less missing water quality index data, they are filled by their own linear interpolation, and the data of the adjacent stations with more missing data are smoothed by referring to the data. Then identify and process the outliers of the water quality index data that may be caused by equipment failure, operating errors or other abnormal reasons. Outlier detection is performed according to the 3σ principle, and outliers are replaced by linear interpolation to ensure that the subsequent data analysis results are more accurate and reliable.
[0078] S2: establishing a water quality index sequence based on the water quality index data, and performing smoothing on the water quality index sequence;
[0079] The water quality index sequence is a time series of each water quality index data of each monitoring site; the establishment method is as follows: all water quality index data are standardized; each standardized water quality index data of each monitoring site is sorted into a water quality index sequence in chronological order; through Z-score standardization, the dimensional differences and numerical range differences between different water quality index data can be eliminated.
[0080] The smoothing method is to smooth the water quality index data in the water quality index sequence through a sliding window, and the formula involved is as follows:
[0081]
[0082] Among them, x i represents the i-th element in any smoothed water quality index sequence; y i-j represents the ijth element in the water quality index sequence before smoothing; N is the sliding window size, which is a positive integer and is set by technicians in this field based on actual needs.
[0083] Since there may be noise points in the water quality index data, this embodiment uses a sliding window to smooth and filter the original water quality index data to reduce the interference of noise. For water quality index data with large periodic fluctuations, such as dissolved oxygen, the sliding window data smoothing technology is used for processing, which can not only eliminate noise, but also highlight the periodic change trend of the data.
[0084] S3: Format the spatial information of water quality index data, obtain the spatial topological information of water quality index data, and perform time alignment of water quality index sequences;
[0085] The method for obtaining the spatial topological information of water quality index data is as follows:
[0086] Obtain the longitude and latitude coordinates of each monitoring site; the longitude and latitude coordinates of the monitoring point can be obtained through geographic information system technology such as GPS positioning.
[0087] Calculate the distance between each monitoring site and all other monitoring sites based on their latitude and longitude coordinates;
[0088] Construct the adjacency matrix and distance matrix of all monitoring sites; wherein the adjacency matrix is used to represent the adjacency relationship between monitoring sites, and the form is as follows:
[0089]
[0090] Among them, A represents the adjacency matrix, a ij represents the adjacency relationship between the ith monitoring station and the jth monitoring station. If the ith monitoring station is adjacent to the jth monitoring station, then a ij The value of is 1, otherwise, a ij The value of is 0; the value range of i and j is 1, 2, ..., n, where n is the total number of monitoring sites;
[0091] The rules for judging whether any two monitoring sites are adjacent are as follows: if the distance between any monitoring site a and any monitoring site b is less than the threshold distance, then monitoring site a and monitoring site b are adjacent; if the distance between monitoring site a and monitoring site b is not less than the threshold distance, and monitoring site a and monitoring site b are in the same tributary, then monitoring site a and monitoring site b are adjacent; if the distance between monitoring site a and monitoring site b is not less than the threshold distance, and monitoring site a and monitoring site b are not in the same tributary, then monitoring site a and monitoring site b are not adjacent;
[0092] The distance matrix is used to represent the distance between detection sites and is in the following form:
[0093]
[0094] Where D represents the distance matrix, d ij Represents the distance between the i-th monitoring site and the j-th monitoring site.
[0095] Formatting and recording the spatial information between monitoring sites through the adjacency matrix and the distance matrix can provide a data basis for analyzing the spatiotemporal characteristics of water quality data. In particular, when building a water quality prediction model that considers spatial relationships, the adjacency matrix and the distance matrix can be encoded into the model's input or attention mechanism to improve the model's prediction ability.
[0096] During the model training phase, the model first uses the adjacency matrix and distance matrix to determine which sites' data are most critical to the prediction of the target site. The model constructs a spatial weight matrix based on the adjacency matrix and distance matrix through the autocorrelation feature selection algorithm. The spatial weight matrix reflects the intensity of the interaction between sites, that is, the magnitude of the impact between sites. For example, sites that are closer or directly adjacent may be given higher weights because they may have a greater impact on the water quality changes of the target site. The model uses the spatial weight matrix to weighted average or weighted sum the water quality data of neighboring sites. This means that for any target site water quality data input into the model, the data from neighboring sites will be adjusted according to their weights in the spatial weight matrix, and then combined with the data of the target site to form a comprehensive input feature vector.
[0097] The adjacency matrix describes the connectivity between water quality monitoring sites, that is, which sites are directly connected. The adjacency matrix can help the model identify which neighboring sites’ water quality changes may have a direct impact on the target site. The model can include the water quality data of these neighboring sites as additional features to enhance the accuracy of the prediction. The distance matrix provides information on the geographic distance between sites. The distance matrix can assist the model in determining which sites’ impacts will weaken as the distance increases. By analyzing the distance matrix, the model can quantify the degree of attenuation of spatial influences, thereby more accurately assessing the impact of near and far sites on the water quality of the target site. Using only water quality time series may ignore spatial factors, but after adding the adjacency matrix and distance matrix, the model can identify and utilize the impact of spatial proximity on water quality changes and improve prediction accuracy.
[0098] Reference Figure 2 , the method for time alignment of water quality indicator sequences is as follows:
[0099] S100: Select one monitoring site as a reference site; extract each water quality index sequence of the reference site as the reference sequence of each water quality index data; add all monitoring sites other than the reference site to the target site set;
[0100] S200: removing a monitoring site from the target site set, and extracting each water quality indicator sequence of the removed monitoring site as a target sequence for each water quality indicator sequence;
[0101] S300: aligning the target sequence of each water quality indicator with the reference sequence through dynamic time warping; if the target sequence of any water quality indicator is different from the reference sequence in length, interpolating and sampling the target sequence to make the target sequence and the reference sequence in length consistent;
[0102] S400: Repeat steps S200-S300 until the target site set is empty, completing the time alignment of the water quality indicator sequence.
[0103] Dynamic time warping technology can adjust the time difference between data recorded at different monitoring points to ensure the consistency of the water quality indicator sequence at each monitoring point.
[0104] S4: Determine the characteristic dimensions of the water quality indicator sequence;
[0105] The input feature dimension K indicates that any element in any water quality index sequence is highly correlated with its previous K elements; in subsequent model training and deployment applications, the predicted value of each water quality index data is calculated by the previous K elements adjacent to it in the water quality index sequence. Figure 3 , the method to determine the feature dimension is as follows:
[0106] S401: Calculate the autocorrelation coefficient of each lag order of any water quality index sequence; the formula is as follows:
[0107]
[0108] Among them, ρ k represents the autocorrelation coefficient of the water quality index sequence when the lag order is k; E(·) represents the mean value; x t represents the tth element in the water quality index sequence; x t+k represents the t+kth element in the water quality index sequence; μ represents the mean of all elements in the water quality index sequence;
[0109] S402: Calculate the standard error of the autocorrelation coefficient for each lag order; the formula is as follows:
[0110]
[0111] Among them, S(ρ k ) represents the autocorrelation coefficient ρ k The standard error of h It represents the autocorrelation coefficient of the water quality index series when the lag order is h;
[0112] S403: Construct the t statistic of each autocorrelation coefficient based on the autocorrelation coefficient and the standard error of the autocorrelation coefficient. The formula is as follows:
[0113]
[0114] Among them, t k represents the autocorrelation coefficient ρ k The t-statistic of
[0115] S404: Perform a significance test on the t statistic of each autocorrelation coefficient; calculate the lag order of the autocorrelation coefficient that is significantly non-zero, and select the largest lag order as the characteristic dimension of the water quality index sequence. For example, if the autocorrelation coefficients of lag orders 1, 2, 3, 4, and 5 are significantly non-zero, then the characteristic dimension of the water quality index sequence is 5.
[0116] S5: constructing a water quality prediction model, and training the water quality prediction model based on the water quality index sequence and the spatial topological information of the water quality index data;
[0117] The water quality prediction model includes a single-step prediction sub-model, a short-term prediction sub-model, and a medium-term prediction sub-model; the model input of any water quality prediction model includes each water quality indicator sequence of all detection sites, as well as the adjacency matrix and the distance matrix.
[0118] Transformer is a generative neural network that effectively captures dependencies in sequences through self-attention mechanisms and position encoding, and is widely used to predict, classify, and generate time series data. This paper refers to the advanced Transformer architecture. In order to meet the needs of water pollution prediction, the Encoder-Decoder framework of the traditional Transformer is modified, the Encoder layer is removed, and the Decoder-on ly architecture is used to predict water quality index data, so that the model can focus on the tasks of prediction and sequence generation. Figure 4 , the structure of any water quality prediction model includes feature selection layer, feature mapping layer, position encoding layer, decoding layer, and output layer; among them:
[0119] The feature selection layer is configured with an autocorrelation feature selection algorithm for feature screening of the model input; it not only considers the time series characteristics of the water quality index sequence of a single monitoring site, but also uses spatial topological information (including adjacency matrix and distance matrix) to identify which monitoring site data are most critical for predicting the water quality index data of each monitoring site. For example, if the water quality changes at adjacent sites are strongly correlated with the target site, the data at the adjacent sites will be retained first. Through the autocorrelation feature selection algorithm, the model identifies and retains the data most relevant to predicting water quality changes, eliminates noise and irrelevant data, and can improve the focus and prediction efficiency of the model.
[0120] The feature mapping layer is used to map the model input after feature screening into a high-dimensional vector; further converting the model input into a high-dimensional vector can provide a richer expression basis for subsequent data processing. The input data after feature selection is mapped to a high-dimensional space to enhance the model's ability to learn the changing trends of complex water quality index data. High-dimensional mapping can be achieved through kernel functions, neural networks, etc.
[0121] The position encoding layer is used to add position encoding to the high-dimensional vector; adding position encoding enables the model to understand and utilize the relative position information of different time points in the time series. Since the model used in this embodiment is based on the self-attention mechanism and does not contain a loop or convolution structure, additional position information is required to distinguish different positions in the sequence. The position encoding layer is used to add this position information.
[0122] The decoding layer includes two consecutive Transformer decoders; each Transformer decoder includes a self-attention module and a feedforward neural network module; the self-attention module is used to capture the relationship between the unknown encoded high-dimensional vector or the feature vector output by the previous encoder, and output the self-attention vector; the feedforward neural network module is used to perform nonlinear transformation on the self-attention vector and output the feature vector; the decoder uses the self-attention mechanism to enable the model to dynamically consider the relationship between the water quality index data at the current time point and the water quality index data at all past time points, as well as the potential impact caused by spatial adjacency or distance between these data. The feedforward neural network then performs deep nonlinear modeling on these relationships to enhance the model's ability to dynamically capture complex water quality index data.
[0123] The output layer is used to calculate and output the predicted value of the water quality index data of each water quality index sequence; the above model structure can use historical data and spatial information to infer the future trend of water quality index data changes.
[0124] The number of neurons in the output layer of the single-step prediction sub-model is m·n, and the output is the predicted value of the water quality index data at a future time point of each water quality index sequence; wherein m is the number of types of water quality index sequences, and in this embodiment, the value of m is 5; and n is the number of monitoring sites;
[0125] The number of neurons in the output layer of the short-term prediction sub-model is m·n·p, and the output is the predicted value of the water quality index data at p consecutive time points in the future of each water quality index sequence;
[0126] The number of neurons in the output layer of the mid-term prediction sub-model is m·n·q, and the output is the predicted value of the water quality index data at q consecutive time points in the future of each water quality index sequence;
[0127] Among them, p and q are both positive integers, and 1<p<q; such an output layer configuration allows different sub-models to perform single-step and multi-step predictions to meet the water quality prediction needs of different time spans.
[0128] The water quality index sequence is divided into training set, validation set and test set, and the water quality prediction model is trained, verified and tuned, and tested and tuned in sequence. During the model training process, the learning rate is dynamically adjusted to prevent overfitting. The trained water quality prediction model is saved and deployed in the central water quality monitoring system.
[0129] S6: Collect real-time water quality index data and perform spatiotemporal water quality prediction based on the water quality prediction model; the method is as follows:
[0130] Continuously collect real-time water quality index data from each monitoring site and transmit it to the central water quality monitoring system;
[0131] The central water quality monitoring system cleans and standardizes the real-time water quality index data of each monitoring site, updates each water quality index sequence of each monitoring site, calls the water quality prediction model, predicts each water quality index data of each monitoring site based on the updated water quality index sequence, and visualizes the prediction results.
[0132] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0133] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the purpose and scope of protection of the present invention, which are all within the protection of the present invention.
Claims
1. A method for spatiotemporal prediction of water quality in a water network based on a generative neural network model, characterized in that: The following steps are involved: S1: Obtain water quality monitoring data set of water network, extract water quality index data and perform data cleaning on water quality index data; S2: establishing a water quality index sequence based on the water quality index data, and performing smoothing on the water quality index sequence; S3: Format the spatial information of water quality index data, obtain the spatial topological information of water quality index data, and perform time alignment of water quality index sequences; S4: Determine the characteristic dimensions of the water quality indicator sequence; S5: constructing a water quality prediction model, and training the water quality prediction model based on the water quality index sequence and the spatial topological information of the water quality index data; S6: Collect real-time water quality index data, and perform spatiotemporal prediction of water quality based on the water quality prediction model.
2. The method for spatiotemporal prediction of water quality in a water network based on a generative neural network model according to claim 1, characterized in that: The water quality monitoring data set of the water network includes water quality index data recorded by each monitoring station of the water network; the water quality index data includes total nitrogen value, dissolved oxygen, conductivity, total phosphorus value, and pH value; The data cleaning includes filling missing values and replacing abnormal values; The water quality index sequence is a time series of each water quality index data of each monitoring site; the establishment method is as follows: standardize all water quality index data; organize each standardized water quality index data of each monitoring site into a water quality index sequence in chronological order; The smoothing method is to smooth the water quality index data in the water quality index sequence through a sliding window, and the formula involved is as follows: Among them, x i represents the i-th element in any smoothed water quality index sequence; y i-j represents the ijth element in the water quality index sequence before smoothing; N is the sliding window size.
3. The method for spatiotemporal prediction of water quality in a water network based on a generative neural network model as claimed in claim 2, characterized in that: The method for obtaining the spatial topological information of water quality index data is as follows: Get the longitude and latitude coordinates of each monitoring site; Calculate the distance between each monitoring site and all other monitoring sites based on their latitude and longitude coordinates; Construct an adjacency matrix and a distance matrix for all monitoring sites; wherein the adjacency matrix is used to represent the adjacency relationship between monitoring sites, and the distance matrix is used to represent the distance between detection sites.
4. The method for spatiotemporal prediction of water quality in a water network based on a generative neural network model as claimed in claim 3, characterized in that: The adjacency matrix is in the following form: Among them, A represents the adjacency matrix, a ij represents the adjacency relationship between the ith monitoring station and the jth monitoring station. If the ith monitoring station is adjacent to the jth monitoring station, then a ij The value of is 1, otherwise, a ij The value of is 0; the value range of i and j is 1, 2, ..., n, where n is the total number of monitoring sites; The rules for judging whether any two monitoring sites are adjacent are as follows: if the distance between any monitoring site a and any monitoring site b is less than the threshold distance, then monitoring site a and monitoring site b are adjacent; if the distance between monitoring site a and monitoring site b is not less than the threshold distance, and monitoring site a and monitoring site b are in the same tributary, then monitoring site a and monitoring site b are adjacent; if the distance between monitoring site a and monitoring site b is not less than the threshold distance, and monitoring site a and monitoring site b are not in the same tributary, then monitoring site a and monitoring site b are not adjacent.
5. The method for spatiotemporal prediction of water quality in a water network based on a generative neural network model as claimed in claim 4, characterized in that: The method for time alignment of water quality indicator sequences is as follows: S100: Select one monitoring site as a reference site; extract each water quality index sequence of the reference site as the reference sequence of each water quality index data; add all monitoring sites other than the reference site to the target site set; S200: removing a monitoring site from the target site set, and extracting each water quality indicator sequence of the removed monitoring site as a target sequence for each water quality indicator sequence; S300: Align the target sequence of each water quality indicator with the reference sequence through dynamic time warping; If the target sequence and reference sequence lengths of any water quality indicator are different, the target sequence is interpolated and sampled to make the target sequence and reference sequence lengths consistent; S400: Repeat steps S200-S300 until the target site set is empty, completing the time alignment of the water quality indicator sequence.
6. The method for spatiotemporal prediction of water quality in a water network based on a generative neural network model according to claim 5, characterized in that: The method for determining the characteristic dimension of the water quality index sequence is as follows: S401: Calculate the autocorrelation coefficient of each lag order of any water quality index sequence; the formula is as follows: Among them, ρ k represents the autocorrelation coefficient of the water quality index sequence when the lag order is k; E(·) represents the mean value; x t represents the tth element in the water quality index sequence; x t+k represents the t+kth element in the water quality index sequence; μ represents the mean of all elements in the water quality index sequence; S402: Calculate the standard error of the autocorrelation coefficient for each lag order; the formula is as follows: Among them, S(ρ k ) represents the autocorrelation coefficient ρ k The standard error of h It represents the autocorrelation coefficient of the water quality index series when the lag order is h; S403: Construct the t statistic of each autocorrelation coefficient based on the autocorrelation coefficient and the standard error of the autocorrelation coefficient. The formula is as follows: Among them, t k represents the autocorrelation coefficient ρ k The t-statistic of S404: Perform a significance test on the t statistic of each autocorrelation coefficient; calculate the lag order of the autocorrelation coefficient that is significantly not zero, and select the largest lag order as the characteristic dimension of the water quality indicator sequence.
7. The method for spatiotemporal prediction of water quality in a water network based on a generative neural network model according to claim 6, characterized in that: The water quality prediction model includes a single-step prediction sub-model, a short-term prediction sub-model, and a medium-term prediction sub-model; the model input of any water quality prediction model includes each water quality index sequence of all detection sites, as well as the adjacency matrix and the distance matrix; The structure of any water quality prediction model includes feature selection layer, feature mapping layer, position encoding layer, decoding layer, and output layer; among them: The feature selection layer is configured with an autocorrelation feature selection algorithm for feature screening of model input; The feature mapping layer is used to map the model input after feature screening into a high-dimensional vector; The position coding layer is used to add position coding to the high-dimensional vector; The decoding layer includes two consecutive Transformer decoders; each Transformer decoder includes a self-attention module and a feedforward neural network module; the self-attention module is used to capture the relationship between the unknown encoded high-dimensional vector or the feature vector output by the previous encoder, and output the self-attention vector; the feedforward neural network module is used to perform nonlinear transformation on the self-attention vector and output the feature vector; The output layer is used to calculate and output the predicted value of the water quality index data of each water quality index sequence.
8. The method for spatiotemporal prediction of water quality in a water network based on a generative neural network model according to claim 7, characterized in that: The number of neurons in the output layer of the single-step prediction sub-model is m·n, and the output is the predicted value of the water quality index data at a future time point of each water quality index sequence; wherein m is the number of types of water quality index sequences; n is the number of monitoring sites; The number of neurons in the output layer of the short-term prediction sub-model is m·n·p, and the output is the predicted value of the water quality index data at p consecutive time points in the future of each water quality index sequence; The number of neurons in the output layer of the mid-term prediction sub-model is m·n·q, and the output is the predicted value of the water quality index data at q consecutive time points in the future of each water quality index sequence; Wherein, p and q are both positive integers, and 1<p<q.
9. The method for spatiotemporal prediction of water quality in a water network based on a generative neural network model according to claim 8, characterized in that: The method for performing spatiotemporal water quality prediction is as follows: Continuously collect real-time water quality index data from each monitoring site and transmit it to the central water quality monitoring system; The central water quality monitoring system cleans and standardizes the real-time water quality index data of each monitoring site, updates each water quality index sequence of each monitoring site, calls the water quality prediction model, predicts each water quality index data of each monitoring site based on the updated water quality index sequence, and visualizes the prediction results.
Citation Information
Cited By
Water purifier control method based on deep mixed Q network
CN120337990A
A Water Purifier Control Method Based on Deep Hybrid Q-Network
CN120337990B
Automatic calibration method and system for starting electrode of intelligent water station
CN120721822A
