A method for dynamic monitoring of microbial contamination in water supply pipelines and prediction of disinfection response

The microbial pollution prediction model of water supply pipelines is constructed through online sensors and deep learning models (enhanced residual convolution module, LSTM network and multi-head mixed feature attention mechanism), which solves the problem of poor real-time performance of traditional monitoring methods and realizes microbial pollution of water supply pipelines Real-time monitoring and prediction improves emergency response capabilities and disinfection efficiency.

CN118568448BActive Publication Date: 2024-12-10JINAN CUP OF WATER ENVIRONMENTAL PROTECTION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411061372.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-05
Publication Date
2024-12-10
Estimated Expiration
2044-08-05

AI Technical Summary

Technical Problem

The detection period of microbial pollution monitoring methods in traditional water supply pipelines is long and have poor real-time performance, and cannot promptly reflect the dynamic changes in pollution, resulting in the inability to take disinfection response measures in a timely manner, affecting the safety of water supply.

Method used

The water quality data is collected in real time by online sensors, and combined with the enhanced residual convolution module, the improved LSTM network model and the multi-head mixed feature attention mechanism module, the water supply pipeline microbial pollution prediction model is built to realize dynamic monitoring and disinfection response prediction of microbial pollution.

Benefits of technology

It improves the emergency response capacity of the water supply system, reduces the excessive use of disinfectants, reduces costs and environmental impacts, and improves the level of water supply safety management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118568448B_ABST
    Figure CN118568448B_ABST
Patent Text Reader

Abstract

The present invention proposes a method for dynamic monitoring and disinfection response prediction of water supply pipeline microbial contamination, which relates to the field of microbial contamination response prediction. The present invention proposes a water supply pipeline microbial contamination prediction process, including collecting microbial contamination data, preprocessing microbial contamination data, building a water supply pipeline microbial contamination prediction model, training the water supply pipeline microbial contamination prediction model using a training set, and performing a microbial contamination prediction test on the prediction model using a test set. The water supply pipeline microbial contamination prediction model consists of an enhanced residual convolution module, a GRU model, and a multi-head mixed feature attention mechanism module. The prediction model uses convolution kernels of different sizes to capture features of different scales, and captures long-term and short-term dependencies in time series at the same time. The outputs of the first two are jointly input into the multi-head mixed feature attention mechanism module to enhance the prediction model's ability to focus on important information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of microbial contamination response prediction, and in particular relates to a method for dynamic monitoring of microbial contamination in a water supply pipeline and prediction of disinfection response. Background Art

[0002] As a key component of the urban water supply system, the quality and safety of water supply pipelines are directly related to the health and quality of life of residents. Microbial contamination in water supply pipelines is one of the important threats to water supply safety. Microbial contamination mainly includes bacteria, viruses, fungi and protozoa. These microorganisms not only lead to water quality degradation and affect the sensory indicators of water, such as turbidity, color and odor, but also may cause a variety of waterborne diseases. In order to deal with microbial contamination in water supply pipelines, effective monitoring and control measures need to be taken. Traditional water quality monitoring methods mainly rely on regular sampling and laboratory testing, which have the problems of long detection cycle, poor real-time performance and inability to reflect the dynamic changes of pollution in a timely manner. Therefore, modern water supply systems urgently need a technology that can achieve real-time monitoring and early warning, so as to take disinfection response measures in time to ensure water supply safety.

[0003] With the development of sensing technology and information technology, water supply safety management systems based on online monitoring and intelligent prediction have gradually become a research hotspot. Online microbial sensor technology can monitor the concentration of microorganisms in water in real time. Combined with big data analysis and artificial intelligence algorithms, it can realize dynamic monitoring of microbial contamination in water supply pipelines and prediction of disinfection response. Specifically, by deploying online sensors in water supply pipelines, water quality data such as microbial concentration, pH value, temperature and turbidity are collected in real time. Advanced prediction models are used to analyze and process the collected data, predict future pollution trends, and automatically adjust the amount of disinfectant added according to the prediction results to achieve the purpose of preventing and controlling microbial contamination. In order to solve this problem, the present invention proposes a water supply pipeline microbial contamination prediction model.

