Optimal dosage prediction method based on fcm-anfis model
By combining the FCM-ANFIS model with fuzzy C-means clustering and an adaptive neurofuzzy inference system, the problem of inaccurate coagulant dosage in traditional methods is solved, and rapid and accurate prediction of coagulant dosage is achieved, which is suitable for online control of drinking water treatment plants.
Patent Information
- Application Number
- CN202210382307.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-12
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2042-04-12
AI Technical Summary
Traditional coagulant dosing methods are difficult to adjust in real time, leading to water quality fluctuations and inaccurate dosage. Existing neural network algorithms, such as BP and Elman algorithms, are insufficient to meet the needs of drinking water treatment plants in terms of prediction accuracy and efficiency.
A method based on the FCM-ANFIS model, combined with fuzzy C-means clustering and an adaptive neural fuzzy inference system, was adopted to establish a predictive model for coagulant dosage through data preprocessing, cluster analysis, and model training, and meteorological data was used for prediction.
It enables rapid and accurate prediction of coagulant dosage, improves the applicability and prediction accuracy of the model, and can predict the amount of coagulant to be added for several days in the future based on weather forecast data, overcoming the shortcomings of traditional methods.
Smart Images

Figure CN115206444B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of water purification process, and particularly to a method for predicting optimal dosing amount based on a FCM-ANFIS model. BACKGROUND
[0002] As an important part of water purification process, coagulant dosing is difficult to adjust the dosing amount in real time according to raw water quality due to the nonlinearity and large time lag of the process, and traditional dosing methods such as beaker test. Although some traditional intelligent algorithms such as BP algorithm and Elman algorithm have appeared, they are difficult to meet the requirements of drinking water treatment plants due to low learning efficiency and poor prediction accuracy.
[0003] With the increasing demand for water, the scale of drinking water treatment plants is also increasing. As an important part of water purification process, coagulant dosing will directly affect the water quality, water purification dosing cost and profit of drinking water treatment plants. Coagulant dosing is a complex physical and chemical reaction process, which has the characteristics of complexity, time variation, nonlinearity and large time lag. Under the requirement of water quality, how to reduce the dosing amount of coagulant and achieve the optimal control of coagulant dosing amount has become the focus of the water purification industry.
[0004] For traditional drinking water treatment plants, the dosing amount of coagulant is mainly determined by manual experience method and beaker test method. The manual experience method is to manually adjust the dosage of coagulant according to the formation of flocculation after dosing or the turbidity of effluent from the sedimentation tank. This method is labor-intensive, and when the raw water quality changes frequently, the dosage of coagulant needs to be adjusted in time, and the effluent needs to be observed in real time, which is easy to cause water quality fluctuation and difficult to ensure water quality. The beaker test method is to simulate the actual production of coagulation and disinfection under different water quality conditions, compare the actual effects of different coagulants and their dosing amounts, and determine the optimal coagulant dosing amount. Although the beaker test reduces the work intensity, it is difficult to truly simulate the actual conditions, the optimal dosing amount deviates from the actual situation, and the coagulant dosage cannot be adjusted in time, which obviously has the problems of result lag and poor timeliness.
[0005] In recent years, some artificial neural network algorithms (ANN) have also been applied to the field of drinking water treatment process. Generally, an artificial neural network model is represented by network topology, node characteristics and learning rules, and mainly adjusts the weighted coefficients and other learning processes to make the output reach the expected value. Connection weights, activation functions, network topology structure and other factors can affect the performance of the neural network model. Common ANN algorithms include BP neural network algorithm and Elman neural network algorithm.
[0006] The BP neural network algorithm is a kind of multilayer feedforward neural network, and the BP neural network algorithm is composed of two processes of forward propagation and backward propagation. In the forward propagation process, training samples are processed layer by layer from the input layer to the hidden layer unit, and the output of each layer of neurons only has an influence on the state of the next layer of neurons until the output layer. If there is a deviation between the network output and the expected output, the backward propagation process is entered. In the backward propagation process, the error signal is transmitted back in the original forward propagation path, and the weight coefficients and threshold values of each layer of neurons are corrected in the negative gradient direction of the least mean square error function, so that the expected error function tends to be minimum. Therefore, the BP neural network algorithm is a search algorithm based on the gradient method.
[0007] In the actual coagulant dosage prediction process of the drinking water treatment plant, the BP neural network algorithm has a long learning period in the training and learning process, a large number of parameters are required for the model, and there is no effective method for selecting the parameters, so the number of hidden layers of the BP neural network model can only be determined according to experience. If the initial weight is not properly selected, the BP neural network model is prone to fall into a local minimum value. Moreover, when the number of samples is small, the BP neural network does not have good generalization ability.
[0008] Unlike the BP neural network algorithm, the Elman neural network algorithm adds a connecting unit between the hidden layer and the output layer. The Elman neural network algorithm is a kind of dynamic recurrent neural network model, which is generally composed of an input layer, a hidden layer, a connecting layer and an output layer, and uses an error correction learning algorithm to update the weight values and threshold values between the neurons. The output value of the previous hidden layer element of the neural network algorithm can be output to the connecting layer for storage. Since the hidden layer receives both the data of the input layer and the stored data in the connecting layer, the output generated at different times for the same input data can be different. The connecting layer acts as a delay operator, so that the network has a dynamic memory function and is suitable for time series prediction and other problems.
[0009] The Elman neural network has only one hidden layer. When the information of the input layer, the feedback information of the output layer and the self-feedback information of the hidden layer are all input to the hidden layer, the hidden layer cannot handle a large amount of information, which will cause data redundancy and adversely affect the training efficiency and training effect of the Elman neural network model.
[0010] Obviously, neither the BP neural network algorithm nor the Elman neural network algorithm can achieve good results in the prediction of the coagulant dosage of the drinking water treatment plant, and most of them have problems of time delay and lag, and the prediction accuracy is not high, which is difficult to meet the daily needs of the drinking water treatment plant. SUMMARY
[0011] The application provides an optimal dosing amount prediction method based on an FCM-ANFIS model, combines an FCM clustering algorithm and an ANFIS fuzzy inference system effectively based on a fuzzy C-means clustering adaptive neural fuzzy inference system, and has the advantages of the FCM clustering algorithm and the ANFIS fuzzy inference system, and overcomes the problems of slow convergence, poor prediction accuracy and being easy to fall into a local minimum value of a BP neural network algorithm and an Elman neural network algorithm.
[0012] The application adopts the following technical scheme.
[0013] The optimal dosing amount prediction method based on the FCM-ANFIS model is used for coagulant dosing amount prediction of a water treatment plant, and comprises the following steps.
[0014] Step S1, selecting a drinking water treatment plant whose coagulant dosing is controlled according to the effluent turbidity of a coagulation tank, and taking whole-year raw water quality sample data in historical operation as a data set;
[0015] Step S2, pre-processing the data set, and selecting year data in which temperature has a threshold value above influence on raw water turbidity;
[0016] Step S3, analyzing the similarity between raw water quality data variables to describe the correlation between the water quality data, and clustering and analyzing the pre-processed sample data by using a fuzzy C-means clustering algorithm, and finally obtaining the required clustering center and membership matrix by using the FCM clustering algorithm for iterative loop solving;
[0017] Step S4, introducing an internal fuzzy clustering effectiveness index to evaluate the clustered result, and establishing an ANFIS prediction model;
[0018] Step S5, learning and training the parameters of the ANFIS model by using a hybrid algorithm of a BP algorithm and a least square method, and if the error meets the requirement or the maximum iteration number is reached, the training is terminated, and an FCM-ANFIS fuzzy inference system for dosing amount prediction is established;
[0019] Step S6, clustering the pre-processed data set into N classes by using the FCM clustering algorithm, and inputting the data set into the ANFIS fuzzy inference system to obtain an optimal fuzzy inference system based on the ANFIS prediction model by training and learning;
[0020] Step S7, taking raw water quality of the drinking water treatment plant as sample data, and predicting by using the fuzzy inference system.
[0021] In step S2, the noise and abnormal points in the sample data are removed and corrected by interpolation method.
[0022] In step S3, Pearson correlation coefficient and difference matrix based on Euclidean distance are used to analyze the raw water quality data of the drinking water treatment plant by using the "statistical product and service solutions" software SPSS, and Z-score is used to convert the Euclidean distance to see the similarity between the data, the smaller the value of Z-score, the greater the similarity between variables, and vice versa.
[0023] In step S3, the preprocessed sample data is clustered and analyzed by using fuzzy C-means clustering algorithm FCM; the fuzzy C-means clustering algorithm uses membership function to determine the membership clustering center of the sampling point; the algorithm is based on loop calculation, and the clustering classification is completed by modifying the clustering center and classification matrix belonging to the membership function, specifically: FCM decomposes n data vectors X i (i=1, 2,..., n) into C fuzzy groups, and calculates the clustering center of each fuzzy group under the condition of meeting the minimum cost function; FCM uses membership value between 0-1 to determine the membership degree of the sampling data; through the initialization processing of the data, the membership sum of a sampling data combination is 1, that is
[0024]
[0025] The cost function of FCM is represented as:
[0026]
[0027] In formula two, H i is the i clustering center, U is the membership matrix; d ij =||H i +-X i ||is the Euclidean distance from the i-th center to the j-th sampling data point; m is a weighted number greater than 1; the necessary condition for the cost function J to reach the minimum value is obtained by using Lagrange method, and then the u ij and X j are derived, and then the FCM clustering algorithm is used for iterative loop solution, and finally the required clustering center and membership matrix are obtained.
[0028] The evaluation indexes used in step S4 include Bezdek partition coefficient, Xie-Beni coefficient, reconstruction error rate V RE and P BM index;
[0029] The Bezdek partition coefficient is V PCThe membership of the divided data is redefined, i.e. the sum of the square of the membership of all elements to each category, defined as follows:
[0030]
[0031] In the formula, u is an element of the data, and n is the number of elements; V PC The larger the value is, the better the clustering effect is;
[0032] The Xie-Beni coefficient is V XB , which is defined as:
[0033]
[0034] In the formula, x is an element before division, and v is an element after division.
[0035] V RE is the reconstruction error rate of the data, which is defined as follows:
[0036]
[0037] In the formula, I(t) and I'(t) are the values of the ith data before and after reconstruction, respectively; V RE The smaller the value is, the better the division effect of the clustering algorithm is;
[0038] P BM is an index of clustering effectiveness, defined as follows:
[0039]
[0040] In the formula, K is the given number of categories, and E1 is the given data set, which is a constant; E k is the sum of the fuzzy distance between the data to be classified and the cluster centers in the individual, and P BM The value of P k will increase as E k decreases. D k is the maximum distance between the cluster centers in the individual; P BM The larger the value of P BM is, the better the division effect is;
[0041] According to the calculation formula of the above related indexes, the calculation of the related indexes of the FCM clustering algorithm is carried out, and the calculation results are evaluated. If the value of V RE is very small, and the value of P BM is very large, it indicates that the clustering effect of the FCM fuzzy clustering algorithm is better.
[0042] In step S5, the ANFIS prediction model is an adaptive neuro-fuzzy inference system, specifically a Sugeno-type fuzzy neural network inference system, which adopts If-Then fuzzy rules, and the output is expressed as a linear combination of fuzzy subsets of inputs, which is expressed in a formula as follows:
[0043] If x is A1 and y is B1, Then f1 = p1x + q1y + r1 Formula 7
[0044] If x is A2 and y is B2, Then f2 = p2x + q2y + r2 Formula 8
[0045] The adaptive neuro-fuzzy inference system is represented by a five-layer feedforward neural network, which contains two inputs (x, y) and an output f, and the architecture automatically generates If-Then fuzzy rules to achieve arbitrary accuracy in approximating nonlinear functions.
[0046] In the five-layer feedforward neural network, the first layer is a fuzzification layer, the nodes of which fuzzify the precise input into several fuzzy subsets, and use membership functions to describe the degree of belonging to a certain subset, which is expressed in a formula as follows
[0047]
[0048] where x j (j = 1, 2) is the precise input of node j, A i (or B i ) is its corresponding fuzzy subset, and μA i (or μB i ) is the membership function, the shape of which is determined by the antecedent parameters.
[0049] The second layer is a rule inference layer, which is responsible for calculating the excitation strength of fuzzy rules, which is expressed in a formula as follows
[0050]
[0051] The third layer is a normalization layer, which is responsible for normalizing the excitation strength, which is expressed in a formula as follows
[0052]
[0053] The fourth layer is a fuzzy rule output layer, which adaptively generates If-Then fuzzy rules, which is expressed in a formula as follows
[0054]
[0055] where {p i , q i , r i} is the consequent parameter.
[0056] The fifth layer is an output layer, responsible for converting the fuzzy output into the precise output, which can be expressed as
[0057]
[0058] The ANFIS model learns by using the back propagation algorithm or the hybrid algorithm of back propagation and linear least squares; when the hybrid algorithm is selected, if the antecedent parameters are fixed first, the system output of the ANFIS model can be expressed as a linear combination of the consequent parameters, that is:
[0059]
[0060] wherein the vector theta constitutes the set of consequent parameters {p1, q1, r1, p2, q2, r2}, which is estimated and adjusted by using the least squares method; next, the antecedent parameters in the fuzzy rules and the update of the connection weights are completed by the BP algorithm when the consequent parameters are fixed; compared with the single back propagation algorithm, the training speed and parameter learning efficiency of the hybrid algorithm are improved.
[0061] In step S6, the FCM-ANFIS architecture comprises a data division unit, an FCM clustering algorithm unit, a fuzzy system generator, a fuzzy inference system and an adaptive fuzzy neural network; in step S6, after the data set is divided into a training set, a validation set and a test set, the data set is allocated to the FCM clustering algorithm to complete clustering, and then input to the ANFIS model for training and learning, and finally the optimal fuzzy inference system is obtained; the modeling of the FCM-ANFIS prediction model is completed on the MATLAB software.
[0062] In step S7, the fuzzy inference system is the FCM-ANFIS hybrid model.
[0063] The prediction method further comprises step S8, wherein the pH value, temperature, inflow and turbidity of raw water are taken as inputs of the FCM-ANFIS hybrid model, and the coagulant dosage is taken as the output of the prediction result of the FCM-ANFIS hybrid model.
[0064] The prediction method further comprises step S9, wherein the difference between the coagulant dosage predicted by the FCM-ANFIS model and the actual coagulant dosage of the drinking water treatment plant is obtained to obtain the prediction error value of the FCM-ANFIS model; the prediction error values are plotted into a scatter plot to evaluate the prediction effect of the FCM-ANFIS prediction model.
[0065] The prediction method further comprises a step S10 of comparing the prediction accuracy of the selected prediction model, and the specific method is to introduce the root mean square error (RMSE), the standard deviation (SD) and the mean absolute error (MAE) as the prediction result evaluation standard of the prediction model, and the calculation formula is:
[0066]
[0067]
[0068]
[0069] In the above formula, n is the number of samples, μ is the arithmetic mean of the observation data, y k and are the predicted value and the average of the predicted value respectively.
[0070] The prediction method predicts the water turbidity of the drinking water treatment plant according to the weather forecast data, and further predicts the coagulant dosage of the drinking water treatment plant in the future according to the FCM-ANFIS model, and the specific method is as follows:
[0071] Step A1, first, collect the weather forecast data of the meteorological observation station of the site of the drinking water treatment plant in a whole year, and select the meteorological conditions including dew point temperature, atmospheric pressure, visibility, average wind speed and rainfall;
[0072] Step A2, the FCM clustering algorithm is used to cluster the meteorological weather forecast data, and the clustered meteorological data is divided into a training set, a test set and a validation set as the fuzzy input of the ANFIS model;
[0073] Step A3, the ANFIS model is trained, the ANFIS model is trained, the water turbidity of the drinking water treatment plant in a whole year is predicted by using the model, and the output is input to the workspace of MATLAB, and is combined with the original selected sample data "coagulant dosage" as a new sample data set;
[0074] Step A4, the new sample data set obtained in step A3 is input into the ANFIS prediction model, the fuzzy rules are adaptively adjusted according to the fuzzy input, a model for predicting the coagulant dosage of the water purification plant based on the weather forecast data, i.e. a secondary model, is obtained, and the coagulant dosage of the water purification plant is further predicted based on the secondary model.
[0075] The advantages of the present application are as follows:
[0076] 1. The FCM-ANFIS hybrid prediction model is combined with the FCM fuzzy clustering algorithm and the ANFIS adaptive fuzzy inference system, so that the advantages of the FCM clustering algorithm and the ANFIS adaptive fuzzy inference system are integrated; compared with the BP neural network algorithm and the Elman neural network algorithm, the prediction efficiency of the FCM-ANFIS hybrid prediction model is faster, and the prediction precision is higher. Meanwhile, the FCM-ANFIS model can have wider applicability, and can predict the turbidity of the influent of the drinking water treatment plant according to the meteorological data of the weather forecast such as the dew point temperature, the atmospheric pressure, the visibility, the average wind speed and the rainfall, so as to further predict the coagulant dosage of the drinking water treatment plant in the future according to the FCM-ANFIS model.
[0077] 2. The model for predicting the coagulant dosage of the water purification plant based on the weather forecast data is a secondary model, that is, the coagulant dosage of the water purification plant is further predicted on the basis of the meteorological data prediction model. The FCM-ANFIS hybrid prediction model has the advantages that only the preprocessed meteorological data set with time series needs to be input into the FCM-ANFIS hybrid prediction model, and the fuzzy rules can be adaptively adjusted according to the fuzzy input. Meanwhile, it is the first attempt for the FCM-ANFIS hybrid prediction model to predict the coagulant dosage of the drinking water treatment plant in the future according to the meteorological data of the weather forecast.
[0078] 3. This invention addresses the problems of traditional BP neural network models easily getting trapped in local minima and Elman neural network models easily causing data redundancy. It proposes an optimal drug dosage prediction model based on an adaptive neural fuzzy inference system using fuzzy C-means clustering. Fuzzy C-means clustering (FCM) is a partition-based clustering algorithm that maximizes the similarity between objects within the same cluster and minimizes the similarity between different clusters. Adaptive Fuzzy Neural Inference System (ANFIS) is a type of fuzzy neural inference system. Compared to ANN, ANFIS does not suffer from the limitation of getting trapped in local optima. Generally, ANFIS performs better than ANN in training. Due to its decision-making capabilities in fuzzy systems and its self-learning ability in neural networks, ANFIS is widely used in control system identification, pattern recognition, and some nonlinear complex systems. This invention effectively combines the FCM fuzzy clustering algorithm with the ANFIS adaptive fuzzy inference system, representing a first attempt in the field of drinking water treatment. Based on the raw water quality properties, the model first uses the FCM clustering algorithm to divide the raw water quality data into four categories and generate an initial fuzzy inference system. Then, a hybrid algorithm of BP algorithm and least squares method is used to train the antecedent and consequent parameters in the adaptive fuzzy neural network. Simulation results show that compared with traditional BP neural network algorithms and Elman neural network algorithms, the proposed algorithm has higher prediction efficiency and higher prediction accuracy.
[0079] 4. The FCM-ANFIS hybrid prediction model proposed in this invention overcomes the difficulties of slow convergence, poor prediction accuracy, and susceptibility to local minima associated with both BP neural network and Elman neural network algorithms. This hybrid model uses the FCM clustering algorithm to obtain the number of fuzzy rules and employs a hybrid algorithm combining BP and least squares estimation to train the parameters of the ANFIS model. Simulation results show that, compared with BP and Elman neural network algorithms, the proposed FCM-ANFIS hybrid model algorithm has faster convergence speed and higher prediction accuracy, effectively enabling online prediction of the optimal coagulant dosage in drinking water treatment plants. Attached Figure Description
[0080] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments:
[0081] Appendix Figure 1 This is a schematic diagram of the framework of the FCM-ANFIS hybrid prediction model of the present invention;
[0082] Appendix Figure 2 This is a schematic diagram of the water purification process in a water treatment plant.
[0083] Appendix Figure 3 This is a schematic diagram of the ANFIS network structure;
[0084] Appendix Figure 4 This is a diagram showing the comparison between the predicted and actual values of the FCM-ANFIS hybrid prediction model.
[0085] Appendix Figure 5 This is a scatter plot of the prediction error of the FCM-ANFIS model;
[0086] Appendix Figure 6 This is a diagram comparing the prediction effects of different algorithms on coagulant dosage.
[0087] Appendix Figure 7 This is a schematic diagram comparing the turbidity of the effluent from the FCM-ANFIS hybrid model;
[0088] Appendix Figure 8 This is a schematic diagram illustrating the secondary prediction of coagulant dosage; Detailed Implementation
[0089] As shown in the figure, the optimal dosage prediction method based on the FCM-ANFIS model is used to predict the coagulant dosage in water treatment plants. The method includes the following steps.
[0090] Step S1: Select a drinking water treatment plant that controls the addition of coagulant based on the turbidity of the effluent from the coagulation tank, and use the raw water quality sample data from the entire year of historical operation as the dataset.
[0091] Step S2: Preprocess the dataset and select data from years in which temperature has an impact on raw water turbidity above a threshold.
[0092] Step S3: Analyze the similarity between variables in the raw water quality data to describe the correlation between the water quality data, and perform cluster analysis on the preprocessed sample data using the fuzzy C-means clustering algorithm. Use the FCM clustering algorithm for iterative solution to finally obtain the required cluster centers and membership matrix.
[0093] Step S4: Introduce an internal fuzzy clustering effectiveness index to evaluate the clustering results and establish an ANFIS prediction model;
[0094] Step S5: Use a hybrid algorithm of BP algorithm and least squares method to learn and train the parameters of ANFIS model. If the error meets the requirements or the maximum number of iterations is reached, the training is terminated, and an FCM-ANFIS fuzzy inference system for drug dosage prediction is established.
[0095] Step S6: After the preprocessed dataset is clustered into N classes by the FCM clustering algorithm, it is input into the ANFIS fuzzy inference system for training and learning to obtain the optimal fuzzy inference system based on the ANFIS prediction model.
[0096] Step S7, taking the raw water quality of the drinking water treatment plant as sample data, prediction is made through the fuzzy inference system.
[0097] In step S2, the noise and abnormal points in the sample data are removed and corrected by interpolation method.
[0098] In step S3, Pearson correlation coefficient and difference matrix based on Euclidean distance are used to perform Pearson correlation analysis and difference matrix analysis based on Euclidean distance on the raw water quality data of the drinking water treatment plant by using the "statistical product and service solutions" software SPSS, and Z-score is used to convert the Euclidean distance to see the similarity between the data, the smaller the value of Z-score, the greater the similarity between variables, and vice versa.
[0099] In step S3, the preprocessed sample data is clustered and analyzed by using fuzzy C-means clustering algorithm FCM; the fuzzy C-means clustering algorithm uses membership function to determine the membership clustering center of the sampling point; the algorithm is based on loop calculation, and the clustering classification is completed by correcting the clustering center and classification matrix belonging to the membership function, specifically: FCM decomposes n data vectors X i (i = 1, 2,..., n) into C fuzzy groups, and calculates the clustering center of each fuzzy group under the condition of meeting the minimum cost function; FCM uses membership value between 0-1 to determine the membership degree of the sampling data; through the initialization processing of the data, the membership sum of a sampling data combination is 1, that is
[0100]
[0101] The cost function of FCM is represented as:
[0102]
[0103] In formula two, H i is the i clustering center, U is the membership matrix; d ij = ||H i +-X i || is the Euclidean distance from the i-th center to the j-th sampling data point; m is a weighted number greater than 1; the Lagrange maximum value method is used to solve the necessary condition for the cost function J to reach the minimum value, and then the u ij and X j are derived, and then the FCM clustering algorithm is used for iterative loop solving, and finally the required clustering center and membership matrix are obtained.
[0104] The evaluation indexes used in step S4 include Bezdek partition coefficient, Xie-Beni coefficient, reconstruction error rate V RE and P BMIndex
[0105] The Bezdek partition coefficient is V PC , which is used to re-describe the membership of the partitioned data, i.e. the sum of the square of the membership of each classification of all elements, and is defined as follows:
[0106]
[0107] In the formula, u is an element of the data, and n is the number of elements; V PC is larger, the better the clustering effect is;
[0108] The Xie-Beni coefficient is V XB , which is defined as:
[0109]
[0110] In the formula, x is an element before partitioning, and v is an element after partitioning.
[0111] V RE is the reconstruction error rate of the data, which is defined as follows:
[0112]
[0113] In the formula, I(t) and I'(t) are the values of the ith data before and after reconstruction, respectively; V RE , the smaller the value of the clustering algorithm is, the better the partitioning effect is;
[0114] P BM is an index of clustering effectiveness, which is defined as follows:
[0115]
[0116] In the formula, K is the given number of classifications, E1 is the given data set, which is a constant; E k is the sum of the fuzzy distance between the data to be classified and the cluster centers in the individual, and the value of P BM will increase as the value of E k decreases. D k is the maximum distance between all pairs of cluster centers in the individual; the larger the value of P BM is, the better the partitioning effect is;
[0117] According to the calculation formula of the above-mentioned related indexes, the related indexes of the FCM clustering algorithm are calculated, and the calculation results are evaluated. If the value of V RE is very small, and the value of P BM is very large, it indicates that the clustering effect of the FCM fuzzy clustering algorithm is better.
[0118] In step S5, the ANFIS prediction model is an adaptive neuro-fuzzy inference system, specifically a Sugeno-type fuzzy neural network inference system, which adopts If-Then fuzzy rules, and the output thereof is expressed as a linear combination of fuzzy subsets of inputs, and is expressed in a formula as follows:
[0119] If x is A1 and y is B1, Then f1 = p1x + q1y + r1 Formula 7
[0120] If x is A2 and y is B2, Then f2 = p2x + q2y + r2 Formula 8
[0121] The adaptive neuro-fuzzy inference system is represented by a five-layer feedforward neural network, which contains two inputs (x, y) and one output f, and the architecture thereof automatically generates If-Then fuzzy rules, and reaches arbitrary accuracy in approximating a nonlinear function;
[0122] In the five-layer feedforward neural network, the first layer is a fuzzification layer, the nodes of which fuzzify the precise input into several fuzzy subsets, and use a membership function to describe the degree of belonging to a certain subset, and is expressed in a formula as follows
[0123]
[0124] wherein, x j (j = 1, 2) is the precise input of node j, A i (or B i ) is the corresponding fuzzy subset thereof, and μA i (or μB i ) is the membership function, the shape of which is determined by the antecedent parameters;
[0125] The second layer is a rule inference layer, which is responsible for calculating the excitation strength of the fuzzy rule, and is expressed in a formula as follows
[0126]
[0127] The third layer is a normalization layer, which is responsible for normalizing the excitation strength, and is expressed in a formula as follows
[0128]
[0129] The fourth layer is a fuzzy rule output layer, which adaptively generates If-Then fuzzy rules, and is expressed in a formula as follows
[0130]
[0131] wherein, {p i , q i , r i} is the consequent parameter.
[0132] The fifth layer is an output layer, responsible for converting the fuzzy output into a precise output, which can be expressed in a formula as
[0133]
[0134] The ANFIS model learns by using a back-propagation algorithm or a hybrid algorithm combining back-propagation and linear least squares; when the hybrid algorithm is selected, if the antecedent parameters are fixed first, the system output of the ANFIS model can be expressed as a linear combination of the consequent parameters, that is:
[0135]
[0136] where the vector θ constitutes the set of consequent parameters {p1, q1, r1, p2, q2, r2}, which are estimated and adjusted using the least squares method; next, the antecedent parameters in the fuzzy rules and the update of the connection weights are completed by the BP algorithm when the consequent parameters are fixed; compared with the single back-propagation algorithm, the training speed and parameter learning efficiency of the hybrid algorithm are improved.
[0137] In step S6, the FCM-ANFIS architecture includes a data division unit, an FCM clustering algorithm unit, a fuzzy system generator, a fuzzy inference system, and an adaptive fuzzy neural network; in step S6, after the data set is divided into a training set, a validation set, and a test set, they are respectively assigned to the FCM clustering algorithm to complete clustering, and then input to the ANFIS model for training and learning, and finally the optimal fuzzy inference system is obtained; the modeling of the FCM-ANFIS prediction model is completed on the MATLAB software.
[0138] In step S7, the fuzzy inference system is the FCM-ANFIS hybrid model.
[0139] The prediction method further includes step S8, taking the PH value, temperature, inflow rate, and turbidity of raw water as the input of the FCM-ANFIS hybrid model, and taking the coagulant dosage as the output of the prediction result of the FCM-ANFIS hybrid model.
[0140] The prediction method further includes step S9, subtracting the coagulant dosage predicted by the FCM-ANFIS model from the actual coagulant dosage of the drinking water treatment plant to obtain the prediction error value of the FCM-ANFIS model; drawing a scatter plot of these prediction error values to evaluate the prediction effect of the FCM-ANFIS prediction model.
[0141] The prediction method further comprises a step S10 of comparing the prediction accuracy of the selected prediction model, specifically introducing the root mean square error RMSE, the standard deviation SD and the mean absolute error MAE as the prediction result evaluation standard of the prediction model, and the calculation formula is:
[0142]
[0143]
[0144]
[0145] In the above formula, n is the number of samples, μ is the arithmetic mean of the observation data, y k and are the predicted value and the average of the predicted value, respectively.
[0146] The prediction method predicts the inflow turbidity of the drinking water treatment plant according to the data of the weather forecast, and further predicts the coagulant dosage of the drinking water treatment plant in the future according to the FCM-ANFIS model, specifically as follows:
[0147] Step A1, first collect the weather forecast data of the meteorological observation station of the drinking water treatment plant all year round, and select the meteorological conditions including dew point temperature, atmospheric pressure, visibility, average wind speed and rainfall;
[0148] Step A2, the weather forecast data is clustered by using the FCM clustering algorithm, and the clustered meteorological data is divided into a training set, a test set and a validation set as the fuzzy input of the ANFIS model;
[0149] Step A3, the ANFIS model is trained, and after the ANFIS model is trained, the model is used to predict the inflow turbidity of the drinking water treatment plant all year round, and the output is input to the workspace of MATLAB, and combined with the original selected sample data "coagulant dosage" as a new sample data set;
[0150] Step A4, the new sample data set obtained in step A3 is input into the ANFIS prediction model, so that the fuzzy rules are adaptively adjusted according to the fuzzy input, and a model for predicting the coagulant dosage of the water purification plant based on the weather forecast data is obtained, that is, a secondary model, and the coagulant dosage of the water purification plant is further predicted based on the secondary model.
[0151] Example 1:
[0152] In step S1 of this example: the drinking water treatment plant removes impurities and some harmful substances in the water by a series of physical and chemical methods to make the water quality meet the requirements of domestic or industrial water. The water purification process flow chart of the drinking water treatment plant is shown in Figure 2 The coagulation dosing control system is mainly based on the turbidity of the effluent from the coagulation tank to control the addition of coagulant.
[0153] In step S2 of this example: the data set selects the annual operation data of a drinking water treatment plant in Fujian Province in 2021. Before building the FCM-ANFIS prediction model, the data of the annual operation data set of the drinking water treatment plant needs to be preprocessed. The raw water quality sample data of the drinking water treatment plant is preprocessed, and the noise and abnormal points in the sample data are removed and corrected by interpolation method.
[0154] After preprocessing the sample data, through statistical analysis of these raw water quality data, it can be seen that the turbidity of the raw water of the drinking water treatment plant fluctuates greatly as a whole, which is reflected in that the temperature has a certain influence on the turbidity of the raw water, the turbidity value is smaller in winter and larger in summer. The overall statistical characteristics of the annual data set of the drinking water treatment plant in 2021 are as follows
[0155] Table 4.1 Statistical characteristics of the annual operation data of the drinking water treatment plant in 2021
[0156]
[0157] In step S3 of this example: in order to describe the correlation between the raw water quality data, Pearson correlation coefficient and difference matrix based on Euclidean distance can be used to analyze the similarity between variables. Pearson correlation coefficient describes the linear correlation between two variables, and the value is, under the premise of significance, the larger the absolute value, the stronger the correlation between the two variables. Euclidean distance refers to the distance between two points in Euclidean space, which can be used to describe the strength of the similarity between variables. Using Z-score to convert Euclidean distance can more intuitively see the similarity between data. Generally speaking, when doing difference matrix analysis, the smaller the value of Z-score, the greater the similarity between variables, and vice versa. Using "Statistical Product and Service Solutions" software (Statistical Product and Service Solutions, SPSS) to analyze the Pearson correlation of the raw water quality data of the drinking water treatment plant and the difference matrix based on Euclidean distance, the analysis results are shown in the following table.
[0158] Table 4.2 Pearson correlation analysis
[0159]
[0160] Table 4.3 Difference matrix analysis of raw water quality data
[0161]
[0162] The Pearson correlation coefficient calculated by the SPSS software and the results of the difference matrix analysis can be obtained that the PH value, temperature, inflow and turbidity of raw water have greater influence on the coagulant dosage.
[0163] Example 2
[0164] In this example, the modeling steps of the whole FCM-ANFIS prediction model are as follows:
[0165] 1) The correlation analysis of the coagulant dosage of the raw water quality data of the drinking water treatment plant is performed, the number of input variables of the prediction model is determined to be 4, the number of output variables is determined to be 1, and the initial ANFIS prediction model is generated;
[0166] 2) The raw water quality data of the drinking water treatment plant is divided according to 6:3:1, into a training set, a test set and a validation set. The training set is used for the system simulation training of the ANFIS prediction model and the fitting of the data, the validation set is used for verifying the model performance of the ANFIS prediction model, and finally the test set is used for testing the training effect of the ANFIS prediction model.
[0167] 3) The FCM clustering algorithm is used for the analysis and clustering of the raw water quality data, and then the cluster centers and the number of samples are obtained, and the number of fuzzy rules of the prediction model is determined. The initial cluster center number of the fuzzy C-means clustering algorithm of the application is 28, the maximum iteration number is 200, the partition matrix index is 3, and the target error criterion is 10 -6 .
[0168] 4) The parameters of the ANFIS model are learned and trained by using the hybrid algorithm of the BP algorithm and the least square method, and if the error meets the requirement or reaches the maximum iteration number, the training is terminated.
[0169] 5) After obtaining the optimal ANFIS prediction model through training, the raw water quality sample data of the drinking water treatment plant is used for simulation prediction.
[0170] The PH value, temperature, inflow and turbidity of raw water are used as the input of the FCM-ANFIS hybrid model, and the coagulant dosage is used as the output of the FCM-ANFIS hybrid model. In order to more intuitively observe the prediction effect of the FCM-ANFIS prediction model, Figure 8The predicted value and the actual value of the coagulant dosage of the FCM-ANFIS prediction model are drawn. One curve represents the predicted value of the coagulant dosage of the FCM-ANFIS prediction model, and the other curve represents the actual dosage of the coagulant of the drinking water treatment plant.
[0171] From Figure 8 It can be seen that the FCM-ANFIS prediction model has a small error and high prediction accuracy.
[0172] In order to more intuitively see the prediction effect of the FCM-ANFIS prediction model, the prediction error value of the FCM-ANFIS model is obtained by subtracting the coagulant dosage predicted by the FCM-ANFIS model from the actual coagulant dosage of the drinking water treatment plant. The prediction errors are plotted as a scatter plot as shown in Figure 5
[0173] It can be seen from the FCM-ANFIS prediction error scatter plot that the prediction error of the FCM-ANFIS model is generally within ±2 mg / L, the prediction accuracy is high, and the trained FCM-ANFIS model is reliable, which can accurately predict the optimal dosage of coagulant and clarifying agent of the drinking water treatment plant and meet the daily needs of the drinking water treatment plant.
[0174] In order to further verify the advancement of the algorithm of the present application compared with other algorithms, the Elman neural network algorithm and the BP neural network algorithm are selected for comparison. Under the same sample data conditions, the predicted values of the Elman neural network algorithm, the BP neural network algorithm and the FCM-ANFIS model algorithm are compared with the actual coagulant dosage of the drinking water treatment plant, and the image is drawn as shown in Figure 6
[0175] Example 3
[0176] In this example, under the same raw water quality sample data set of the drinking water treatment plant, the RMSE, MAE and SD of the BP neural network algorithm, the Elman neural network algorithm and the FCM-ANFIS prediction model are calculated respectively, and the related calculation results are shown in the following table.
[0177] Table 4.4 Model Performance Index Table
[0178]
[0179] From the results of Table 4.4, it can be seen that the RMSE and MAE values of the FCM-ANFIS prediction model are smaller than those of the other two algorithms, indicating that the prediction error of the FCM-ANFIS prediction model is smaller than that of the other two algorithms. The system simulation results to some extent verify the applicability of the coagulant dosage of the drinking water treatment plant, indicating that the FCM-ANFIS model can provide an effective solution for the optimal coagulant dosage of the drinking water treatment plant, can greatly reduce the cost and labor cost of the drinking water treatment plant, and opens up a new way for the sustainable development of the drinking water treatment plant.
Claims
1. A method for predicting optimal dosage based on the FCM-ANFIS model, used for predicting coagulant dosage in water treatment plants, characterized by: The method includes the following steps; Step S1: Select a drinking water treatment plant that controls the addition of coagulant based on the turbidity of the effluent from the coagulation tank, and use the raw water quality sample data from the entire year of historical operation as the dataset. Step S2: Preprocess the dataset and select data from years in which temperature has an impact on raw water turbidity above a threshold. Step S3: Analyze the similarity between variables in the raw water quality data to describe the correlation between the water quality data, and use the fuzzy C-means clustering algorithm to perform cluster analysis on the preprocessed sample data and perform iterative loop solution to finally obtain the required cluster centers and membership matrix. Step S4: Introduce an internal fuzzy clustering effectiveness index to evaluate the clustering results and establish an ANFIS prediction model; Step S5: Use a hybrid algorithm of BP algorithm and least squares method to learn and train the parameters of ANFIS model. If the error meets the requirements or the maximum number of iterations is reached, the training is terminated, and an FCM-ANFIS fuzzy inference system for drug dosage prediction is established. Step S6: After the preprocessed dataset is clustered into N classes by the FCM clustering algorithm, it is input into the ANFIS fuzzy inference system for training and learning to obtain the optimal fuzzy inference system based on the ANFIS prediction model. Step S7: Using the raw water quality of the drinking water treatment plant as sample data, make predictions through a fuzzy inference system; The prediction method uses weather forecast data to predict the turbidity of the influent to the drinking water treatment plant, and then uses the FCM-ANFIS model to further predict the amount of coagulant to be added to the drinking water treatment plant for the next few days. The specific method is as follows: Step A1: First, collect the weather forecast data from the meteorological station at the location of the drinking water treatment plant throughout the year. The selected meteorological conditions include dew point temperature, atmospheric pressure, visibility, average wind speed, and rainfall. Step A2: Use the FCM clustering algorithm to cluster the meteorological weather forecast data, and divide the clustered meteorological data into training set, test set and validation set as fuzzy input to the ANFIS model; Step A3: Train the ANFIS model. After training the ANFIS model, use the model to predict the turbidity of the influent to the drinking water treatment plant throughout the year, and output it to the MATLAB workspace. Combine it with the coagulant dosage of the original sample data to form a new sample dataset. Step A4: Input the new sample dataset obtained in step A3 into the ANFIS prediction model, so that the fuzzy rules are adaptively adjusted according to the fuzzy input, and a model for predicting the amount of coagulant added to the water purification plant based on weather forecast data is obtained, namely the quadratic model. Based on the quadratic model, the amount of coagulant added to the water purification plant is further predicted.
2. The optimal drug dosage prediction method based on the FCM-ANFIS model according to claim 1, characterized in that: In step S2, noise and outliers in the sample data are removed and corrected by interpolation.
3. The optimal drug dosage prediction method based on the FCM-ANFIS model according to claim 1, characterized in that: In step S3, Pearson correlation coefficient and Euclidean distance-based difference matrix are used. SPSS software is used to perform Pearson correlation analysis and Euclidean distance-based difference matrix analysis on the raw water quality data of drinking water treatment plants. Z-score is used to transform the Euclidean distance data to see the strength of similarity between data. The smaller the Z-score value, the greater the similarity between variables, and vice versa.
4. The optimal drug dosage prediction method based on the FCM-ANFIS model according to claim 1, characterized in that: In step S3, the preprocessed sample data is clustered using the fuzzy C-means clustering algorithm (FCM). The fuzzy C-means clustering algorithm uses a membership function to determine the cluster centers of the sampling points. The algorithm is based on iterative calculation, completing the clustering classification by correcting the cluster centers belonging to the membership function and the classification matrix. Specifically, FCM divides the n data vectors X... i Let i = 1, 2, ..., n be decomposed into C fuzzy groups. Under the condition of minimizing the cost function, the cluster center of each fuzzy group is calculated. FCM uses membership values between [0-1] to determine the membership degree of the sampled data. Through data initialization, the sum of the membership degrees of a sampled data combination is made to be 1, i.e. The cost function of FCM is expressed as: In Formula 2, H i Let i be the cluster center, and U be the membership matrix; d ij =||H i +-X i || represents the Euclidean distance from the center of class i to the j-th sampled data point; m is a weighting factor greater than 1; The necessary condition for the cost function J to reach its minimum value is obtained by using the Lagrange extremum method, and u is then applied. ij and X j The derivative is calculated, and then the FCM clustering algorithm is used for iterative solving to finally obtain the required cluster centers and membership matrix.
5. The optimal drug dosage prediction method based on the FCM-ANFIS model according to claim 1, characterized in that: The evaluation metrics used in step S4 include the Bezdek partition coefficient, the Xie-Beni coefficient, and the reconstruction error rate V. RE and P BM index; Bezdek's partition coefficient is V PC This is used to re-characterize the membership degree of the data after partitioning, that is, the sum of the squares of the membership degrees of all elements to each category, defined as follows: In the formula, u represents an element of the data, and n is the number of elements; V PC The larger the value, the better the clustering effect; The Xie-Beni coefficient is V XB Its definition is: In the formula, x represents the element before partitioning, and v represents the element after partitioning; V RE It is the data reconstruction error rate, which is defined as follows: In the formula, I(t) and I'(t) are the values of the i-th data before and after reconstruction, respectively; V RE The smaller the value, the better the partitioning effect of the clustering algorithm; P BM The indicator is a clustering effectiveness metric, defined as follows: In the formula, K is the given number of classes, and E1 is the given dataset, which is a constant; E k It is the sum of the fuzzy distances between the data to be classified and the cluster centers of the individuals, P BM The value will change with E k D increases as it decreases; k It is the maximum distance between all cluster center pairs in an individual; P BM The larger the value, the better the partitioning effect; Based on the calculation formulas of the aforementioned relevant indicators, the relevant indicators of the FCM clustering algorithm are calculated, and the results are evaluated. If V RE The value of is very small, while P BM The large value indicates that the FCM fuzzy clustering algorithm has a better clustering effect.
6. The optimal drug dosage prediction method based on the FCM-ANFIS model according to claim 1, characterized in that: In step S5, the ANFIS prediction model is an adaptive fuzzy neural inference system, specifically a Sugeno-type fuzzy neural network inference system that uses the If-Then fuzzy rule. Its output is represented as a linear combination of fuzzy subsets of the input quantities, expressed by the formula: Ifx is A1 and y is B1,Then f1=p1x+q1y+r1 Formula 7; If x is A² and y is B², then f² = p²x + q²y + r² (Formula 8). The adaptive fuzzy neural reasoning system is represented by a five-layer feedforward neural network. The network contains two inputs (x, y) and one output f. Its architecture automatically generates If-Then fuzzy rules and achieves arbitrary precision in approximating nonlinear functions. In the five-layer feedforward neural network, the first layer is a fuzzification layer. The nodes in this layer fuzzify the precise input into several fuzzy subsets, and use a membership function to describe the degree to which the node belongs to a particular subset, expressed as a formula: Where xj, j = 1, 2 are the exact inputs of node j, A i Or B i For its corresponding fuzzy subset, μA i or μB i It is a membership function, the shape of which is determined by the antecedent parameter; The second layer is the rule reasoning layer, responsible for calculating the incentive strength of fuzzy rules, expressed by the formula: The third layer is the normalization layer, responsible for normalizing the incentive intensity, expressed by the formula as follows: The fourth layer is the fuzzy rule output layer, which adaptively generates If-Then fuzzy rules, expressed as a formula: Where, {pi,qi,r i } represents the consequent parameter; The fifth layer is the output layer, responsible for converting fuzzy output into precise output, expressed by the formula as follows: The ANFIS model is learned using either backpropagation or a hybrid algorithm combining backpropagation and linear least squares. When choosing a hybrid algorithm, if the antecedent parameters are fixed first, the system output of the ANFIS model can be expressed as a linear combination of the consequent parameters, i.e.: In this algorithm, vector θ constitutes the consequent parameter set {p1, q1, r1, p2, q2, r2}, which is estimated and adjusted using the least squares method. Next, the consequent parameters are fixed, and the antecedent parameters and connection weights in the fuzzy rules are updated using the BP algorithm. Compared with the single backpropagation algorithm, the hybrid algorithm improves both training speed and parameter learning efficiency.
7. The optimal drug dosage prediction method based on the FCM-ANFIS model according to claim 6, characterized in that: In step S6, the FCM-ANFIS architecture includes a data partitioning unit, an FCM clustering algorithm unit, a fuzzy system generator, a fuzzy inference system, and an adaptive fuzzy neural network. In step S6, after the dataset is partitioned into training, validation, and test sets, it is assigned to the FCM clustering algorithm to complete clustering. Then, it is input into the ANFIS model for training and learning, and finally the optimal fuzzy inference system is obtained. The modeling of the FCM-ANFIS prediction model is completed on MATLAB software.
8. The optimal drug dosage prediction method based on the FCM-ANFIS model according to claim 7, characterized in that: In step S7, the fuzzy inference system is the FCM-ANFIS hybrid model; the prediction method also includes step S8, in which the pH value, temperature, influent flow rate and turbidity of the raw water are used as inputs to the FCM-ANFIS hybrid model, and the dosage of coagulant is used as the output of the prediction result of the FCM-ANFIS hybrid model. The prediction method further includes step S9, which involves subtracting the amount of coagulant added predicted by the FCM-ANFIS model from the amount of coagulant added in the actual drinking water treatment plant to obtain the prediction error value of the FCM-ANFIS model; plotting these prediction error values into a scatter plot to evaluate the prediction effect of the FCM-ANFIS prediction model.
9. The optimal drug dosage prediction method based on the FCM-ANFIS model according to claim 8, characterized in that: The prediction method further includes step S10, which compares the prediction accuracy of the selected prediction model. Specifically, the root mean square error (RMSE), standard deviation (SD), and absolute error (MAE) are introduced as evaluation criteria for the prediction results of the prediction model, and their calculation formulas are as follows: In the above formula, n is the number of samples, μ is the arithmetic mean of the observed data, and y k and These are the predicted value and the average of the predicted values, respectively.