Cascade control method of coagulant addition based on dual-stage attention mechanism

By applying the DA-RNN prediction model of the dual-stage attention mechanism in the water plant, combined with cascade control, the lag problem of coagulant dosage in the traditional method is solved, and more accurate turbidity control and water quality are achieved. The intelligence of the treatment process ensures the stability and safety of the effluent quality.

CN118426430BActive Publication Date: 2024-09-17NANJING UNIV OF POSTS & TELECOMM +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410898896.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-05
Publication Date
2024-09-17
Estimated Expiration
2044-07-05

AI Technical Summary

Technical Problem

Water plants rely on traditional methods to control the amount of coagulant, which results in poor turbidity removal due to lag time, making it difficult to cope with sudden changes in raw water quality and affecting drinking water safety.

Method used

The recurrent neural network DA-RNN prediction model based on the dual-stage attention mechanism is used, combined with cascade control, to accurately calculate the coagulant dosage and reduce the hysteresis effect by preprocessing and correcting the data.

Benefits of technology

It achieves more accurate and timely adjustment of coagulant dosage, ensures that the turbidity of the effluent is within a safe range, improves the intelligence and automation of the water treatment process, and improves treatment efficiency and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118426430B
    Figure CN118426430B
Patent Text Reader

Abstract

The present invention discloses a coagulant addition cascade control method based on a dual-stage attention mechanism, including: obtaining the pre-treated operation data of a water plant; according to the pre-treated operation data, based on a pre-trained DA-RNN prediction model, obtaining the coagulant dosage prediction value, the effluent turbidity prediction value and the sediment turbidity prediction value at the current moment, and correcting the effluent turbidity prediction value and the sediment turbidity prediction value based on the difference correction method of the lag time, respectively, to obtain the effluent turbidity correction value and the sediment turbidity correction value; based on the series coordination of the outer loop controller and the inner loop controller, the coagulant dosage feedback value is calculated, and then the coagulant dosage actual value is calculated to realize the coagulant addition cascade control. The present invention can provide a more accurate regulation of the dosage of the coagulant, ensure the high efficiency of the water treatment process and the stability of the effluent quality, and greatly improve the intelligence and automation of the treatment process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a coagulant dosing cascade control method based on a double-stage attention mechanism, and belongs to the technical field of coagulant dosing. Background Art

[0002] Facing the challenges of global water shortage and water purification technology, the coagulation process of water plants has become a key link in ensuring the safety of drinking water for urban and regional residents. The coagulation process is an important part of water purification in water plants. The addition of coagulants is to remove turbid substances, colloidal particles, microorganisms attached to these particles and other harmful substances in the water. Through this process, the cleanliness and safety of water quality are significantly improved.

[0003] At present, many water plants still use fixed-proportion manual control based on water flow or traditional feedback control methods to control the amount of coagulant added. The biggest problem is that there is a lag time of at least two hours from coagulant addition, coagulation and sedimentation to sand filtration. Therefore, for such a long lag process, when the raw water quality suddenly changes (such as heavy rain, strong winds and sewage discharge from upstream enterprises), it is difficult to make timely and accurate adjustments to the amount of coagulant added, which greatly affects the turbidity removal effect of the coagulation process and even causes the effluent turbidity to exceed the standard for a period of time, endangering the drinking water safety of residents. Summary of the invention

[0004] The purpose of the present invention is to overcome the shortcomings of the prior art and provide a cascade control method for coagulant addition based on a dual-stage attention mechanism. The DA-RNN prediction model of a recurrent neural network based on a dual-stage attention mechanism is adopted, and prediction correction is performed in combination with cascade control. This can provide more accurate regulation of the dosage of the coagulant, thereby ensuring the high efficiency of the water treatment process and the stability of the effluent quality, and greatly improving the intelligence and automation of the treatment process.

[0005] To achieve the above object, the present invention is implemented by adopting the following technical solutions:

[0006] The present invention discloses a cascade control method for coagulant addition based on a dual-stage attention mechanism, comprising the following steps:

[0007] Obtaining the pre-treated operation data of the water plant; the operation data includes the raw water quality index data record value, the effluent turbidity data record value, the sediment turbidity data record value and the coagulant dosage record value;

[0008] According to the pre-processed operation data, based on the pre-trained DA-RNN prediction model, the current moment's predicted value of coagulant dosage, predicted value of effluent turbidity and predicted value of sediment turbidity are obtained.

[0009] Based on the difference correction method of lag time, the predicted value of effluent turbidity and the predicted value of turbidity in the sink are corrected respectively to obtain the corrected value of effluent turbidity and the corrected value of turbidity in the sink;

[0010] According to the effluent turbidity correction value and the sediment turbidity correction value, based on the series coordination of the outer loop controller and the inner loop controller, the coagulant dosage feedback value is calculated;

[0011] According to the coagulant dosage feedback value and the coagulant dosage prediction value, the actual value of the coagulant dosage is calculated to achieve the coagulant dosage cascade control.

[0012] Furthermore, the raw water quality index data recorded values ​​include raw water turbidity, total phosphorus value, conductivity, ammonia nitrogen value, temperature, pH value, dissolved oxygen value, oxygen consumption, and water inlet flow rate.

[0013] Furthermore, the preprocessing comprises the following steps:

[0014] Acquire unprocessed operation data with time series characteristics; wherein the operation data includes raw water quality index data record values, effluent turbidity data record values, sediment turbidity data record values ​​and coagulant dosage record values;

[0015] Based on the time series characteristics, the recorded values ​​of the effluent turbidity data and the recorded values ​​of the coagulant dosage are misaligned, including The recorded value of coagulant dosage at time The recorded value of the outlet turbidity data at the time, Indicates the lag time of the effluent turbidity;