[0004] By preprocessing the collected data, the water supply pipeline microbial contamination data is obtained, and then the prediction model is trained. The water supply pipeline microbial contamination prediction model proposed in the present invention is composed of an enhanced residual convolution module, an improved LSTM network model GRU, and a multi-head mixed feature attention mechanism module. The model has a high prediction accuracy; the dynamic monitoring and prediction method of water supply pipeline microbial contamination not only improves the emergency response capability of the water supply system, but also reduces the excessive use of disinfectants, reduces costs and environmental impacts, and has important application value and social benefits. Therefore, the development of a water supply pipeline microbial contamination dynamic monitoring and disinfection response prediction method based on online monitoring and intelligent prediction is of great significance to improving the level of water supply safety management and protecting the health of residents. Summary of the invention

[0005] The main purpose of the present invention is to provide a method for dynamic monitoring and disinfection response prediction of microbial contamination in water supply pipelines, aiming to construct a water supply pipeline microbial contamination prediction model, which consists of an enhanced residual convolution module, an improved LSTM network model and a multi-head mixed feature attention mechanism module; the enhanced residual convolution module captures features of different scales by using convolution kernels of different sizes, and uses the GRU model to capture long-term and short-term dependencies in time series. Finally, the outputs of the first two are jointly input into the multi-head mixed feature attention mechanism module, and the multi-head mixed feature attention mechanism module combines feature inputs from different sources to enhance the model's ability to focus on important information in the input data.

[0006] To achieve the above objectives, the technical solution of the present invention is: a method for dynamic monitoring of microbial contamination in water supply pipelines and prediction of disinfection response, the method comprising:

[0007] S1. Collect and monitor microbial contamination data in water supply pipes, with the collection frequency set to once an hour. The microbial contamination data types include microbial concentration, water quality parameters, and flow parameter values;

[0008] S2, preprocessing the microbial contamination data, wherein the preprocessing includes data cleaning, data standardization, and time series segmentation operations, and dividing the processed data into a training set and a test set;

[0009] S3. Construct a water supply pipeline microbial contamination prediction model, which consists of an enhanced residual convolution module ERC, an improved LSTM network model GRU, and a multi-head hybrid feature attention mechanism module HFAttention. The specific steps are as follows:

[0010] S31. The enhanced residual convolution module ERC is proposed to enhance the feature extraction capability through one-dimensional convolution and dimension adjustment.

[0011] S32. An improved LSTM network model GRU is proposed, and the gating mechanism of GRU is used to preferentially transmit the most important information, where the most important information is the key information that needs to be retained and transmitted in a long time series;

[0012] S33. A multi-head hybrid feature attention mechanism module HFAttention is proposed. The output of the enhanced residual convolution module and the GRU module are combined as the feature input of HFAttention to enhance the prediction model's ability to focus on important information in the data. The important information includes the relationship between local features, long-term dependencies, temporal features, and multi-dimensional features.

[0013] S4. Use the training set to train the water supply pipeline microbial contamination prediction model, including model hyperparameter setting and back propagation process;

[0014] S5. Use the test set to perform a microbial contamination prediction test on the prediction model to obtain the prediction value of the prediction model for the microbial contamination of the water supply pipeline.

[0015] Furthermore, in the steps S3 and S31, by using convolution kernels of different sizes, the model can capture features of different scales. Input data The shape is ,in is the size of the window, is the dimension of the feature; the number of convolution kernels used in the present invention is , the size of each convolution kernel is divided into , small convolution kernels can capture local, fine-grained features, while large convolution kernels can capture broader global patterns. The convolution kernel size is The convolution operation formula is as follows:

[0016]

[0017] In the formula, ReLU is the activation function, is the dot multiplication operation, is the bias term of the convolution kernel, For input data The subsequence intercepted from Row data, ending at Row data, The convolution kernel size is In the weight matrix Row weight data, The convolution operation is performed at the input data time step Output on;

[0018] Then the output of each layer of convolution operation is concatenated to produce a total output of the convolution operation , the splicing formula is as follows:

[0019]

[0020] In the formula, is the matrix concatenation operation, The convolution kernel size is The output after the convolution operation, The shape is ;

[0021] In order to use the residual connection to connect the final total output of the convolution to the input of the convolution operation, the convolution kernel is used as For each time step Input data Perform a convolution operation and get a shape of The output of each time step The output of the enhanced residual convolution module is , the calculation formula is The outputs of all time steps form the final output matrix , The size is , where is the number of samples.

[0022] Furthermore, in the steps S3 and S32, the improved LSTM model GRU is used to capture the long-term and short-term dependencies in the time series. The initial gate, change gate and new memory content in the GRU act together on the input data and the previous hidden state to determine the hidden state of the current time step; the input of the GRU comes from the original data , each time step After the GRU module, a hidden state is generated , the specific calculation steps are as follows:

