Coagulant addition control method and system in sewage treatment
By obtaining floc images and water quality parameters in real time, combining the alum flower segmentation identification model and coagulant prediction model, dynamically adjusting the amount of coagulant in sewage treatment, solving the problem that the amount of coagulant in the existing technology is difficult to accurately adjust, and achieving efficient and economical sewage treatment effect.
Patent Information
- Application Number
- CN202411897135.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-11
AI Technical Summary
In the existing sewage treatment technology, it is difficult to accurately adjust the amount of coagulant injection, resulting in fluctuations in water quality and increased operating costs.
The floc image and water quality parameters are obtained in real time, combined with the alum flower segmentation identification model and the coagulant prediction model, and the coagulant addition amount is dynamically adjusted.
Accurate control of the amount of coagulant added in sewage treatment, improves water treatment efficiency, reduces operating costs, and improves the automation level of the system.
Smart Images

Figure CN119806071A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of sewage treatment, and in particular to a coagulant addition control method and system in sewage treatment. Background Art
[0002] Most water treatment and sewage treatment are equipped with coagulation treatment units, and the coagulation effect directly affects the final water quality. The cost of coagulants accounts for 28% to 34% of the consumption production cost of water plants. Therefore, it is of great significance to reduce the consumption and production cost of coagulants and improve the economic benefits of water plants. To this end, it is necessary to establish a reliable coagulant dosage prediction model and determine the optimal dosage through scientific methods, thereby reducing the consumption and production cost of coagulants.
[0003] The traditional method of monitoring alum flocs is manual inspection. Operators need to regularly check the alum flocs generated during the coagulation reaction and adjust the dosage based on the raw water flow, turbidity, and effluent turbidity of the sedimentation tank. Although this method is feasible to a certain extent, when the water quality fluctuates frequently, its reaction lag may cause the effluent to exceed the standard. More importantly, this method is extremely dependent on the experience and judgment of the operator. It is not only labor-intensive, but also affected by the conservative tendency of the operator in decision-making, resulting in excessive dosage, which increases operating costs.
[0004] With the development of artificial intelligence technology, data-driven machine learning models are widely used in the prediction of coagulation dosage. The existing technology is based on the convolutional neural network model, which takes floc images as input and the dosage of coagulant as output. Although the prediction effect is good, the model itself lacks interpretability and cannot be well combined with the operating mechanism of the coagulation process itself, and cannot dynamically and accurately predict the dosage of coagulant according to the actual situation. Summary of the invention
[0005] In view of this, the present invention provides a method and system for controlling coagulant addition in sewage treatment, which solves the technical problem of how to accurately adjust the coagulant addition according to the change of water quality at any time.
[0006] In a first aspect, the present invention provides a method for controlling coagulant addition in sewage treatment, the method comprising:
[0007] Acquire the floc image in the flocculation tank in real time, and input it into the pre-trained alum flower segmentation and recognition model to obtain the alum flower recognition result, wherein the alum flower segmentation and recognition model is a U-Net model optimized based on the generative adversarial network;
[0008] Extracting floc characteristic parameters based on the alum floc identification result;
[0009] Obtain water quality parameters entering the sewage treatment plant in real time;
[0010] Inputting the floc characteristic parameters and the water quality parameters into a coagulant prediction model trained based on ensemble learning to obtain predicted coagulant dosage data;
[0011] The operation of the coagulant dosing pump is controlled based on the predicted coagulant dosage data.
[0012] The method for controlling coagulant addition in sewage treatment provided by the embodiment of the present invention can accurately give appropriate coagulant addition data by acquiring water quality parameter data in real time in combination with floc characteristics, and using advanced models (alum floc segmentation and recognition model, coagulant prediction model). It is combined with the operating mechanism of the coagulation process itself and has strong adaptability. At the same time, the alum floc segmentation and recognition model and the coagulant prediction model are trained based on a large amount of data. It is a data-driven control method, which is more scientific and objective than the traditional dosing method relying on experience. Moreover, as new data is continuously accumulated in the future, the model can be further optimized and the accuracy of dosing control can be continuously improved to ensure that sewage treatment can achieve better results under various water quality conditions, improve treatment efficiency by improving the automation level of water treatment, and reduce operating costs.
[0013] In an optional embodiment, the training process of the alum flower segmentation and recognition model includes:
[0014] Collect floc images in the flocculation tank according to a preset time period, and perform image enhancement preprocessing on the collected images to obtain floc images;
[0015] Marking the flocs at different time periods in the pre-processed floc image, and extracting the coordinate information of the marking box as the marking data;
[0016] Input the labeled data into the U-Net model, train the model based on the cross entropy loss function, and use the trained model as the initial alum flower recognition model;
[0017] The generative adversarial network is used to optimize the recognition results of the initial alum flower recognition model to obtain the final alum flower recognition model.
[0018] The U-Net model used in the embodiment of the present invention has an encoder-decoder architecture, which can effectively capture the contextual information and detail features of the image. In the segmentation and recognition of alum flowers, the encoder part can extract the high-level semantic features of the floc image; the decoder part can restore these high-level features to the segmentation results with a resolution close to the original image, accurately locate and segment the alum flowers, and the final alum flower recognition model optimized by the generative adversarial network has better generalization ability. It can better adapt to the alum flower recognition task under different water qualities and different flocculation conditions.
[0019] In an optional implementation, the initial alum flower recognition model is optimized by using a generative adversarial network to obtain a final alum flower recognition model, including:
[0020] The method of optimizing the initial alum flower recognition model by using a generative adversarial network to obtain a final alum flower recognition model includes:
[0021] Inputting the flocculent image into a generator in a generative adversarial network to train the generator based on a first loss function;
[0022] The recognition result generated by the initial alum flower recognition model and the real data are simultaneously fed into the discriminator of the generative adversarial network, and the discriminator is trained based on the second loss function, wherein the second loss function includes the supervised learning loss of the labeled sample data and the unsupervised learning loss of the unlabeled sample data and the generated samples;
[0023] The model trained based on the objective function composed of the first loss function and the second loss function is used as the final alum flower recognition model.
[0024] In the embodiment of the present invention, the generator of the adversarial generative network provides richer feature information and data diversity, and the discriminator ensures that the model accurately discriminates the real data and recognition results. This synergy enables the final model to more accurately identify various complex floc images and different alum flower forms.
[0025] In an optional embodiment, the floc characteristic parameters are extracted based on the alum floc identification result, including:
[0026] Based on the alum floc coordinate information output by the alum floc recognition model, all alum floc positions in the floc image are extracted and a segmentation mask is generated. Based on the pixel point information obtained by the segmentation mask, the alum floc particle size, alum floc area, alum floc distribution density, average particle size, and alum floc distribution density change rate are obtained.
[0027] The embodiment of the present invention can reflect the state of flocs in sewage in real time through these floc characteristic parameters, and adjust the dosage of coagulant according to these parameters, so as to achieve accurate addition of coagulant, improve sewage treatment efficiency, and reduce reagent waste.
[0028] In an optional embodiment, the training process of the coagulant prediction model includes:
[0029] Obtain historical operation data of the sewage treatment plant and perform preprocessing, the historical operation data including: water quality parameters, coagulant dosage, effluent turbidity; wherein the water quality parameters include: inlet turbidity, inlet pH value, inlet temperature, inlet flow rate;
[0030] Obtain the history of the sewage treatment plant, collect floc images in the flocculation tank according to a preset time period, input them into the pre-trained alum floc segmentation and recognition model to obtain alum floc recognition results, and extract floc feature parameters based on the alum floc recognition results;
[0031] The historical operation data and floc characteristic parameters are integrated and divided into a training set and a test set, wherein the water quality of the influent is divided into different types based on the historical operation data using a preset unsupervised clustering algorithm, and the training set is obtained by stratified sampling based on different types of water quality parameters;
[0032] The training set is divided into multiple data subsets and respectively input into multiple learners for training, the trained models are evaluated based on preset evaluation indicators, the final learner or learner combination is determined according to the evaluation value as the final coagulant prediction model, and the coagulant dosage is obtained as the prediction result based on the coagulant prediction model.
[0033] The embodiment of the present invention adopts a stratified sampling method based on different types of water quality parameters to obtain a training set, thereby ensuring that the training set can comprehensively and representatively cover various water quality conditions. This can avoid deviations in the training set, so that the trained model can adapt to the prediction of coagulant dosage under different water quality conditions, thereby improving the generalization ability of the model. The training set is divided into multiple data subsets and input into multiple learners for training, respectively, so that the characteristics and advantages of different learners can be utilized. By comparing the evaluation values of different learners or learner combinations, the model that best suits the actual sewage treatment needs can be selected, thereby providing more accurate control parameters for the sewage treatment process.
[0034] In an optional implementation, the method of determining the final learner or learner combination as the final coagulant prediction model according to the evaluation value includes:
[0035] When a single evaluation index is used, the evaluation values are sorted in order of size, and the final coagulant prediction model is determined based on the sorting results;
[0036] When multiple evaluation indicators are used, the average of the prediction results corresponding to the learners with evaluation values greater than the preset threshold is taken as the final prediction result.
[0037] The embodiment of the present invention can effectively screen out learners with higher quality and stronger prediction ability based on evaluating the trained model with evaluation value, avoid using models with poor performance, and thus ensure the credibility and accuracy of the final prediction results. The average result of the prediction data corresponding to the learner with evaluation value greater than the threshold can reduce the large fluctuation of the prediction results caused by problems such as individual data anomalies or overfitting of the learner. In the sewage treatment process, factors such as influent water quality may fluctuate to a certain extent. The use of the average method can make the prediction result of the coagulant dosage more robust, which helps to achieve a more stable sewage treatment effect.
[0038] In a second aspect, the present invention provides a coagulant dosing control system for sewage treatment, comprising:
[0039] A floc image recognition module is used to obtain floc images in the flocculation tank in real time and input them into a pre-trained floc segmentation and recognition model to obtain floc recognition results, wherein the floc segmentation and recognition model is a U-Net model optimized based on a generative adversarial network;
[0040] A floc characteristic parameter extraction module, used for extracting floc characteristic parameters based on the alum floc identification result;
[0041] Water quality parameter acquisition module, used to obtain water quality parameters entering the sewage treatment plant in real time;
[0042] A coagulant addition data identification module is used to input the floc characteristic parameters and the water quality parameters into a coagulant prediction model trained based on ensemble learning to obtain predicted coagulant addition data;
[0043] The coagulant dosing control module is used to control the operation of the coagulant dosing pump based on the predicted coagulant dosing data.
[0044] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for controlling coagulant addition in sewage treatment according to the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0045] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the method for controlling coagulant addition in sewage treatment according to the first aspect or any corresponding embodiment thereof.
[0046] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions for causing a computer to execute the method for controlling coagulant addition in sewage treatment according to the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0048] Figure 1 is a schematic flow chart of a method for controlling coagulant addition in sewage treatment according to an embodiment of the present invention;
[0049] Figure 2 It is a flow chart of a training process of alum flower segmentation and recognition model according to an embodiment of the present invention;
[0050] Figure 3 is a flow chart of a coagulant prediction model training process according to an embodiment of the present invention;
[0051] Figure 4 is a structural block diagram of a coagulant dosing control system in sewage treatment according to an embodiment of the present invention;
[0052] Figure 5 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution 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 part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0054] An embodiment of the present invention provides an embodiment of a method for controlling the addition of a coagulant in sewage treatment. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0055] In this embodiment, a method for controlling the addition of coagulant in sewage treatment is provided. Figure 1 FIG. 1 is a flow chart of a method for controlling coagulant addition in sewage treatment according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:
[0056] S101, acquiring the floc image in the flocculation tank in real time, and inputting it into the pre-trained alum flower segmentation and recognition model to obtain the alum flower recognition result, and the alum flower segmentation and recognition model is a U-Net model optimized based on the generative adversarial network.
[0057] Specifically, the embodiment of the present invention can more accurately identify the flocs by acquiring the floc image in the flocculation tank and analyzing it using a pre-trained floc segmentation and recognition model (based on the U-Net model optimized by the generative adversarial network). The U-Net model itself has a good performance in the field of image segmentation. After being optimized by the generative adversarial network, its accuracy in segmenting and identifying targets such as flocs is further improved, thus laying the foundation for the subsequent accurate extraction of floc feature parameters.
[0058] S102, extracting floc characteristic parameters based on the floc recognition result.
[0059] Specifically, the floc characteristic parameters include: floc size, floc area, floc distribution density, average particle size, and floc distribution density change rate. The amount of coagulant added is closely related to the formation of flocs. For example, the floc size and area can reflect the degree of coagulation reaction, and the floc distribution density and average particle size provide information on the spatial distribution of flocs in water. The appropriate dosage will make the flocs evenly distributed and the average particle size within a reasonable range. For example, during the flow of sewage, evenly distributed flocs (appropriate distribution density) can effectively adsorb and settle suspended particles. The average particle size helps to determine the optimal sedimentation conditions, and then infer the required coagulant dosage. In addition, the floc distribution density change rate can dynamically reflect the changing trend of the coagulation process. If the rate of change is abnormal, such as a sudden increase or decrease, this may indicate that the coagulant dosage needs to be adjusted in time.
[0060] S103, obtaining water quality parameters entering the sewage treatment plant in real time.
[0061] Specifically, the water quality parameters in the embodiments of the present invention include: inlet turbidity, inlet pH value, inlet temperature, and inlet flow rate. Among them, inlet turbidity is a key indicator to measure the amount of suspended particles in the water. Generally, the higher the inlet turbidity, the greater the amount of coagulant required, because more suspended particles require coagulants to promote their coagulation and precipitation; the pH value has a significant effect on the hydrolysis and coagulation effects of the coagulant. Different coagulants work best in different pH ranges; the inlet temperature affects the rate of coagulation reaction; the inlet flow rate determines the residence time of sewage in the treatment unit. A larger inlet flow rate means that the sewage stays in the reaction tank for a shorter time. In order to achieve a good coagulation effect within a limited time, it may be necessary to increase the amount of coagulant.
[0062] S104, inputting floc characteristic parameters and water quality parameters into the coagulant prediction model trained based on ensemble learning to obtain predicted coagulant dosage data.
[0063] The embodiment of the present invention not only considers the floc characteristic parameters, but also combines the water quality data entering the sewage treatment plant and inputs them into the coagulant prediction model trained based on ensemble learning. Ensemble learning can integrate the advantages of multiple different learning models, reduce the errors and deviations of a single model, make the prediction of coagulant addition data more accurate, and more in line with the complex and changeable situations in actual sewage treatment, avoiding the problem of inaccurate coagulant addition control caused by relying solely on a single factor. The predicted coagulant addition data includes the coagulant dosage.
[0064] S105, controlling the operation of the coagulant dosing pump based on the predicted coagulant dosing data.
[0065] The embodiment of the present invention controls the operation of the coagulant dosing pump based on the predicted coagulant dosage, and the entire process forms an automated control chain. There is no need for manual monitoring and manual adjustment of the coagulant dosage, which greatly reduces the labor cost investment. It also avoids the subjective errors and untimely operations that may be caused by manual operations, thereby improving the overall efficiency of sewage treatment, helping to achieve reasonable and accurate addition of coagulants, optimize resource utilization, and improve the cost-effectiveness of sewage treatment.
[0066] The method for controlling coagulant addition in sewage treatment provided by the embodiment of the present invention can accurately give appropriate coagulant addition data by acquiring water quality parameter data in real time in combination with floc characteristics, and using advanced models (alum floc segmentation and recognition model, coagulant prediction model). It is combined with the operating mechanism of the coagulation process itself and has strong adaptability. At the same time, the alum floc segmentation and recognition model and the coagulant prediction model are trained based on a large amount of data. It is a data-driven control method, which is more scientific and objective than the traditional dosing method relying on experience. Moreover, as new data is accumulated in the future, the model can be further optimized to continuously improve the accuracy of dosing control, thereby ensuring that sewage treatment can achieve better results under various water quality conditions, and improving the treatment efficiency and reducing operating costs by improving the automation level of water treatment.
[0067] In one embodiment, the training process of the alum flower segmentation and recognition model in the embodiment of the present invention is as follows: Figure 2 As shown, the following steps are included:
[0068] S201, collecting floc images in a flocculation tank at a preset time period, and performing image enhancement preprocessing on the collected images to obtain floc images.
[0069] In the embodiment of the present invention, an industrial camera (using a global shutter camera) is installed in the flocculation tank to capture floc images at regular intervals, such as capturing a set of floc images every 15 seconds, and then the collected image data is divided into a training set and a validation set in a ratio of 8:2, which is only an example and not limited to this.
[0070] Furthermore, the collected image is subjected to image enhancement preprocessing to obtain a floc image, specifically:
[0071] The collected image is grayed and gray-scale distribution is grayed to enhance the contrast of the image. However, due to the turbidity of the water, there are still a lot of noise points in the grayed image, and graying will inevitably blur the boundaries of the alum flowers. Therefore, the mean filter method is used for further processing.
[0072] S202, marking the flocs at different time periods in the pre-processed floc image, and extracting the coordinate information of the marking box as the marking data.
[0073] Specifically, data annotation software can be used to annotate the flocs at different time periods in floc images at different time periods, and a training set is formed by framing the edge of the flocs in the image and extracting the coordinate information of the calibration frame.
[0074] S203, inputting the labeled data into the U-Net model, and training the model based on the cross entropy loss function, and using the trained model as the initial alum flower recognition model.
[0075] The embodiment of the present invention adopts the U-Net model to perform supervised learning on the annotated alum flower image, and learns the segmentation features from the annotated data. The U-Net model mainly includes two parts: an encoder and a decoder. The encoder part extracts image features (such as edges, textures, etc.) through multi-layer convolution (the convolution layer is responsible for extracting local features in the image, and a convolution operation is performed on the image by sliding a window to generate a feature map) and pooling operation (using a maximum pooling strategy to reduce feature dimensions and extract the most significant features). The decoder part gradually restores the spatial resolution of the image, and at the same time uses a jump connection to introduce high-resolution features to generate a segmentation map with the same resolution as the original image. The decoder and the encoder are connected through a jump connection. The feature map in the encoder is directly transferred to the corresponding layer in the decoder, and the high-resolution detail information in the encoder is fused with the abstract features in the decoder through a splicing operation. The cross entropy loss function is applied to optimize the model and obtain a trained initial alum flower recognition model, wherein the cross entropy loss function is expressed by the following formula:
[0076]
[0077] Where, L seg is the cross entropy loss function; N is yi Total number of pixels, y i is the true label of the i-th pixel, p i Predict the probability for the i-th pixel.
[0078] S204, using a generative adversarial network to optimize the recognition result of the initial alum flower recognition model to obtain a final alum flower recognition model.
[0079] Specifically, since the U-Net network can extract local and global information respectively, a good detection effect is achieved. The U-Net network can achieve effective classification when the number of samples is insufficient by reusing sample information for multi-scale target feature extraction. However, when the training set and test set data do not match, the generalization ability of the U-Net network is weak. The embodiment of the present invention utilizes the adversarial performance of the generative adversarial network to train the classification ability of the U-Net network, and uses jump connections for multi-scale feature extraction, which can extract effective classification features of the target, thereby avoiding the problem of rapid decline in recognition ability of a single U-Net network when the data does not match. The pre-trained model of supervised learning trained in the early stage is used as the basis for generative adversarial learning, and the generative adversarial network is introduced, combined with the image segmentation network of supervised learning, to achieve effective learning of image segmentation features.
[0080] The generative adversarial network consists of two parts: the generator (G) and the discriminator (D). The generator can take the flocculent image as input and generate samples; the discriminator discriminates the distribution of the real data and the output distribution of the generative model. The generator and the discriminator reach a Nash equilibrium in the process of mutual game. For the data mismatch problem, the game idea of the generative adversarial network can be used to optimize the classification ability of the U-Net network. The data output by the U-Net network and the real data are sent to the discriminator at the same time. The discriminator will classify the model category. The output of the discriminator model category calculates the cross entropy between the real data and the original label, and the cross entropy between the U-Net model output and the original label.
[0081] Specifically, the above-mentioned generative adversarial network is used to optimize the initial alum flower recognition model to obtain the final alum flower recognition model, including:
[0082] S2041, inputting the flocculent image into a generator in a generative adversarial network to train the generator based on a first loss function.
[0083] Specifically, the loss function formula of the generator is expressed as follows:
[0084]
[0085] Among them, L Gis the generator loss function, which indicates the probability of the generated sample being predicted by the discriminator; x is the real image data; p z (z) is the image data generated by the generator; G(z) is the data generated by the generator; D(G(z)) is the output of the discriminator, which is used to distinguish between generated data and real data. It is generally a value between 0 and 1. When the output is biased towards 0, it means that the input data is likely to be generated data, and when the output is biased towards 1, it means that the input data is biased towards real data; E x~pz(z) From the data distribution p z (z) is the expected value of the data sampled in x.
[0086] S2042, the recognition result generated by the initial alum flower recognition model and the real data are simultaneously sent to the discriminator of the generative adversarial network, and the discriminator is trained based on the second loss function, wherein the second loss function includes the supervised learning loss of the labeled sample data and the unsupervised learning loss of the unlabeled sample data and the generated samples.
[0087] Specifically, the supervised learning loss is expressed by the following formula:
[0088]
[0089] Among them, x, y are real data, and the label of the real sample y∈{1,...C}, Represents the distribution of data p data The expected value of the data sampled in (x,y) for x,y.
[0090] The unsupervised learning loss is expressed by the following formula:
[0091]
[0092] Among them, E x~Pdata(x) From the data distribution P data (x) is the expected value of the sampled data for x; Z~P Z (Z) indicates that the sample comes from the generator, E z~pz(z) From the data distribution p z(z) The expected value of the sampled data for z. The label of the generated sample is set to C+1. For the generated sample, the probability that the sample belongs to C+1 needs to be calculated, that is, p model (y=C+1|x); For unlabeled real samples, we only need to calculate the probability that the sample does not belong to the C+1th class, that is, 1-p model (y=C+1|x).
[0093] Combining the supervised loss function and the unsupervised loss function, the discriminator loss function is:
[0094]
[0095] S2043, using the model trained based on the objective function composed of the first loss function and the second loss function as the final alum flower recognition model.
[0096] Specifically, the total loss function of the U-Net optimization model is L = L G +L D。 Other parameters, such as the learning rate of the generator network is 0.0005, the training rounds are 50, and the learning rate of the discriminator network is 0.0001, are only used as examples and are not limited to this. Cross entropy can be used as a loss function during training. Cross entropy represents the difference between the generated data distribution and the real data distribution. It is used to measure the distance between one probability distribution and another probability distribution. The smaller the cross entropy value, the closer the network model is to the optimal. In the actual training process, a cross-training mode is adopted, that is, the discriminator and generator are trained alternately. For example, first train the discriminator times (can be 1, 2, etc.), and then train the generator once. In this way, it is iterated repeatedly. As the training progresses, the parameters of the generator and the discriminator are continuously optimized. The quality of the samples generated by the generator will gradually improve, and the ability of the discriminator to distinguish between real samples and generated samples will also be continuously adjusted until a balance is reached.
[0097] In a specific embodiment, if Figure 3 As shown in FIG. 1 , the process of training the prediction model for predicting coagulant includes the following steps:
[0098] S301: Obtain historical operation data of the sewage treatment plant, including: water quality parameters, coagulant dosage, and effluent turbidity; the water quality parameters include: inlet turbidity, inlet pH value, inlet temperature, and inlet flow rate.
[0099] The present invention can determine the optimal coagulant dosage for achieving the expected effluent turbidity under different water quality parameters by analyzing historical data, and the historical operation data can help find the optimal coagulation effect under different dosages.
[0100] In one embodiment, the operating data of an existing sewage treatment plant for one year is collected. This is only used as an example and is not limited to this. In actual applications, reasonable settings are made according to specific needs. Due to special circumstances such as human detection errors and failures in the reagent dosing system during data collection, there are abnormal values and missing values in the original data set, which need to be preprocessed for subsequent model construction. The preprocessing mainly includes the following contents: 1) Use the 3σ criterion to eliminate abnormal values in each variable; 2) For missing data, use the average value of the three data before and after the missing value of each variable to replace it; 3) Use the maximum and minimum normalization method to normalize each variable to eliminate the influence of dimension. After preprocessing, valid data is obtained.
[0101] S302: Obtain the history of the sewage treatment plant, collect floc images in the flocculation tank according to a preset time period, and input them into a pre-trained floc segmentation and recognition model to obtain floc recognition results, and extract floc feature parameters based on the floc recognition results.
[0102] Specifically, the floc characteristic parameters include: alum floc particle size, alum floc area, alum floc distribution density, average particle size, and alum floc distribution density change rate. Among them, the calculation formulas for the single alum floc area and the total area are as follows:
[0103]
[0104] In the formula, A i is the area of the i-th connected region; (x, y) is the coordinate of the pixel in the image; N i (x, y) is the segmentation mask of the i-th blobs, a value of 1 indicates that the pixel belongs to blobs, and a value of 0 indicates that the pixel does not belong to blobs; A is the total area of blobs in the picture; n is the total number of blobs.
[0105] The calculation method of alum flower particle size and average particle size is as follows:
[0106]
[0107] In the formula, K i is the particle size of the ith alum flower, in pixels; K avg is the average particle size, indicating the average size of alum flowers in the sample.
[0108] The distribution density of alum flowers and the rate of change of alum flower distribution density are obtained by weighted average of the particle sizes of all alum flowers. The specific calculation method is shown in the following formula:
[0109]
[0110] In the formula, ρ floc is the distribution density of alum flowers; P is the image size; R ρ is the rate of change of alum flower distribution density; Δρ floc is the change in the density of alum flowers; Δt is the change in time.
[0111] S303: Integrate the historical operation data and floc characteristic parameters and divide them into a training set and a test set, wherein the water quality of the influent is divided into different types based on the historical operation data using a preset unsupervised clustering algorithm, and a stratified sampling method is used to obtain the training set based on different types of water quality parameters.
[0112] Specifically, the historical operation data and floc characteristic parameters are merged according to the timestamp or sample number, and the integrated data is divided into a training set and a test set using a random sampling method. In order to enable the model to grasp a more comprehensive dosage rule during the training stage, the embodiment of the present invention uses an unsupervised clustering algorithm to classify water quality, and then divides the samples of the training set. Specifically, the K-Means clustering algorithm is used, which is an unsupervised learning algorithm commonly used for unlabeled data classification problems. It can adjust the cluster center through continuous iteration to minimize the loss function, and finally divide the data into K categories. It has the characteristics of high time efficiency, strong interpretability, and the ability to specify the number of cluster categories.
[0113] Specifically: First, K-Means clustering is used to classify water quality according to the two characteristics of raw water turbidity and water temperature. The number of categories is determined according to the elbow rule (an empirical method for determining the number of clusters, mainly used in cluster analysis scenarios in unsupervised learning. The optimal number of clusters is determined by observing the curve of clustering error changing with the number of clusters and finding the "elbow" position of the curve). It is divided into three categories: low temperature and low turbidity (0-10℃, less than 30NTU), high temperature and high turbidity (10-30℃, greater than 100NTU), and high temperature and low turbidity (10-30℃, less than 30NTU); secondly, a stratified sampling method is used, such as dividing the pre-processed data into a training set and a test set according to a ratio of 7:3. The specific method is to extract 70% of each type of water quality data to form a training set, and the remaining 30% to form a test set. Compared with the traditional random extraction division method, the method of first classification and then stratified sampling can specify that the water quality data containing different rules will be evenly divided, so that the model can obtain a more comprehensive training effect in a limited sample.
[0114] S304: Divide the training set into multiple data subsets and input them into multiple learners for training respectively, evaluate the trained model based on preset evaluation indicators, determine the final learner or learner combination as the final coagulant prediction model according to the evaluation value, and obtain the coagulant dosage as the prediction result based on the coagulant prediction model.
[0115] The present invention adopts the bagging method, which uses the self-service sampling method to extract several data subsets, trains learners on each subset, and takes the prediction mean of each learner as the final prediction result. The bagging method can achieve complementary advantages between learners and effectively reduce the test error. The selection of learner type is also an important factor affecting the effect of ensemble learning. Selecting a learner with high accuracy and large differences has a better ensemble prediction effect.
[0116] In a specific embodiment, 7 data subsets are extracted from the training set using a self-service sampling method. A total of 7 learners, including support vector machine, random forest, Adaboost, GBDT, Catboost, XGBoost and LightGBM, are selected for integration. Support vector machine has a good effect in solving small sample, nonlinear and high-dimensional pattern recognition problems. The other 6 learners, such as random forest, Adaboost, GBDT, are all tree-based ensemble learning algorithms, which are robust to missing values and noise, and also have good processing capabilities for sparse matrices. It should be noted that the above 7 classifiers in the embodiment of the present invention are exemplified and are not limited to this. Other number of other classifiers can also be used for ensemble learning.
[0117] After completing the training of the above 7 classifiers, the embodiment of the present invention selects R 2 The prediction effect is evaluated by at least one of the three error indicators: root mean square error (RMSE) and mean relative error (MAPE). 2 The closer it is to 1, the closer RMSE is to 0, and the closer MAPE is to 0, the better the prediction effect.
[0118] When a single evaluation index is used, the evaluation values are sorted in order of size, and the final coagulant prediction model is determined based on the sorting results. For example, if the root mean square error (RMSE) is selected as the evaluation index, the RMSE value of each model is calculated separately, and then the learners are sorted from small to large according to the RMSE value, and the first learner after sorting is selected as the final coagulant prediction model.
[0119] When multiple evaluation indicators are used, the average of the prediction results corresponding to the learners with evaluation values greater than the preset threshold is taken as the final prediction result. 2 Greater than 0.8, RMSE less than 5, and MAPE less than 10 are used as screening conditions to determine the learners with good prediction effects, and the average of the prediction results of these learners is taken as the final prediction result.
[0120] The above method can effectively screen out learners with high quality and strong prediction ability, avoid using models with poor performance, and thus ensure the credibility and accuracy of the final prediction results. The average result of the prediction data corresponding to the learners with evaluation values greater than the threshold can reduce the large fluctuations in the prediction results caused by problems such as individual data anomalies or learner overfitting. In the sewage treatment process, factors such as influent water quality may fluctuate to a certain extent. The use of the average method can make the prediction results of the coagulant dosage more robust, which helps to achieve a more stable sewage treatment effect.
[0121] In this embodiment, a coagulant dosing control system for sewage treatment is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made are not repeated here. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the system described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.
[0122] This embodiment provides a coagulant dosing control system for sewage treatment, such as Figure 4 As shown, including:
[0123] The floc image recognition module 401 is used to obtain the floc image in the flocculation tank in real time and input it into the pre-trained floc segmentation and recognition model to obtain the floc recognition result, wherein the floc segmentation and recognition model is a U-Net model optimized based on the generative adversarial network;
[0124] A floc characteristic parameter extraction module 402, used to extract floc characteristic parameters based on the alum floc identification result;
[0125] The water quality parameter acquisition module 403 is used to obtain the water quality parameters entering the sewage treatment plant in real time;
[0126] A coagulant addition data identification module 404 is used to input the floc characteristic parameters and the water quality parameters into the coagulant prediction model trained based on ensemble learning to obtain predicted coagulant addition data;
[0127] The coagulant dosing control module 405 is used to control the operation of the coagulant dosing pump based on the predicted coagulant dosing data.
[0128] In some optional implementations, the training process of the alum flower segmentation and recognition model includes:
[0129] Collect floc images in the flocculation tank according to a preset time period, and perform image enhancement preprocessing on the collected images to obtain floc images;
[0130] Marking the flocs at different time periods in the pre-processed floc image, and extracting the coordinate information of the marking box as the marking data;
[0131] Input the labeled data into the U-Net model, train the model based on the cross entropy loss function, and use the trained model as the initial alum flower recognition model;
[0132] The generative adversarial network is used to optimize the recognition results of the initial alum flower recognition model to obtain the final alum flower recognition model.
[0133] In some optional implementations, the initial alum flower recognition model is optimized using a generative adversarial network to obtain a final alum flower recognition model, including:
[0134] Inputting the flocculent image into a generator in a generative adversarial network to train the generator based on a first loss function;
[0135] The recognition result generated by the initial alum flower recognition model and the real data are simultaneously fed into the discriminator of the generative adversarial network, and the discriminator is trained based on the second loss function, wherein the second loss function includes the supervised learning loss of the labeled sample data and the unsupervised learning loss of the unlabeled sample data and the generated samples;
[0136] The model trained based on the objective function composed of the first loss function and the second loss function is used as the final alum flower recognition model.
[0137] In some optional embodiments, the floc characteristic parameters are extracted based on the alum floc identification result, including:
[0138] Based on the alum floc coordinate information output by the alum floc recognition model, all alum floc positions in the floc image are extracted and a segmentation mask is generated. Based on the pixel point information obtained by the segmentation mask, the alum floc particle size, alum floc area, alum floc distribution density, average particle size, and alum floc distribution density change rate are obtained.
[0139] In some optional embodiments, the training process of the coagulant prediction model includes:
[0140] Obtain historical operation data of the sewage treatment plant and perform preprocessing, the historical operation data including: water quality parameters, coagulant dosage, effluent turbidity; wherein the water quality parameters include: inlet turbidity, inlet pH value, inlet temperature, inlet flow rate;
[0141] Obtain the history of the sewage treatment plant, collect floc images in the flocculation tank according to a preset time period, input them into the pre-trained alum floc segmentation and recognition model to obtain alum floc recognition results, and extract floc feature parameters based on the alum floc recognition results;
[0142] The historical operation data and floc characteristic parameters are integrated and divided into a training set and a test set, wherein the water quality of the influent is divided into different types based on the historical operation data using a preset unsupervised clustering algorithm, and the training set is obtained by stratified sampling based on different types of water quality parameters;
[0143] The training set is divided into multiple data subsets and respectively input into multiple learners for training, the trained models are evaluated based on preset evaluation indicators, the final learner or learner combination is determined according to the evaluation value as the final coagulant prediction model, and the coagulant dosage is obtained as the prediction result based on the coagulant prediction model.
[0144] In some optional implementations, determining the final learner or learner combination as the final coagulant prediction model according to the evaluation value includes:
[0145] When a single evaluation index is used, the evaluation values are sorted in order of size, and the final coagulant prediction model is determined based on the sorting results;
[0146] When multiple evaluation indicators are used, the average of the prediction results corresponding to the learners with evaluation values greater than the preset threshold is taken as the final prediction result.
[0147] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0148] The coagulant addition control system in sewage treatment in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0149] The embodiment of the present invention also provides a computer device having the above Figure 4 The coagulant dosing control system in sewage treatment is shown.
[0150] See also Figure 5 , Figure 5 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 5 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 5 A processor 10 is taken as an example.
[0151] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0152] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.
[0153] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0154] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0155] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0156] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor central control system or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor or hardware, the method shown in the above embodiment is implemented.
[0157] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0158] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for controlling coagulant addition in sewage treatment, characterized in that: include: Acquire the floc image in the flocculation tank in real time, and input it into the pre-trained alum flower segmentation and recognition model to obtain the alum flower recognition result, wherein the alum flower segmentation and recognition model is a U-Net model optimized based on the generative adversarial network; Extracting floc characteristic parameters based on the alum floc identification result; Obtain water quality parameters entering the sewage treatment plant in real time; Inputting the floc characteristic parameters and the water quality parameters into a coagulant prediction model trained based on ensemble learning to obtain predicted coagulant dosage data; The operation of the coagulant dosing pump is controlled based on the predicted coagulant dosage data.
2. The method according to claim 1, characterized in that The training process of the alum flower segmentation and recognition model includes: Collect floc images in the flocculation tank according to a preset time period, and perform image enhancement preprocessing on the collected images to obtain floc images; Marking the flocs at different time periods in the pre-processed floc image, and extracting the coordinate information of the marking box as the marking data; Input the labeled data into the U-Net model, train the model based on the cross entropy loss function, and use the trained model as the initial alum flower recognition model; The generative adversarial network is used to optimize the recognition results of the initial alum flower recognition model to obtain the final alum flower recognition model.
3. The method according to claim 2, characterized in that The method of optimizing the initial alum flower recognition model by using a generative adversarial network to obtain a final alum flower recognition model includes: Inputting the flocculent image into a generator in a generative adversarial network to train the generator based on a first loss function; The recognition result generated by the initial alum flower recognition model and the real data are simultaneously fed into the discriminator of the generative adversarial network, and the discriminator is trained based on the second loss function, wherein the second loss function includes the supervised learning loss of the labeled sample data and the unsupervised learning loss of the unlabeled sample data and the generated samples; The model trained based on the objective function composed of the first loss function and the second loss function is used as the final alum flower recognition model.
4. The method according to claim 2, characterized in that: The method of extracting floc characteristic parameters based on the alum floc identification result includes: Based on the alum floc coordinate information output by the alum floc recognition model, all alum floc positions in the floc image are extracted and a segmentation mask is generated. Based on the pixel point information obtained by the segmentation mask, the alum floc particle size, alum floc area, alum floc distribution density, average particle size, and alum floc distribution density change rate are obtained.
5. The method according to claim 1 or 4, characterized in that: The training process of the coagulant prediction model includes: Obtain historical operation data of the sewage treatment plant and perform preprocessing, the historical operation data including: water quality parameters, coagulant dosage, effluent turbidity; wherein the water quality parameters include: inlet turbidity, inlet pH value, inlet temperature, inlet flow rate; Obtain the history of the sewage treatment plant, collect floc images in the flocculation tank according to a preset time period, input them into the pre-trained alum floc segmentation and recognition model to obtain alum floc recognition results, and extract floc feature parameters based on the alum floc recognition results; The historical operation data and floc characteristic parameters are integrated and divided into a training set and a test set, wherein the water quality of the influent is divided into different types based on the historical operation data using a preset unsupervised clustering algorithm, and the training set is obtained by stratified sampling based on different types of water quality parameters; The training set is divided into multiple data subsets and respectively input into multiple learners for training, the trained models are evaluated based on preset evaluation indicators, the final learner or learner combination is determined according to the evaluation value as the final coagulant prediction model, and the coagulant dosage is obtained as the prediction result based on the coagulant prediction model.
6. The method according to claim 5, characterized in that The method of determining the final learner or learner combination as the final coagulant prediction model according to the evaluation value includes: When a single evaluation index is used, the evaluation values are sorted in order of size, and the final coagulant prediction model is determined based on the sorting results; When multiple evaluation indicators are used, the average of the prediction results corresponding to the learners with evaluation values greater than the preset threshold is taken as the final prediction result.
7. A coagulant dosing control system in sewage treatment, characterized in that: include: A floc image recognition module is used to obtain floc images in the flocculation tank in real time and input them into a pre-trained floc segmentation and recognition model to obtain floc recognition results, wherein the floc segmentation and recognition model is a U-Net model optimized based on a generative adversarial network; A floc characteristic parameter extraction module, used for extracting floc characteristic parameters based on the alum floc identification result; Water quality parameter acquisition module, used to obtain water quality parameters entering the sewage treatment plant in real time; A coagulant addition data identification module is used to input the floc characteristic parameters and the water quality parameters into a coagulant prediction model trained based on ensemble learning to obtain predicted coagulant addition data; The coagulant dosing control module is used to control the operation of the coagulant dosing pump based on the predicted coagulant dosing data.
8. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for controlling coagulant addition in sewage treatment according to any one of claims 1 to 6 by executing the computer instructions.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the method for controlling coagulant addition in sewage treatment according to any one of claims 1-6.
10. A computer program product, characterized in that It comprises computer instructions, and the computer instructions are used to enable a computer to execute the coagulant addition control method in sewage treatment according to any one of claims 1-6.
Citation Information
Cited By
Control system and control method for AI dynamic regulation and control of low-cost magnetic coagulating sedimentation
CN120122544A
Intelligent coagulant adding control method and system based on image recognition and multi-parameter modeling
CN120535101A
Accurate dosing method for sewage plant based on multi-mode automatic machine learning
CN120655932A
Method for enhancing efficiency of anaerobic-aerobic biological system based on ferrous salt coagulation iron mud
CN120717608A
Intelligent decision-making method, system and equipment for sewage medicament addition and medium
CN120746224A