[0016] Based on the time series characteristics, the recorded values ​​of the sediment turbidity data and the recorded values ​​of the coagulant dosage are misaligned, including The recorded value of coagulant dosage at time The recorded value of the turbidity data at the time, where , Indicates the lag time of turbidity in sedimentation;

[0017] For the operating data, The criterion determines the normal range of data to mark abnormal data points; the abnormal data points are corrected based on the smoothing window method to obtain the corrected operating data;

[0018] The corrected operating data is subjected to median filtering and normalization processing to achieve data preprocessing; wherein the normalization processing expression is as follows:

[0019]

[0020] In the formula, Represents the input features of the normalized running data ; Represents the input features of the running data before normalization ; Represents the input features of the running data The minimum value of Represents the input features of the running data The maximum value in .

[0021] Further, the DA-RNN prediction model includes an input attention layer, a first softmax layer, a feature update module, an encoder, a temporal attention layer, a second softmax layer, an attention weight module, a context vector module and a decoder;

[0022] Based on the input attention layer, the raw water quality index data record value is used as the input feature , combined with the hidden state of the encoder at time t-1 , calculate the hidden state of the original encoder at time t , the expression is as follows:

[0023]

[0024]

[0025] In the formula, represents an LSTM neural network; Represents the input features, that is, the set of n features at time t; represents the mth feature at time t, and , n represents the number of features;

[0026] And according to the hidden state of the encoder at time t-1 and cell status , calculate the first attention score of any feature , the expression is as follows:

[0027] G t m = Ο G T tan h ( K G [ h t - 1 ; s t - 1 ]+ S G x m )

[0028] In the formula, represents the first attention score of the mth feature at time t; represents the first model learning parameters; represents the learning parameters of the second model; represents the hidden state of the encoder at time t-1; Represents the unit state of the encoder at time t-1; represents the learning parameters of the third model; represents the set of m-th features in a window of length T, ;

[0029] Based on the first softmax layer, according to the first attention score , calculate feature weights , , represents the first attention score of feature i at time t, and n represents the number of features; the feature weights are calculated based on the Softmax function and ensure that the sum of all input feature weights at time t is 1;

[0030] Based on the feature update module, the updated new features are obtained according to the feature weights and the input features. , ;

[0031] Based on the encoder, according to the new feature , the hidden state of the original encoder at time t Update to get the updated hidden state of the encoder at time t , ;

[0032] Based on the temporal attention layer, the hidden state of the i-th encoder is calculated to correspond to the second attention score of the decoder at time t , the expression is as follows:

[0033] Q t i = Ο Q T tan h ( K Q [ d t - 1 ; s t - 1 ' ]+ S Q h i )

[0034] In the formula, represents the fourth model learning parameter; represents the fifth model learning parameter; represents the hidden state of the decoder at time t-1; represents the unit state of the decoder at time t-1; represents the sixth model learning parameter; represents the hidden state of the i-th encoder;

[0035] Based on the second softmax layer, according to the second attention score , calculate the hidden state weight of the i-th encoder , , Indicates that the hidden state of the i-th encoder corresponds to the second attention score of the decoder at time t; calculates the feature weights based on the Softmax function and ensures that the sum of the hidden state weights of all encoders at time t is 1;

[0036] Based on the context vector module, according to the hidden state weight of the i-th encoder and the hidden state of the i-th encoder , calculate the context vector at time t , ;

[0037] Based on the decoder, according to the hidden state of the decoder within a time window T and context vector , output the predicted value , which is expressed as follows:

[0038] y ̂ T = u y ⊤ ( V y [ p T ; c T ]+ O w )+ b v

[0039] In the formula, It indicates the predicted value within the time window T, including the predicted value of coagulant dosage, the predicted value of sediment turbidity and the predicted value of effluent turbidity; Represents the weight of the predicted linear function; represents the weight matrix used to implement the linear transformation from the concatenation of the decoder's hidden state and the context vector to the decoder's hidden state; represents the hidden state of the decoder within a time window T; Represents a context vector within a time window T; represents a bias vector used to implement a linear transformation from the concatenation of the decoder's hidden state and the context vector to the decoder's hidden state; Represents the deviation of the predicted linear function.

[0040] Furthermore, the calculation method of the outlet water turbidity correction value is as follows:

[0041] According to the pre-processed operation data, the recorded value of the effluent turbidity in the preset time period is obtained;

[0042] Based on the lag time of the effluent turbidity, the recorded value of the coagulant dosage and the recorded value of the raw water quality index data of the previous time period of the preset time period corresponding to the recorded value of the effluent turbidity are obtained, and data prediction is performed based on the pre-trained DA-RNN prediction model to obtain the predicted value of the effluent turbidity in the previous time period;

[0043] The outlet water turbidity correction value is calculated based on the outlet water turbidity prediction value at the current moment, the outlet water turbidity record value in a preset time period and the outlet water turbidity prediction value in a previous time period.

[0044] Furthermore, the expression of the outlet turbidity correction value is as follows:

[0045]

[0046] In the formula, Indicates the outlet turbidity correction value at time t; represents the predicted value of the outlet turbidity at time t; k represents the correction window size; represents the first correction weight coefficient; express The recorded value of the outlet turbidity at the time; express Predicted value of outlet turbidity at the time; Indicates the lag time of water turbidity.

[0047] Furthermore, the calculation method of the turbidity correction value in the sediment is as follows:

[0048] According to the pre-processed operation data, the recorded values ​​of turbidity in the sediment in the preset time period are obtained;

[0049] Based on the lag time of the turbidity in the sediment, the recorded value of the coagulant dosage and the recorded value of the raw water quality index data of the previous time period of the preset time period corresponding to the recorded value of the turbidity in the sediment are obtained, and data prediction is performed based on the pre-trained DA-RNN prediction model to obtain the predicted value of the turbidity in the sediment in the previous time period;

[0050] The correction value of the turbidity in the sink is calculated based on the predicted value of the turbidity in the sink at the current moment, the recorded value of the turbidity in the sink in a preset time period and the predicted value of the turbidity in the sink in the previous time period.

[0051] Further, the expression of the turbidity correction value in the sediment is as follows:

[0052]

[0053] In the formula, Indicates the turbidity correction value of the sediment at time t; represents the predicted value of turbidity in the sediment at time t; k represents the size of the correction window; represents the second correction weight coefficient; express The recorded value of turbidity in the sediment at the moment; express Predicted value of turbidity in the sediment at the moment; Indicates the lag time of turbidity in sediment.

[0054] Furthermore, the expression of the coagulant dosage feedback value is as follows:

[0055]

[0056] In the formula, It represents the feedback value of coagulant dosage at time t; Indicates the feedback value of coagulant dosage at the previous moment t-1; represents the proportional coefficient of the inner loop P controller; Indicates the turbidity correction value of the sediment at time t; represents the proportional coefficient of the outer loop P controller; Indicates the set value of outlet water turbidity; Indicates the outlet turbidity correction value at time t.

[0057] Furthermore, the expression of the actual value of the coagulant dosage is as follows:

[0058]

[0059] In the formula, Indicates the actual value of coagulant dosage at time t; The weight coefficient representing the dosage of two parts of coagulant; It represents the predicted value of coagulant dosage at time t; It represents the feedback value of coagulant dosage at time t.

[0060] Compared with the prior art, the present invention has the following beneficial effects:

[0061] The coagulant addition cascade control method based on the dual-stage attention mechanism of the present invention adopts the DA-RNN prediction model of the recurrent neural network based on the dual-stage attention mechanism, combined with cascade control for prediction correction, so as to accurately control the dosage of the coagulant. Compared with the traditional method relying on manual judgment and simple rules, the cascade control method of the present invention can more effectively suppress the turbidity fluctuation caused by reaction lag, and can more accurately and timely adjust the dosage of the coagulant, thereby ensuring that the turbidity of the effluent is always within the safe and standard range. In addition, this cascade control structure also helps to reduce over-regulation caused by interference, thereby ensuring the high efficiency of the water treatment process and the stability of the effluent quality, and greatly improving the intelligence and automation of the treatment process.

[0062] The present invention collects and analyzes key water quality indicators and treatment process parameters in real time, and uses deep learning technology to intelligently optimize and manage the treatment process. The efficiency and stability of the water treatment process are significantly improved, while reducing dependence on manual operations, and promoting the evolution of the water treatment field towards intelligence and automation. Through the implementation of the method of the present invention, the optimal operation of water treatment facilities under various environmental conditions can be guaranteed, ensuring the continuity, quality and safety of water supply. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] Figure 1 It is a flow chart of a cascade control method for coagulant addition based on a dual-stage attention mechanism provided in an embodiment;

[0064] Figure 2 is a schematic diagram of data median filtering provided by an embodiment;

[0065] Figure 3 It is a schematic diagram of a recurrent neural network based on a dual-stage attention mechanism provided in an embodiment;

[0066] Figure 4 is a cascade control principle diagram provided by an embodiment;

[0067] Figure 5 It is a convergence diagram of the training curve of the coagulant dosage prediction model provided in the embodiment;

[0068] Figure 6 is a convergence diagram of the training curve of the effluent turbidity prediction model provided in the embodiment;

[0069] Figure 7 It is a convergence graph of the training curve of the prediction model in the embodiment provided;

[0070] Figure 8 It is a test set coagulant dosage prediction effect diagram provided in the embodiment;

[0071] Fig. 9It is a test set sedimentation tank effluent turbidity prediction effect diagram provided in the embodiment;

[0072] Fig.10 It is a test set sedimentation tank turbidity prediction effect diagram provided in the embodiment;

[0073] Fig.11 It is a diagram of actual operation effect provided by the embodiment. DETAILED DESCRIPTION

[0074] The present invention will be further described below in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the protection scope of the present invention.

[0075] This embodiment provides a coagulant addition cascade control method based on a dual-stage attention mechanism, comprising the following steps:

[0076] Obtain the operation data of the water plant after pretreatment; the operation data includes the record values ​​of raw water quality index data, the record values ​​of effluent turbidity data, the record values ​​of sediment turbidity data and the record values ​​of coagulant dosage;

[0077] According to the pre-processed operation data, based on the pre-trained DA-RNN prediction model, the current moment's predicted value of coagulant dosage, effluent turbidity, and sediment turbidity are obtained.

[0078] Based on the difference correction method of lag time, the predicted value of effluent turbidity and the predicted value of turbidity in the sediment are corrected respectively to obtain the corrected value of effluent turbidity and the corrected value of turbidity in the sediment.

[0079] According to the effluent turbidity correction value and the sediment turbidity correction value, based on the series coordination of the outer loop controller and the inner loop controller, the feedback value of the coagulant dosage is calculated;

[0080] According to the feedback value of coagulant dosage and the predicted value of coagulant dosage, the actual value of coagulant dosage is calculated to realize cascade control of coagulant dosage.

[0081] The technical concept of the present invention is: using the DA-RNN prediction model of the recurrent neural network based on the dual-stage attention mechanism, combined with cascade control for prediction correction, to accurately control the dosage of the coagulant. Compared with the traditional method that relies on manual judgment and simple rules, the present invention can provide more precise regulation, thereby ensuring the high efficiency of the water treatment process and the stability of the effluent quality, greatly improving the intelligence and automation of the treatment process.

[0082] like Figure 1 As shown, the specific steps include:

[0083] Step 1: Data preprocessing.

[0084] The preprocessing includes the following steps:

[0085] First, the unprocessed operation data with time series characteristics are obtained; the operation data include the raw water quality index data record values, the effluent turbidity data record values, the sediment turbidity data record values ​​and the coagulant dosage record values; the raw water quality index data record values ​​include raw water turbidity, total phosphorus value, conductivity, ammonia nitrogen value, temperature, pH value, dissolved oxygen value, oxygen consumption, and inlet flow rate.

[0086] In this embodiment, the PLC uses a one-minute period as a time series feature to collect the operating data into the database.

[0087] Secondly, since the coagulant needs a certain reaction time in the sedimentation process, there is a lag time between the coagulant dosage, the turbidity in the sedimentation and the turbidity of the effluent, and it is necessary to perform dislocation processing to move the raw water quality indicators and the coagulant dosage backward to the corresponding sedimentation water turbidity position, so that the raw water quality indicators, coagulant dosage, turbidity in the sedimentation and turbidity of the effluent maintain a one-to-one correspondence based on the time series characteristics, as follows:

[0088] Based on the time series characteristics, the recorded values ​​of effluent turbidity data and coagulant dosage are misplaced, including The recorded value of coagulant dosage at time The recorded value of the outlet turbidity data at the time, Indicates the lag time of water turbidity.

[0089] Based on the time series characteristics, the recorded values ​​of sediment turbidity data and coagulant dosage are misplaced, including The recorded value of coagulant dosage at time The recorded value of the turbidity data at the time, where , Indicates the lag time of turbidity in sediment.

[0090] Furthermore, due to the complex operating environment of the water plant, the failure and aging of measuring instruments, the operator's operating errors, etc. will cause the appearance of abnormal values. In order to avoid the adverse effects of these abnormal values ​​in the future, we use This method does not rely on complex model structures, but instead uses statistical analysis to identify data points that are far away from the center of the data set.

[0091] Specifically, for any of the above collected running data, we first calculate the mean of each feature and standard deviation Then, use The principle is to determine the normal range of data, that is, The data within the interval are considered normal values, while the data points outside this interval are marked as outliers. For the data points marked as abnormal, the smoothing window method is used to replace the abnormal value, that is, a window of size t is set before the abnormal value, and the average value of the data within the window is used to replace the abnormal value. The abnormal data points are corrected based on the smoothing window method, and then the corrected running data is obtained.

[0092] Finally, if Figure 2 As shown in Figure 1, in order to reduce noise and improve the accuracy of subsequent models, median filtering is performed on the data. For each data point, all data in a window around the point are selected, the median of these data is calculated, and then the median is used to replace the value of the original data point.

[0093] Data normalization is to avoid the impact of the huge difference in dimensions between the raw water quality indicators and process variable data of different water plants on the model, and to convert the collected data into a relatively uniform numerical range to ensure the rapid iteration of the neural network and prevent gradient explosion. In this embodiment, the extreme value normalization method is selected, and its expression is as follows:

[0094]

[0095] In the formula, Represents the input features of the normalized running data ; Represents the input features of the running data before normalization ; Represents the input features of the running data The minimum value of Represents the input features of the running data The maximum value in .

[0096] Step 2: DA-RNN prediction model.

[0097] The time series prediction model based on the dual-stage attention recursive neural network of the present invention has the following principles:

[0098]

[0099]

[0100] In the formula, T represents the time window, It indicates the predicted value within the time window T, including the predicted value of coagulant dosage, the predicted value of sediment turbidity and the predicted value of effluent turbidity; Indicates the recorded value of coagulant dosage, the recorded value of sediment turbidity and the recorded value of effluent turbidity within the previous T-1 time; represents the input features, that is, the set of n features at time t; n represents the number of features, that is, the number of input features of the raw water quality index data record values.

[0101] In order to enable the model to adaptively select the most relevant input features at each moment, an attention mechanism is added to the decoder stage. This stage uses the attention mechanism and combines the hidden layer information to assign a certain weight to each input feature. The attention mechanism is also introduced in the decoder stage, using LSTM to capture long-term dependencies by weighted summing of the encoder's hidden states.

[0102] like Figure 3 As shown, the DA-RNN prediction model includes an input attention layer, a first softmax layer, a feature update module, an encoder, a temporal attention layer, a second softmax layer, an attention weight module, a context vector module and a decoder;

[0103] Based on the input attention layer, the raw water quality index data record value is used as the input feature , combined with the hidden state of the encoder at time t-1 , calculate the hidden state of the original encoder at time t , the expression is as follows:

[0104]

[0105]

[0106] In the formula, represents an LSTM neural network; Represents the input features, that is, the set of n features at time t; represents the mth feature at time t, and , n represents the number of features;

[0107] And according to the hidden state of the encoder at time t-1 and cell status , calculate the first attention score of any feature , the expression is as follows:

[0108] G t m = Ο G T tan h ( K G [ h t - 1 ; s t - 1 ]+ S G x m )

[0109] In the formula, represents the first attention score of the mth feature at time t; represents the first model learning parameters; represents the learning parameters of the second model; represents the hidden state of the encoder at time t-1; Represents the unit state of the encoder at time t-1; represents the learning parameters of the third model; represents the set of m-th features in a window of length T, ;

[0110] Based on the first softmax layer, according to the first attention score , calculate feature weights , , represents the first attention score of feature i at time t, and n represents the number of features; the feature weights are calculated based on the Softmax function and ensure that the sum of all input feature weights at time t is 1;

[0111] Based on the feature update module, the updated new features are obtained according to the feature weights and the input features. , ;

[0112] Based on the encoder, according to the new features , the hidden state of the original encoder at time t Update to get the updated hidden state of the encoder at time t , ;

[0113] Based on the temporal attention layer, the hidden state of the i-th encoder is calculated to correspond to the second attention score of the decoder at time t , the expression is as follows:

[0114] Q t i = Ο Q T tan h ( K Q [ d t - 1 ; s t - 1 ' ]+ S Q h i )

[0115] In the formula, represents the fourth model learning parameter; represents the fifth model learning parameter; represents the hidden state of the decoder at time t-1; represents the unit state of the decoder at time t-1; represents the sixth model learning parameter; represents the hidden state of the i-th encoder;

[0116] Based on the second softmax layer, according to the second attention score , calculate the hidden state weight of the i-th encoder , , Indicates that the hidden state of the i-th encoder corresponds to the second attention score of the decoder at time t; calculates the feature weights based on the Softmax function and ensures that the sum of the hidden state weights of all encoders at time t is 1;

[0117] Based on the context vector module, according to the hidden state weight of the i-th encoder and the hidden state of the i-th encoder , calculate the context vector at time t , ;

[0118] Based on the decoder, according to the hidden state of the decoder within a time period T and context vector , output the predicted value , which is expressed as follows:

[0119] y ̂ T = u y ⊤ ( V y [ p T ; c T ]+ O w )+ b v

[0120] In the formula, It indicates the predicted value within the time window T, including the predicted value of coagulant dosage, the predicted value of sediment turbidity and the predicted value of effluent turbidity; Represents the weight of the predicted linear function; represents the weight matrix used to implement the linear transformation from the concatenation of the decoder's hidden state and the context vector to the decoder's hidden state; represents the hidden state of the decoder within a time window T; Represents a context vector within a time window T; represents a bias vector used to implement a linear transformation from the concatenation of the decoder's hidden state and the context vector to the decoder's hidden state; Represents the deviation of the predicted linear function.

[0121] A cascade control system is constructed based on the predicted value of coagulant dosage, the predicted value of effluent turbidity and the predicted value of sediment turbidity. This control system connects two controllers in series, and the output of the outer loop controller is used as the set value of the inner loop controller, and the output of the inner loop controller is used to control the controlled object, so that the output of the outer loop can be more effectively controlled. The final actual value of coagulant dosage is composed of the predicted value of coagulant dosage and the feedback value of coagulant dosage, as shown in the following steps 3 to 6.

[0122] Step 3: Correct the turbidity of the effluent water.

[0123] The calculation method of the outlet water turbidity correction value is as follows:

[0124] According to the pre-processed operation data, the recorded value of the effluent turbidity in the preset time period is obtained;

[0125] Based on the lag time of the effluent turbidity, the recorded value of the coagulant dosage and the recorded value of the raw water quality index data of the previous time period of the preset time period corresponding to the recorded value of the effluent turbidity are obtained, and data prediction is performed based on the pre-trained DA-RNN prediction model to obtain the predicted value of the effluent turbidity of the previous time period;

[0126] The effluent turbidity correction value is calculated based on the effluent turbidity prediction value at the current moment, the effluent turbidity record value in the preset time period and the effluent turbidity prediction value in the previous time period.

[0127] Specifically, according to the operation data pre-processed in step 1, obtain the recorded values ​​of turbidity of the sedimentation tank effluent at time t and k times before it. , and the recorded value of the outlet turbidity at time t corresponds to to The raw water quality index data recorded values ​​and the coagulant dosage recorded values ​​at the time;

[0128] Through the DA-RNN prediction model in step 2, we can get to The predicted value of the outlet turbidity at time is: Therefore, the difference between these two parts can be used to correct the real-time effluent turbidity record value at time t and the effluent turbidity prediction value corresponding to the coagulant dosage record value. The amount of correction.

[0129] The expression of the outlet turbidity correction value is as follows:

[0130]

[0131] In the formula, Indicates the outlet turbidity correction value at time t; represents the predicted value of the outlet turbidity at time t; k represents the correction window size; represents the first correction weight coefficient; express The recorded value of the outlet turbidity at the time; express Predicted value of outlet turbidity at the time; Indicates the lag time of water turbidity.

[0132] Step 4: Turbidity correction in sediment.

[0133] The calculation method of the turbidity correction value in the sediment is as follows:

[0134] According to the pre-processed operation data, the recorded values ​​of turbidity in the sediment in the preset time period are obtained;

[0135] Based on the lag time of the turbidity in the sediment, obtain the recorded value of the coagulant dosage and the recorded value of the raw water quality index data of the previous time period of the preset time period corresponding to the recorded value of the turbidity in the sediment, and perform data prediction based on the pre-trained DA-RNN prediction model to obtain the predicted value of the turbidity in the sediment in the previous time period;

[0136] The correction value of the turbidity in the sink is calculated based on the predicted value of the turbidity in the sink at the current moment, the recorded value of the turbidity in the sink in a preset time period and the predicted value of the turbidity in the sink in the previous time period.

[0137] Specifically, according to the operation data pre-processed in step 1, obtain the turbidity record value of the sedimentation tank at time t and k times before it Since the measurement position of the turbidity in the sedimentation tank is in the middle part of the entire sedimentation tank, it can be deduced that the lag time corresponding to the turbidity in the sedimentation tank is , and the recorded turbidity value at time t corresponds to to The raw water quality index data recorded at the time and the coagulant dosage recorded value, and the turbidity prediction value in the sediment can be obtained by the same method Correction amount:

[0138] The expression of the turbidity correction value in the sediment is as follows:

[0139]

[0140] In the formula, Indicates the turbidity correction value of the sediment at time t; represents the predicted value of turbidity in the sediment at time t; k represents the size of the correction window; represents the second correction weight coefficient; express The recorded value of turbidity in the sediment at the moment; express Predicted value of turbidity in the sediment at the moment; Indicates the lag time of turbidity in sediment.

[0141] Step 5: Calculate the actual amount of coagulant added.

[0142] like Figure 4 As shown, the actual value of coagulant dosage is calculated according to the feedback value of coagulant dosage and the predicted value of coagulant dosage to realize cascade control of coagulant dosage.

[0143] The expression of the coagulant dosage feedback value is as follows:

[0144]

[0145] In the formula, It represents the feedback value of coagulant dosage at time t; Indicates the feedback value of coagulant dosage at the previous moment t-1; represents the proportional coefficient of the inner loop P controller; Indicates the turbidity correction value of the sediment at time t; represents the proportional coefficient of the outer loop P controller; Indicates the set value of outlet water turbidity; Indicates the outlet turbidity correction value at time t.

[0146] The expression of the actual value of coagulant dosage is as follows:

[0147]

[0148] In the formula, Indicates the actual value of coagulant dosage at time t; The weight coefficient representing the dosage of two parts of coagulant; It represents the predicted value of coagulant dosage at time t; It represents the feedback value of coagulant dosage at time t.

[0149] The specific training process of the DA-RNN prediction model in step 2 includes the following steps:

[0150] (1) Data collection and preprocessing: Real-time collection of data such as raw water quality indicators, coagulant dosage, sediment turbidity and effluent turbidity of the water plant, data dislocation processing, abnormal data processing, and data filtering and normalization.

[0151] (2) Data set division: The processed data is divided into a training set and a test set according to the ratio, with the training set accounting for 70% and the test set accounting for 30%.

[0152] (3) Model construction: Based on the recurrent neural network with a two-segment attention mechanism, a coagulant dosage prediction model, an effluent turbidity prediction model, and a sediment turbidity prediction model were constructed.

[0153] (4) Model compilation: The training iterations of the coagulant dosage prediction model were set to 140, the training iterations of the effluent turbidity prediction model and the sediment turbidity prediction model were set to 80, the batch size was set to 128, the window size was set to 10, the number of hidden layer neurons of the decoder and encoder were both set to 64, the optimizer was the Adam optimizer, the learning rate was set to 0.01, and the loss function was the mean square error (MSE).

[0154] (5) Model training and evaluation: Based on the above hyperparameter training model, the mean square error (MSE) indicator is used to evaluate the accuracy of the model on the test dataset.

[0155] like Figure 5-Figure 7 As shown in the figure, from the training curve, it can be seen that with the increase in the number of iterations, the loss of the training set is gradually decreasing. After 80 iterations, the rate of loss decrease of the coagulant dosage prediction model is significantly reduced. After 140 iterations, the loss of the training set tends to converge. After 50 iterations, the rate of loss decrease of the effluent turbidity prediction model and the sediment turbidity prediction model is significantly reduced. After 80 iterations, the loss of the training set tends to converge.

[0156] like Figure 8-Figure 10 As shown in the figure, the overall trend of the predicted value of coagulant dosage is consistent with the actual value, and due to the periodic change of the inlet flow rate, the predicted value and actual value of the coagulant dosage in the figure also have corresponding periodic changes. The trends of the predicted value and actual value of the turbidity in the sediment and the turbidity in the effluent are roughly the same. The model can better capture the change pattern of the turbidity in the sediment and the turbidity in the effluent over time. At some peaks and troughs, there is a slight deviation between the predicted value and the actual value.

[0157] like Fig.11As shown, the turbidity of the effluent from Phase 2 and Phase 3 in the figure is the actual data collected from January 22, 2024 to January 23, 2024, with a collection period of 1 minute and a total data volume of 2880. The sedimentation tanks of Phase 2 and Phase 3 share a water source, so the water quality of the influent of the two sedimentation tanks is exactly the same, only the influent water volume is different, and the coagulant addition of Phase 2 is controlled by the control method of the present invention, while Phase 3 adopts a method of artificial addition according to the proportion of the influent flow of the sedimentation tank. The current effluent turbidity setting value of the water plant is 0.6NTU, and the allowable error is between ±0.15NTU. As can be seen from the figure, the effluent turbidity of the sedimentation tank of Phase 2 fluctuates around 0.6NTU, and the error of the fluctuation is between ±0.15NTU, which can meet the actual operation needs of the water plant. The turbidity of the effluent from the manually controlled Phase 3 sedimentation tank fluctuated violently. Since the amount of coagulant added could not be flexibly adjusted according to changes in water quality, the turbidity of the effluent exceeded the allowable error range at certain times. The highest turbidity of the effluent reached 0.9 NTU, affecting the normal production of the water plant.

[0158] In summary, the DA-RNN prediction model of the present invention combines the encoder-decoder architecture and the attention mechanism to effectively process and analyze time series data. In the encoding stage, the input features most relevant to the current prediction target are selected through the dynamic attention mechanism, and in the decoding stage, the local attention mechanism is applied to capture the key time points in the time series, thereby ensuring efficient data processing and enhanced model interpretability. Compared with traditional recurrent neural networks, the DA-RNN prediction model shows its unique advantages, especially in processing water quality data with complex time dependencies. By finely adjusting the attention weights, the DA-RNN prediction model can adaptively focus on the most important features and time steps, thereby achieving more accurate prediction of coagulant dosage. In addition, the structural design of the DA-RNN prediction model enables it to quickly adapt to new data through an effective parameter update mechanism without retraining the entire model, ensuring the long-term application and stability of the model in a dynamic environment. The actual application effect verifies the efficiency and accuracy of the DA-RNN prediction model in predicting the amount of coagulant in water plants. The model can not only accurately predict the optimal dosage of coagulant based on historical and real-time water quality data, but also dynamically adjust as water quality changes, improving the adaptability and efficiency of the treatment process. By reducing the turbidity of the effluent, the present invention has shown significant advantages in ensuring the safety and stability of water supply, and provides an efficient and reliable technical solution for the operation and management of water plants.

[0159] The coagulant addition cascade control method based on the dual-stage attention mechanism of the present invention adopts the DA-RNN prediction model of the recurrent neural network based on the dual-stage attention mechanism, combined with cascade control for prediction correction, so as to accurately control the dosage of the coagulant. Compared with the traditional method relying on manual judgment and simple rules, the present invention can provide more precise regulation, thereby ensuring the high efficiency of the water treatment process and the stability of the effluent quality, and greatly improving the intelligence and automation of the treatment process.

[0160] The present invention collects and analyzes key water quality indicators and treatment process parameters in real time, and uses deep learning technology to intelligently optimize and manage the treatment process. The efficiency and stability of the water treatment process are significantly improved, while reducing dependence on manual operations, and promoting the evolution of the water treatment field towards intelligence and automation. Through the implementation of the method of the present invention, the optimal operation of water treatment facilities under various environmental conditions can be guaranteed, ensuring the continuity, quality and safety of water supply.

[0161] The present invention takes the second phase sedimentation tank of the water plant as the application background. The reaction time of the sedimentation tank is 2.5h-4.5h, and there is a large hysteresis. In order to reduce the influence of hysteresis on the turbidity of the effluent, turbidity meters are installed in the middle and tail of the sedimentation tank. The cascade control system for coagulant addition is constructed by these two turbidity meters. Compared with other water plants that only monitor and control at the effluent end of the sedimentation tank, the cascade control method of the present invention can more effectively suppress the turbidity fluctuation caused by the reaction lag, and can more accurately and timely adjust the dosage of the coagulant, thereby ensuring that the turbidity of the effluent is always within the safety and standard range. In addition, this cascade control structure also helps to reduce over-regulation caused by interference and improve the stability and efficiency of the entire water treatment process.

[0162] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt 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 codes.

[0163] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0164] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0165] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0166] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A cascade control method for coagulant addition based on a dual-stage attention mechanism, characterized in that: The steps include: Obtaining the pre-treated operation data of the water plant; the operation data includes the raw water quality index data record value, the effluent turbidity data record value, the sediment turbidity data record value and the coagulant dosage record value; According to the pre-processed operation data, based on the pre-trained DA-RNN prediction model, the current moment's predicted value of coagulant dosage, predicted value of effluent turbidity and predicted value of sediment turbidity are obtained. Based on the difference correction method of lag time, the predicted value of effluent turbidity and the predicted value of turbidity in the sink are corrected respectively to obtain the corrected value of effluent turbidity and the corrected value of turbidity in the sink; According to the effluent turbidity correction value and the sediment turbidity correction value, based on the series coordination of the outer loop controller and the inner loop controller, the coagulant dosage feedback value is calculated; Calculating the actual value of coagulant dosage according to the coagulant dosage feedback value and the coagulant dosage prediction value to achieve cascade control of coagulant dosage; The DA-RNN prediction model includes an input attention layer, a first softmax layer, a feature update module, an encoder, a temporal attention layer, a second softmax layer, an attention weight module, a context vector module and a decoder; Based on the input attention layer, the raw water quality index data record value is used as the input feature , combined with the hidden state of the encoder at time t-1 , calculate the hidden state of the original encoder at time t , the expression is as follows: ; ; In the formula, represents an LSTM neural network; Represents the input features, that is, the set of n features at time t; represents the mth feature at time t, and 1≤m≤n, where n represents the number of features; And according to the hidden state of the encoder at time t-1 and cell status , calculate the first attention score of any feature , the expression is as follows: ; In the formula, represents the first attention score of the mth feature at time t; represents the first model learning parameters; represents the learning parameters of the second model; represents the hidden state of the encoder at time t-1; Represents the unit state of the encoder at time t-1; represents the learning parameters of the third model; represents the set of m-th features in a window of length T, ; Based on the first softmax layer, according to the first attention score , calculate feature weights , , represents the first attention score of feature i at time t, and n represents the number of features; the feature weights are calculated based on the Softmax function and ensure that the sum of all input feature weights at time t is 1; Based on the feature update module, the updated new features are obtained according to the feature weights and the input features. , ; Based on the encoder, according to the new feature , the hidden state of the original encoder at time t Update to get the updated hidden state of the encoder at time t , ; Based on the temporal attention layer, the hidden state of the i-th encoder is calculated to correspond to the second attention score of the decoder at time t , the expression is as follows: ; In the formula, represents the fourth model learning parameter; represents the fifth model learning parameter; represents the hidden state of the decoder at time t-1; represents the unit state of the decoder at time t-1; represents the sixth model learning parameter; represents the hidden state of the i-th encoder; Based on the second softmax layer, according to the second attention score , calculate the hidden state weight of the i-th encoder , , Indicates that the hidden state of the i-th encoder corresponds to the second attention score of the decoder at time t; calculates the feature weights based on the Softmax function and ensures that the sum of the hidden state weights of all encoders at time t is 1; Based on the context vector module, according to the hidden state weight of the i-th encoder and the hidden state of the i-th encoder , calculate the context vector at time t , ; Based on the decoder, according to the hidden state of the decoder within a time window T and context vector , output the predicted value , which is expressed as follows: ; In the formula, It indicates the predicted value within the time window T, including the predicted value of coagulant dosage, the predicted value of sediment turbidity and the predicted value of effluent turbidity; Represents the weight of the predicted linear function; represents the weight matrix used to implement the linear transformation from the concatenation of the decoder's hidden state and the context vector to the decoder's hidden state; represents the hidden state of the decoder within a time window T; Represents the context vector within a time window T; represents a bias vector used to implement a linear transformation from the concatenation of the decoder's hidden state and the context vector to the decoder's hidden state; represents the deviation of the predicted linear function; The expression of the outlet turbidity correction value is as follows: ; In the formula, Indicates the outlet turbidity correction value at time t; represents the predicted value of the outlet turbidity at time t; k represents the correction window size; represents the first correction weight coefficient; express The recorded value of the outlet turbidity at the time; express Predicted value of outlet turbidity at the time; Indicates the lag time of the effluent turbidity; The expression of the turbidity correction value in the sediment is as follows: ; In the formula, Indicates the turbidity correction value of the sediment at time t; represents the predicted value of turbidity in the sediment at time t; k represents the size of the correction window; represents the second correction weight coefficient; express The recorded value of turbidity in the sediment at the moment; express Predicted value of turbidity in the sediment at the moment; Indicates the lag time of turbidity in sedimentation; The expression of the coagulant dosage feedback value is as follows: ; In the formula, It represents the feedback value of coagulant dosage at time t; Indicates the feedback value of coagulant dosage at the previous moment t-1; represents the proportional coefficient of the inner loop P controller; Indicates the turbidity correction value of the sediment at time t; represents the proportional coefficient of the outer loop P controller; Indicates the set value of outlet water turbidity; Indicates the outlet turbidity correction value at time t; The expression of the actual value of the coagulant dosage is as follows: ; In the formula, Indicates the actual value of coagulant dosage at time t; The weight coefficient representing the dosage of two parts of coagulant; It represents the predicted value of coagulant dosage at time t; It represents the feedback value of coagulant dosage at time t.