[0023] The first is the initial gate, which controls how much hidden state information of the previous time step is discarded. The weight matrix from the previous hidden state to the initial gate Perform a product operation with the input data to the weight matrix of the initial gate and the current time step Input data The results of the product operation are added to get the final output result of the initial gate , the specific calculation formula is as follows:

[0024]

[0025] In the formula, is an element-by-element multiplication operation, is an activation function used to limit the output to between [0, 1], is the bias term of the initial gate, For the The initial gate output of the time step ranges from [0, 1];

[0026] The second is the change gate, which determines how much information is retained from the previous hidden state to the current hidden state. The weight matrix from the previous hidden state to the change gate Perform product operation and input data to the weight matrix of the variable gate and the current time step Input data The results of the product operation are added to get the final output result of the variable gate. , the specific calculation formula is as follows:

[0027]

[0028] In the formula, is the bias term of the variable gate, For the The output of the variable gate at each time step is in the range of [0,1];

[0029] Then, the output of the initial gate and the change gate are combined to generate a new candidate hidden state. The calculation formula is as follows:

[0030]

[0031] In the formula, is the activation function, limiting the output to [-1,1], For the candidate hidden states for time steps, is the weight matrix from input data to candidate hidden states, is the weight matrix from the previous hidden state to the candidate hidden state, is the bias of the candidate hidden state;

[0032] Finally, the final hidden state of the current time step is determined by combining the change gate and the candidate hidden state. , this state is the final output state of a layer of GRU network, and the calculation formula is as follows:

[0033]

[0034] In the formula, is the output of the final new hidden state; each time step The GRU module generates a sequence of hidden states , and finally the GRU module output is concatenated to obtain , whose internal data is represented as , hidden state sequence The shape is .

[0035] Furthermore, in the steps S3 and S33, a multi-head hybrid feature attention mechanism is proposed, which combines the output of the enhanced residual convolution module and the GRU module as the feature input of HFAttention to enhance the prediction model's ability to focus on important information in the data, wherein the important information includes the relationship between local features, long-term dependencies, temporal features, and multi-dimensional features; in the hybrid feature attention mechanism, the output of the GRU model is used as the feature input of the HFAttention. As the query vector in the HFAttention module The input contains the long-term and short-term dependency information in the time series data. ; The output of the enhanced residual convolution module As the key vector in the HFAttention module With value vector Input, , the output after the enhanced residual convolution module captures the local patterns and details in the input data; the specific implementation steps of the multi-head hybrid feature attention mechanism are as follows:

[0036] First, the attention score is calculated. For each head, the query vector is calculated using the scaled dot product and key vector The similarity score between them is calculated as follows:

[0037]

[0038] In the formula, For the The query vector projection matrix of each head, For the The key vector projection matrix of each head, is the dimension of the key vector;

[0039] The attention score for each head is calculated using The function is normalized to obtain the attention weight, and the calculation formula is as follows:

[0040]

[0041] In the formula, For the Position and The attention weight of each head, is the activation function;

[0042] The value vector is then weighted and summed using the attention weight to obtain the output of each attention head. The formula is as follows:

[0043]

[0044] In the formula, For the The output of an attention head is For the The value vector projection matrix of the attention head;

[0045] Finally, the outputs of all attention heads are concatenated and transformed into the final output feature representation through linear transformation. The formula is expressed as:

[0046]

[0047] In the formula, is the final output of multi-head attention, is the number of attention heads, For the splicing operation; the final output The final prediction value of the model is output through the feed-forward layer.

[0048] In summary, due to the adoption of the above technical solution, the beneficial effects of the present invention are:

[0049] In the present invention, a water supply pipeline microbial contamination prediction model is constructed, which consists of an enhanced residual convolution module, an improved LSTM network model and a multi-head mixed feature attention mechanism module; the enhanced residual convolution module captures features of different scales by using convolution kernels of different sizes, and uses a GRU model to capture long-term and short-term dependencies in time series. Finally, the outputs of the first two are jointly input into the multi-head mixed feature attention mechanism module, and the multi-head mixed feature attention mechanism module combines feature inputs from different sources to enhance the model's ability to focus on important information in the input data. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 The present invention is a flowchart of the steps of a method for dynamic monitoring of microbial contamination in water supply pipelines and prediction of disinfection response.

[0051] Figure 2 The present invention is a flow chart of a water supply pipeline microbial contamination prediction model in a water supply pipeline microbial contamination dynamic monitoring and disinfection response prediction method.

[0052] Figure 3 Schematic diagram of the convolution operation of the enhanced residual convolution module in a method for dynamic monitoring of microbial contamination and disinfection response prediction of water supply pipelines.

[0053] Figure 4 This is a structural diagram of the GRU module in a method for dynamic monitoring of microbial contamination in water supply pipelines and prediction of disinfection response.

[0054] Figure 5 This is a structural diagram of the mixed feature attention mechanism in a method for dynamic monitoring of microbial contamination in water supply pipelines and prediction of disinfection response.

[0055] Figure 6 This is a fitting diagram of the predicted value and true value of the water supply pipeline microbial contamination prediction model on the test set in a water supply pipeline microbial contamination dynamic monitoring and disinfection response prediction method.

[0056] Figure 7 Real-time monitoring of the changes in the number of biofilm bacteria. DETAILED DESCRIPTION

[0057] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments; based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0058] See also Figure 1-Figure 7 The present invention provides a technical solution: a method for dynamic monitoring and disinfection response prediction of microbial contamination in water supply pipelines. The method constructs a water supply pipeline microbial contamination prediction model, introduces an enhanced residual convolution module to capture features of different scales by using convolution kernels of different sizes, and uses a GRU model to capture long-term and short-term dependencies in time series. Finally, the outputs of the first two are jointly input into a multi-head mixed feature attention mechanism module. The multi-head mixed feature attention mechanism module combines feature inputs from different sources to enhance the model's ability to focus on important information in the input data.

[0059] Please refer to Figure 1 As shown, a method for dynamic monitoring of microbial contamination in water supply pipelines and prediction of disinfection response in an embodiment of the present application is as follows:

[0060] Collect and monitor microbial contamination data in water supply pipes, with the collection frequency set to once an hour. The microbial contamination data types include microbial concentration, water quality parameters, and flow parameter values.

[0061] Furthermore, in step S1, fluorescent microscope sensors, microbial detection sensors based on PCR technology, and multi-parameter water quality monitors are deployed at key nodes of the water supply pipeline, such as water source inlets, main water supply pipelines, secondary water supply systems, and residential distribution points; in the data types, microbial concentrations include the concentrations of bacteria, viruses, fungi, and protozoan microorganisms in the water; water quality parameters include water temperature, pH value, dissolved oxygen, turbidity, conductivity, and redox potential; and flow data include water flow velocity and flow rate in the channel; according to the actual conditions of the water supply system and the dynamic changes in microbial contamination, the present invention sets the data acquisition frequency to one hour to achieve continuous monitoring of sensors and real-time data uploading, thereby avoiding interruptions and delays in data acquisition.

[0062] S2. Preprocessing the microbial contamination data includes data cleaning, data standardization, and time series segmentation operations, and dividing the processed data into a training set and a test set.

[0063] Furthermore, in step S2, there are a small number of randomly distributed missing values ​​in the collected data. The present invention directly deletes the data points containing missing values. In order to eliminate the dimensional differences between different data features and make the data comparable on a uniform scale, the minimum-maximum normalization operation is used to scale the data to the range of [0, 1]. The minimum-maximum normalization formula is as follows:

[0064]

[0065] In the formula, is the data value to be normalized, For data The maximum value among the eigenvalues, For data The minimum value among the eigenvalues, for Values ​​after min-max normalization;

[0066] In order to generate a data set suitable for model training, the present invention uses the sliding window method to segment the collected data set into time series, setting the window length to , the sliding step length is , the original time series is , the data subsequence after sliding window is , because the last window will not have subsequent data points to predict, so the number of subsequences It can be calculated by the following formula:

[0067]

[0068] In the formula, is the window length, set to 10, is the sliding step size, set to 1, is the number of samples, which is 200; finally, the processed data is divided into training set and test set in a ratio of 7:3.

[0069] S3. Construct a water supply pipeline microbial contamination prediction model. The model process is as follows: Figure 2 As shown in the figure, the prediction model consists of an enhanced residual convolution module ERC, an improved LSTM network model GRU and a multi-head hybrid feature attention mechanism module HFAttention. The specific steps are as follows.

[0070] S31. An enhanced residual convolution module ERC is proposed to enhance the feature extraction capability through one-dimensional convolution and dimensionality adjustment.