2. The method for cascade control of coagulant addition based on a dual-stage attention mechanism according to claim 1 is characterized in that: The raw water quality index data recorded values ​​include raw water turbidity, total phosphorus value, conductivity, ammonia nitrogen value, temperature, pH value, dissolved oxygen value, oxygen consumption, and water inlet flow rate.

3. The method for cascade control of coagulant addition based on a dual-stage attention mechanism according to claim 1 is characterized in that: The pre-processing comprises the following steps: Acquire unprocessed operation data with time series characteristics; wherein the operation data includes raw water quality index data record values, effluent turbidity data record values, sediment turbidity data record values ​​and coagulant dosage record values; Based on the time series characteristics, the recorded values ​​of the effluent turbidity data and the recorded values ​​of the coagulant dosage are misplaced, including the recorded value of the coagulant dosage at time t, corresponding to The recorded value of the outlet turbidity data at the time, η represents the lag time of the outlet turbidity; Based on the time series characteristics, the recorded values ​​of the sediment turbidity data and the recorded values ​​of the coagulant dosage are misplaced, including the recorded value of the coagulant dosage at time t, corresponding to The recorded value of the turbidity data in the sediment at the time, where λ=η / 2, λ represents the lag time of the turbidity in the sediment; For the operating data, the normal range of the data is determined by the 3S criterion to mark abnormal data points; the abnormal data points are corrected based on the smoothing window method to obtain corrected operating data; The corrected operating data is subjected to median filtering and normalization processing to achieve data preprocessing; wherein the normalization processing expression is as follows: ; In the formula, represents the input feature i of the normalized running data; represents the input feature i of the running data before normalization; represents the minimum value of input feature i of the running data; Represents the maximum value among the input feature i of the running data.