[0071] Furthermore, in step S31, the ERC module combines one-dimensional convolution, residual connection and dimension adjustment convolution operations, and captures multi-scale features by using multi-layer convolutions with different convolution kernel sizes. The convolution kernel adjusts the input dimension, implements residual connection, and enhances the expressiveness and robustness of the model. The specific steps are as follows:

[0072] For each time step Input data The shape is ,in is the size of the window, is the dimension of the feature; the number of convolution kernels used in the present invention is , the size of each convolution kernel is divided into , the convolution operation is as follows Figure 3 As shown in Figure 2, small convolution kernels can capture local, fine-grained features, while large convolution kernels can capture broader global patterns. The convolution kernel size is The convolution operation formula is as follows:

[0073]

[0074] In the formula, ReLU is the activation function, is the dot multiplication operation, is the bias term of the convolution kernel, For input data The subsequence intercepted from Row data, ending at Row data, The convolution kernel size is In the weight matrix Row weight data, The convolution operation is performed at the input data time step Output on;

[0075] Then the output of each layer of convolution operation is concatenated to produce a total output of the convolution operation , the splicing formula is as follows:

[0076]

[0077] In the formula, is the matrix concatenation operation, The convolution kernel size is The output after the convolution operation, The shape is ;

[0078] In order to use the residual connection to connect the final total output of the convolution to the input of the convolution operation, the convolution kernel is used as For each time step Input data Perform a convolution operation and get a shape of The output of each time step The output of the enhanced residual convolution module is , the calculation formula is The outputs of all time steps form the final output matrix , The size is ; Residual connections help alleviate the gradient vanishing problem while retaining the original input information and the features extracted by the convolutional layer;

[0079] Furthermore, in step S31, the use of one-dimensional convolution operation to process multivariate time series data has the advantages of high efficiency and simple implementation, and can effectively capture time dependencies; combined with different convolution kernel sizes, the model can extract multi-scale features, enhance the richness of feature representation and the robustness of the model, reduce the risk of overfitting, and improve prediction accuracy; through the comprehensive application of multi-layer convolution, different convolution kernel sizes, pooling layers and residual connections, the model can better process complex data and improve overall performance and adaptability.

[0080] S32. An improved LSTM network model GRU is proposed, and the gating mechanism of GRU is used to preferentially transmit the most important information, where the most important information is the key information that needs to be retained and transmitted in a long time series.

[0081] Furthermore, in step S32, the improved LSTM model GRU is used to capture the long-term and short-term dependencies in the time series. The initial gate, change gate and new memory content in the GRU act together on the input data and the previous hidden state to determine the hidden state of the current time step. The GRU structure is as follows: Figure 4 As shown; the input of GRU comes from the original data , each time step After the GRU module, a hidden state is generated , the specific calculation steps are as follows:

[0082] The first is the initial gate, which controls how much hidden state information of the previous time step is discarded. The weight matrix from the previous hidden state to the initial gate Perform a product operation with the input data to the weight matrix of the initial gate and the current time step Input data The results of the product operation are added to get the final output result of the initial gate , the specific calculation formula is as follows:

[0083]

[0084] In the formula, is an element-by-element multiplication operation, is an activation function used to limit the output to between [0, 1], is the bias term of the initial gate, For the The initial gate output of the time step ranges from [0, 1];

[0085] The second is the change gate, which determines how much information is retained from the previous hidden state to the current hidden state. The weight matrix from the previous hidden state to the change gate Perform product operation and input data to the weight matrix of the variable gate and the current time step Input data The results of the product operation are added to get the final output result of the variable gate. , the specific calculation formula is as follows:

[0086]

[0087] In the formula, is the bias term of the variable gate, For the The output of the variable gate at each time step is in the range of [0,1];

[0088] Then, the output of the initial gate and the change gate are combined to generate a new candidate hidden state. The calculation formula is as follows:

[0089]

[0090] In the formula, is the activation function, limiting the output to [-1,1], For the candidate hidden states for time steps, is the weight matrix from input data to candidate hidden states, is the weight matrix from the previous hidden state to the candidate hidden state, is the bias of the candidate hidden state;

[0091] Finally, the final hidden state of the current time step is determined by combining the change gate and the candidate hidden state. , this state is the final output state of a layer of GRU network, and the calculation formula is as follows:

[0092]

[0093] In the formula, is the output of the final new hidden state; each time step The GRU module generates a sequence of hidden states , and finally the GRU module output is concatenated to obtain , whose internal data is represented as , hidden state sequence The shape is .

[0094] Furthermore, in step S32, the use of GRU can effectively capture the long-term and short-term dependencies in the time series. The gated unit uses a gate mechanism to control the flow of information, selectively retaining or forgetting outdated information, and avoiding the gradient vanishing and explosion problems common in traditional RNNs. This structure enables the gated unit to perform well in processing long sequences and has superior performance in many time series prediction tasks.

[0095] S33. A multi-head hybrid feature attention mechanism module HFAttention is proposed. The output of the enhanced residual convolution module and the GRU module are combined as the feature input of HFAttention to enhance the prediction model's ability to focus on important information in the data, including local features, long-term dependencies, temporal features, and the relationship between multidimensional features.

[0096] Furthermore, in step S33, a multi-head hybrid feature attention mechanism is used to combine feature inputs from different sources to enhance the model's ability to focus on important information in the input data; Figure 5 As shown, in the hybrid feature attention mechanism, the output of the GRU model is As the query vector in the HFAttention module The input contains the long-term and short-term dependency information in the time series data. ; The output of the enhanced residual convolution module As the key vector in the HFAttention module With value vector Input, , the output after the enhanced residual convolution module captures the local patterns and details in the input data; the specific implementation steps of the multi-head hybrid feature attention mechanism are as follows:

[0097] First, the attention score is calculated. For each head, the query vector is calculated using the scaled dot product and key vector The similarity score between them is calculated as follows:

[0098]

[0099] In the formula, For the The query vector projection matrix of each head, For the The key vector projection matrix of each head, is the dimension of the key vector;

[0100] The attention score for each head is calculated using The function is normalized to obtain the attention weight, and the calculation formula is as follows:

[0101]

[0102] In the formula, For the Position and The attention weight of each head, is the activation function;

[0103] The value vector is then weighted and summed using the attention weight to obtain the output of each attention head. The formula is as follows:

[0104]

[0105] In the formula, For the The output of an attention head is For the The value vector projection matrix of the attention head;

[0106] Finally, the outputs of all attention heads are concatenated and transformed into the final output feature representation through linear transformation. The formula is expressed as:

[0107]

[0108] In the formula, is the final output of multi-head attention, For the number of attention heads, set the value to 8. For splicing operation.

[0109] Furthermore, in step S33, the multi-head mixed feature attention mechanism can simultaneously focus on multiple feature patterns of the input data, and capture information from different feature subspaces through multiple attention heads. This mechanism enhances the model's ability to understand complex data, allowing the model to more finely decompose and process local and global relationships in the data; in addition, by integrating the spatial features from the convolutional layer and the temporal features of the GRU, the model can more comprehensively capture the key information in the data, thereby improving the accuracy of prediction and classification.

[0110] S4. Use the training set to train a water supply pipeline microbial contamination prediction model, wherein the training includes model hyperparameter setting and back propagation process.

[0111] Furthermore, in step S4, the output value of step S33 is The layer is tiled and then The layer outputs the final prediction value , the root mean square error loss function is used in this invention , the implementation formula is as follows:

[0112]

[0113] In the formula, is the total number of batch samples, which is numerically the same as the hyperparameter same, For the The true value of the samples, For the The predicted value of the sample model is is the loss function value, which is used to back propagate and adjust the model weight information; the model parameters are set as follows: , is 512, The number of iterations is 2000. The learning rate is 0.0001; the water supply pipeline microbial contamination prediction model constructed by training makes the model have a high prediction accuracy, which can meet the needs of predicting future microbial contamination and disinfection response.

[0114] S5. Use the test set to perform a microbial contamination prediction test on the prediction model to obtain the prediction value of the prediction model for the microbial contamination of the water supply pipeline.

[0115] Furthermore, in step S5, the trained prediction model is tested using a test set. Figure 6 This is the fitting of the predicted value and the true value of the prediction model on the test set. As can be seen from the figure, with the passage of time, the true value of the disinfection response is gradually increasing, and the predicted value of the model is also increasing accordingly, proving that the model can predict future microbial contamination. Figure 7 By monitoring the number of biofilm bacteria in real time, if the number of bacteria is gradually increasing, corresponding disinfection measures can be taken.

[0116] The above are only preferred embodiments of the present invention. It should be pointed out that a person skilled in the art can make several modifications and improvements without departing from the inventive concept of the present invention, and these all fall within the protection scope of the present invention.