4. The method for cascade control of coagulant addition based on a dual-stage attention mechanism according to claim 1 is characterized in that: The calculation method of the outlet water turbidity correction value is as follows: According to the pre-processed operation data, the recorded value of the effluent turbidity in the preset time period is obtained; Based on the lag time of the effluent turbidity, the recorded value of the coagulant dosage and the recorded value of the raw water quality index data of the previous time period of the preset time period corresponding to the recorded value of the effluent turbidity are obtained, and data prediction is performed based on the pre-trained DA-RNN prediction model to obtain the predicted value of the effluent turbidity in the previous time period; The outlet water turbidity correction value is calculated based on the outlet water turbidity prediction value at the current moment, the outlet water turbidity record value in a preset time period and the outlet water turbidity prediction value in a previous time period.

5. The method for cascade control of coagulant addition based on a dual-stage attention mechanism according to claim 1 is characterized in that: The calculation method of the turbidity correction value in the sediment is as follows: According to the pre-processed operation data, the recorded values ​​of turbidity in the sediment in the preset time period are obtained; Based on the lag time of the turbidity in the sediment, the recorded value of the coagulant dosage and the recorded value of the raw water quality index data of the previous time period of the preset time period corresponding to the recorded value of the turbidity in the sediment are obtained, and data prediction is performed based on the pre-trained DA-RNN prediction model to obtain the predicted value of the turbidity in the sediment in the previous time period; The correction value of the turbidity in the sink is calculated based on the predicted value of the turbidity in the sink at the current moment, the recorded value of the turbidity in the sink in a preset time period and the predicted value of the turbidity in the sink in the previous time period.