Claims

1. A method for dynamic monitoring of microbial contamination in water supply pipelines and prediction of disinfection response, characterized in that: The following steps are involved: S1. Collect and monitor microbial contamination data in water supply pipes, with the collection frequency set to once an hour. The microbial contamination data types include microbial concentration, water quality parameters, and flow parameter values; S2, preprocessing the microbial contamination data, wherein the preprocessing includes data cleaning, data standardization, and time series segmentation operations, and dividing the processed data into a training set and a test set; S3. Construct a water supply pipeline microbial contamination prediction model, which consists of an enhanced residual convolution module ERC, an improved LSTM network model GRU, and a multi-head hybrid feature attention mechanism module HFAttention. The specific steps are as follows: S31, propose enhanced residual convolution module ERC, for each time step t input data X t The shape of is (ω, d), where ω is the size of the window and d is the dimension of the feature. The ability of feature extraction is enhanced through one-dimensional convolution and dimensionality adjustment; S32. An improved LSTM network model GRU is proposed. The input of GRU comes from the original data X. At each time step X t After the GRU module, a hidden state H is generated. t , using the gating mechanism of GRU to preferentially transmit the most important information, where the most important information is the key information that needs to be retained and transmitted in a long time series; S33. A multi-head hybrid feature attention mechanism module HFAttention is proposed. The output of the enhanced residual convolution module and the GRU module are combined as the feature input of HFAttention to enhance the prediction model's ability to focus on important information in the data. The important information includes the relationship between local features, long-term dependencies, temporal features, and multi-dimensional features. S4. Use the training set to train the water supply pipeline microbial contamination prediction model, including model hyperparameter setting and back propagation process; S5. Use the test set to perform a microbial contamination prediction test on the prediction model to obtain the prediction value of the prediction model for the microbial contamination of the water supply pipeline.

2. A method for dynamic monitoring of microbial contamination in water supply pipelines and prediction of disinfection response according to claim 1, characterized in that: In steps S3 and S31, by using convolution kernels of different sizes, the model captures features of different scales. For each time step t, the input data X t The shape of is (ω, d), where ω is the size of the window and d is the dimension of the feature; the number of convolution kernels used is ω, and the size of each convolution kernel is (1, d), (2, d), ..., (ω, d). Small convolution kernels capture local, fine-grained features, while large convolution kernels capture broader global patterns. The convolution operation formula with a convolution kernel size of ((j, dd)) is as follows: In the formula, ReLU is the activation function, · is the point multiplication operation, and b j is the bias term of the convolution kernel, X p:p+1 For input data X t The subsequence intercepted in starts at the pth row of data and ends at the p+1th row of data. is the weight data of the pth row in the weight matrix with a convolution kernel size of (j, d), is the output of the convolution operation at the input data time step t; Then the output of each layer of convolution operation is concatenated to produce a total output Y of the convolution operation. The concatenation formula is as follows: In the formula, Concat is the matrix concatenation operation, is the output after the convolution operation with a convolution kernel size of (j, d), Y t The shape of is (1, ω); In order to use the residual connection to connect the final total output of the convolution to the input of the convolution operation, the convolution kernel (1, d) is used for the input data X at each time step t. t Perform a convolution operation to obtain an output with a shape of (1, ω); the output of the enhanced residual convolution module at each time step t is O t , the calculation formula is O t =Y t +X t ; The outputs of all time steps t form the final output matrix O, the size of O is (n, ω), where n is the number of samples.

3. A method for dynamic monitoring of microbial contamination in water supply pipelines and prediction of disinfection response according to claim 2, characterized in that: In steps S3 and S32, the improved LSTM model GRU is used to capture the long-term and short-term dependencies in the time series. The initial gate, change gate and new memory content in the GRU act together on the input data and the previous hidden state to determine the hidden state of the current time step. The input of the GRU comes from the original data X. At each time step X t After the GRU module, a hidden state H is generated. t , the specific calculation steps are as follows: The first is the initial gate, which converts the hidden state H of the previous time step t-1 and the weight matrix U from the previous hidden state to the initial gate r Perform a product operation with the weight matrix W of the input data to the initial gate r and the input data X at the current time step t t The results of the product operation are added to get the final output result r of the initial gate t , the specific calculation formula is as follows: r t =Sigmoid(X t *W r +W r *H t-1 +b r ); In the formula, * is the element-by-element multiplication operation, Sigmoid is the activation function, which limits the output to [0, 1], and b r is the bias term of the initial gate, r t is the initial gate output at the tth time step, ranging between [0, 1]; The second is the change gate, which changes the hidden state H of the previous time step t-1 And the weight matrix U from the previous hidden state to the change gate z Perform a product operation and input data to the weight matrix W of the variable gate z and the input data X at the current time step t t The results of the product operation are added to get the final output result z of the variable gate. t , the specific calculation formula is as follows: z t =Sigmoid(X t *W z +W z *H t-1 +b z ); Where b z is the bias term of the variable gate, z t is the output of the variable gate at the tth time step, ranging between [0, 1]; Then, the output of the initial gate and the change gate are combined to generate a new candidate hidden state. The calculation formula is as follows: Ha t =(Tanh(X t *W+U*r t *H t-1 +b)); In the formula, Tanh is the activation function, which limits the output to [-1, 1], and Ha t is the candidate hidden state at the tth time step, W is the weight matrix from the input data to the candidate hidden state, U is the weight matrix from the previous hidden state to the candidate hidden state, and b is the bias of the candidate hidden state; Finally, the final hidden state H of the current time step is determined by combining the change gate and the candidate hidden state t , this state is the final output state of a layer of GRU network, and the calculation formula is as follows: H t =(1-z t )*H t-1 +z t *Ha t ; In the formula, H t is the output of the final new hidden state; each time step tGRU module generates a hidden state sequence H t Finally, the output of the GRU module is concatenated to obtain H, whose internal data is represented as H = {H1, H2, ..., H n }, the shape of the hidden state sequence H is ((n, ω).

4. A method for dynamic monitoring of microbial contamination in water supply pipelines and prediction of disinfection response according to claim 3, characterized in that: In steps S3 and S33, a multi-head hybrid feature attention mechanism is proposed, which combines the output of the enhanced residual convolution module and the GRU module as the feature input of HFAttention to enhance the prediction model's ability to focus on the relationship between local features, long-term dependencies, temporal features and multi-dimensional features in the data; in the hybrid feature attention mechanism, the output H of the GRU model is used as the input of the query vector Q in the HFAttention module, Q=H, which contains the long-term and short-term dependency information in the time series data; the output O of the enhanced residual convolution module is used as the input of the key vector K and the value vector V in the HFAttention module, K=V=Q, and the output after the enhanced residual convolution module captures the local patterns and details in the input data; the specific implementation steps of the multi-head hybrid feature attention mechanism are as follows: First, the attention score is calculated. For each head, the similarity score between the query vector Q and the key vector K is calculated using the scaled dot product, which is calculated as follows: In the formula, is the query vector projection matrix of the i-th head, is the key vector projection matrix of the i-th head, is the dimension of the key vector; The attention score of each head is normalized using the Softmax function to obtain the attention weight. The calculation formula is as follows: α t,i =Softmax(score i (Q,K)); In the formula, α t,i is the attention weight of the t-th position and the i-th head, and Softmax is the activation function; The value vector is then weighted and summed using the attention weight to obtain the output of each attention head. The formula is as follows: In the formula, head i is the output of the ith attention head, is the value vector projection matrix of the i-th attention head; Finally, the outputs of all attention heads are concatenated and transformed into the final output feature representation through linear transformation. The formula is expressed as: MultiHea(Q,K,V)=Concat(head1,head2,...,head sum ); Where MultiHead(Q, K, V) is the final output of the multi-head attention, sum is the number of attention heads, and Concat is the concatenation operation; the final output MultiHead(Q, K, V) is passed through the feedforward layer to output the final prediction value of the model.

5. A method for dynamic monitoring of microbial contamination in water supply pipelines and prediction of disinfection response according to claim 4, characterized in that: In step S4, the output value of step S33 is flattened through the Flatten layer, and then the final predicted value is output through the MLP layer. q ), the present invention uses the root mean square error loss function RMSE, and the implementation formula is as follows: In the formula, batch is the total number of batch samples, which is numerically the same as the hyperparameter batch_size, and y q is the true value of the qth sample, f(x q ) is the predicted value of the qth sample model, RMSE is the loss function value, which is used to back-propagate and adjust the model weight information; the model parameters are set as follows: the optimizer is Adam, the batch_size is 512, the number of Epochs iterations is 2000, and the LR learning rate is 0.0001.