CN117291069A - LSTM sewage water quality prediction method based on improved DE and attention mechanism - Google Patents

LSTM sewage water quality prediction method based on improved DE and attention mechanism Download PDF

Info

Publication number
CN117291069A
CN117291069A CN202311148279.3A CN202311148279A CN117291069A CN 117291069 A CN117291069 A CN 117291069A CN 202311148279 A CN202311148279 A CN 202311148279A CN 117291069 A CN117291069 A CN 117291069A
Authority
CN
China
Prior art keywords
lstm
population
quality prediction
mutation
water quality
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311148279.3A
Other languages
Chinese (zh)
Inventor
任健
周红标
秦源汇
杨丹
刘帅祥
徐浩渊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huaiyin Institute of Technology
Original Assignee
Huaiyin Institute of Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huaiyin Institute of Technology filed Critical Huaiyin Institute of Technology
Priority to CN202311148279.3A priority Critical patent/CN117291069A/en
Publication of CN117291069A publication Critical patent/CN117291069A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F30/00Computer-aided design [CAD]
    • G06F30/20Design optimisation, verification or simulation
    • G06F30/23Design optimisation, verification or simulation using finite element methods [FEM] or finite difference methods [FDM]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/10Pre-processing; Data cleansing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/243Classification techniques relating to the number of classes
    • G06F18/2433Single-class perspective, e.g. one-against-all classification; Novelty detection; Outlier detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F30/00Computer-aided design [CAD]
    • G06F30/20Design optimisation, verification or simulation
    • G06F30/27Design optimisation, verification or simulation using machine learning, e.g. artificial intelligence, neural networks, support vector machines [SVM] or training a model
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/044Recurrent networks, e.g. Hopfield networks
    • G06N3/0442Recurrent networks, e.g. Hopfield networks characterised by memory or gating, e.g. long short-term memory [LSTM] or gated recurrent units [GRU]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02ATECHNOLOGIES FOR ADAPTATION TO CLIMATE CHANGE
    • Y02A20/00Water conservation; Efficient water supply; Efficient water use
    • Y02A20/152Water filtration

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Evolutionary Computation (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Software Systems (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Geometry (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Computer Hardware Design (AREA)
  • Evolutionary Biology (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Medical Informatics (AREA)
  • Activated Sludge Processes (AREA)

Abstract

The invention discloses an LSTM sewage water quality prediction method based on an improved DE and attention mechanism, which comprises the following steps: 1) Preprocessing an important characteristic data set of a sewage treatment plant; 2) Constructing and initializing an ATT-LSTM water quality prediction model; 3) Optimizing the super-parameters of the ATT-LSTM water quality prediction model by utilizing ADE to obtain an optimal super-parameter ADE-ATT-LSTM water quality prediction model; 4) Constructing a training set and a testing set based on the preprocessed data to train the optimal super-parameter ADE-ATT-LSTM water quality prediction model; 5) And inputting the acquired data into a trained ADE-ATT-LSTM water quality prediction model to obtain a DO prediction result. The water quality prediction model can ensure the optimal parameters of the prediction model, thereby effectively improving the water quality prediction precision; in addition, the invention combines ADE with ATT and LSTM models, thereby greatly improving the calculation efficiency of the water quality prediction model.

Description

LSTM sewage water quality prediction method based on improved DE and attention mechanism
Technical Field
The invention belongs to the technical field of water quality prediction, and particularly relates to an LSTM sewage water quality prediction method based on an improved DE and attention mechanism.
Background
At present, the most effective method for preventing further deterioration and pollution of water resources is to improve the prediction capability of key characteristics in the sewage treatment process, and the characteristics of uncertainty, nonlinearity, time lag and the like in the sewage treatment process are difficult to describe by using a traditional mathematical model. Meanwhile, the change of Dissolved Oxygen (DO) in a water body is closely related to the metabolism rate of the water body, so that DO is very important in evaluating the health condition of a water ecosystem of a sewage treatment plant. However, the lack of reliable DO prediction methods severely affects the effective monitoring and control of wastewater treatment quality. Although accurate concentrations, such as the determination of potassium dichromate and potassium permanganate indices, can be obtained by conventional predictive methods, there is inevitably a significant time delay, ranging from minutes to hours. This delay is too late for advanced wastewater treatment systems that require more accurate and timely control. The prediction capability of important characteristics of the sewage treatment plant is improved, the planning of the sewage treatment plant can be assisted, and the method has important significance for controlling the water environment pollution of the area.
Traditional prediction methods are time-consuming and high in cost, and are difficult to meet the requirement of rapid prediction in practical application. In recent years, the neural network based on the strong fitting capability and adaptability is gradually introduced into the field of wastewater treatment and used for data-driven modeling. However, ignoring the time series characteristics of the wastewater data, lack of efficient handling of the sequence dependencies between input variables, limits the ability of the model to handle time series predictions. LSTM neural networks have been proposed to balance the time and non-linear relationship of wastewater data. But similar to conventional neural networks, it is difficult to select super parameters.
To solve this problem, the present invention provides a prediction method based on a long-short-term memory (LSTM) neural network model that improves the differential evolution Algorithm (ADE) and the attention mechanism (ATT). ATT-LSTM is optimized with ADE because of the difficulty in choosing the superparameter of LSTM. In addition, ATT is added into the LSTM model, so that the water quality characteristics are mined, the DO prediction accuracy is improved, and the method has important practical engineering significance.
Disclosure of Invention
The invention aims to: aiming at the problems pointed out in the background art, the invention provides the LSTM sewage water quality prediction method based on the improved DE and attention mechanism, and the ATT-LSTM model is optimized through ADE, and finally DO prediction is carried out on sewage, so that an accurate DO prediction result is obtained, the calculation efficiency of the model is improved, and the prediction accuracy of the model is improved.
The technical scheme is as follows: the invention provides an LSTM sewage water quality prediction method based on an improved DE and attention mechanism, which comprises the following steps:
step 1: preprocessing an important characteristic data set of a sewage treatment plant, wherein the characteristic data set comprises pH, conductivity, water temperature, turbidity, potassium permanganate, total phosphorus, ammonia nitrogen, total nitrogen and dissolved oxygen historical data of the previous moments;
step 2: constructing and initializing an ATT-LSTM water quality prediction model, wherein the ATT-LSTM water quality prediction model is a long-term and short-term memory LSTM neural network model based on an attention mechanism ATT;
step 3: based on the preprocessed data, optimizing the super-parameters of the ATT-LSTM water quality prediction model by utilizing an improved differential evolution algorithm ADE to obtain an optimal super-parameter ADE-ATT-LSTM water quality prediction model;
step 4: constructing a training set and a testing set based on the preprocessed data to train the optimal super-parameter ADE-ATT-LSTM water quality prediction model;
step 5: and inputting the collected data set comprising the pH, conductivity, water temperature, turbidity, potassium permanganate, total phosphorus, ammonia nitrogen, total nitrogen and dissolved oxygen historical data at the previous moments into a trained ADE-ATT-LSTM water quality prediction model to obtain a DO value prediction result.
Further, the step of preprocessing the data set in the step 1 includes:
s11: outlier processing: firstly, carrying out descriptive statistics on characteristic values to check unreasonable data and whether the data are subjected to normal distribution, and when the average value of the sample distance is greater than 3 standard deviations, recognizing the sample as an abnormal value and deleting the abnormal value in a data set;
s12: missing value processing: indexing the data containing the missing values in the data set, and filling the indexed missing values according to the data of the previous time point and the next time point;
s13: normalization: the data of different scales and ranges are mapped into a unified range to eliminate dimensional differences between different features.
Further, the attention mechanism in the step 2 assigns corresponding weights according to the importance of the input features, and the calculation formula is as follows:
wherein T is the total time step; h is a m Is the output eigenvector of LSTM; alpha m Is the result of the first weighted calculation through the full connection layer; w (W) l αh And b α The weight matrix and the bias of the full connection layer are respectively; beta m Is calculated by softmax activation function and assigned to corresponding h m Final weight of (c); and vector γ is an important feature of extraction.
Further, optimizing the super parameters of the ATT-LSTM water quality prediction model using ADE based on the preprocessed data in step 3 includes:
s31: the number of hidden layer neurons and the learning rate of the ATT-LSTM water quality prediction model are selected as optimization parameters of an ADE algorithm, the optimization range of the parameters to be optimized is determined, and the population P is initialized randomly;
s32: calculating the fitness value of each individual in the ADE algorithm:
wherein p is the number of samples, y p As the true value of the sample,is a predicted value;
s33: randomly dividing the whole population P into exploratory sub-populations P 1 Developing sub-population P 2 And a balancer population P 3 And adaptively selecting a mutation strategy;
s34: entering a mutation stage, and executing a corresponding particle mutation method according to a corresponding mutation strategy and the adaptive mutation factor F;
s35: entering a mutation stage, and executing a corresponding particle mutation method according to the self-adaptive crossover probability Cr;
s36: calculating the fitness value of the individual, determining the optimal value in the 3 sub-populations, and combining the 3 sub-populations;
s37: judging whether the condition of ending the iteration is satisfied; if the iteration number reaches the maximum value, returning to the optimal super-parameters of the model; otherwise, S33 is repeated to continue execution until the termination condition is satisfied.
Further, the neutron population adaptive selection mutation strategy in S33 is specifically as follows:
1) Sonde population P 1
Sonde population P 1 DE/rand/2 asMutation strategy; the target individual is interfered by using two random differential vectors, and the mutation strategy is as follows:
“DE/rand/2”:V i,G =X r1,G +F×(X r2,G -X r3,G )+F×(X r4,G -X r5,G )
wherein V is i,G For individuals X in the current population i,G Generating a mutation vector by using mutation strategy, r 1 、r 2 、r 3 、r 4 、r 5 Respectively represent [1, N ]]Mutually exclusive integers randomly generated in range, F E [0,1]Is a variation factor;
2) Development of sub-population P 2
Development of sub-population P 2 DE/best/2 is used as a mutation strategy to search near the optimal individuals of the current population, and the mutation strategy is as follows:
“DE/best/2”:V i,G =X best,G +F×(X r2,G -X r3,G )+F×(X r4,G -X r5,G )
wherein X is best,G The individual vector with the best fitness value in the G generation population is obtained;
3) Balancer population P 3
For the balancer population P 3 According to the size of individual fitness value, dividing the current iteration to the G generation population into an excellent population and a common population, and in the variation strategy of the improved differential evolution algorithm, X r1,G ,X r2,G ,X r4,G Randomly selecting from a superior population, X r3,G And X r5,G Random selection from the common population, adaptive mutation strategy selection is as follows:
wherein the proportion of the excellent population scale to the whole population scale is set to 0.4, Q G For the probability of being selected in the two mutation strategies of the above formula, the following is calculated:
further, the step S34 is performed to enter a mutation stage, and a corresponding particle mutation method is performed according to a corresponding mutation strategy and an adaptive mutation factor F, wherein the adaptive mutation factor F is generated as follows:
wherein F is 0 For the initial value of the mutation factor, G is the number of current iterations, G m The maximum iteration number; f from 2F 0 Decrementing to F 0
Further, the adaptive crossover probability Cr of each individual in S35 is generated as follows:
wherein is Cr max ,Cr min Is a maximum value and a minimum value given to Cr, f i ,f min And f max Respectively representing the fitness of the ith individual, the average value of the population fitness, the fitness of the optimal individual and the fitness of the worst individual.
Advantageous effects
(1) Aiming at the problem of sewage quality prediction, the invention provides an improved differential evolution algorithm, designs a self-adaptive mutation strategy and aims at evolving early-stage auxiliary P 3 Expanding search range and helping P in later period of evolution 3 The convergence speed is improved. Thereby promoting the population P 3 The balance of the prediction model is synchronously improved.
(2) The improved differential evolution algorithm provided by the invention designs a self-adaptive F, cr strategy, and improves the optimizing performance of ADE. And then, the optimal hidden layer neuron number and learning rate are obtained by utilizing an ADE algorithm, so that the prediction accuracy of the prediction model is improved.
(3) The LSTM based on the attention mechanism can distribute corresponding weight according to the importance of the important characteristics of the input sewage. Thus, the ability of the LSTM neural network to learn the importance of the sewage data features can be improved, and more accurate prediction can be realized.
Drawings
FIG. 1 is a diagram of a multi-population evolution strategy according to the present invention;
FIG. 2 is a diagram of an attention module according to the present invention;
FIG. 3 is an algorithm flow of the DTL-EADE-LSWSVM of the present invention.
Detailed Description
Embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.
The invention provides an LSTM sewage water quality prediction method based on an improved DE and attention mechanism, which comprises the following steps:
step 1: pretreatment is carried out on an important characteristic data set of a sewage treatment plant, wherein the characteristic data set comprises pH, conductivity, water temperature, turbidity, potassium permanganate, total phosphorus, ammonia nitrogen, total nitrogen and dissolved oxygen historical data at the previous moments at the current moment;
outlier processing is performed on the data set, and the formula is as follows:
where x is the value of the data point; μ is the average of the dataset; σ is the standard deviation of the dataset. If the absolute value of Z for a data point exceeds a threshold (typically 2 or 3 is selected), the data point may be marked as outliers.
The missing value processing is carried out on the data set, and the formula is as follows:
x # =(x f +x b )/2
wherein x is # Is a padded value; x is x f Is the previous point in time data; x is x b Is the latter point in time data. The missing values are filled as the average value of the data of the adjacent time points thereof, so that the filling values reflect the variation trend of the real data to a certain extent.
The data set is normalized, and the formula is as follows:
wherein x is the normalized value; and x is max And x min Respectively, a maximum value and a minimum value in the data set. The method can help the prediction model to better understand and capture the relation between different features, and improves the sensitivity of the model to data.
Step 2: constructing and initializing an ATT-LSTM water quality prediction model;
an ATT-LSTM water quality prediction model is constructed to obtain an initial framework of an ATT-LSTM mixed model, wherein the mixed model comprises two parts of ATT and LSTM, the ATT can be simply understood as weighted summation, and corresponding weights can be distributed according to the importance of input features. The calculation formula is as follows:
wherein T is the total time step; h is a m Is the output eigenvector of LSTM; alpha m Is the result of the first weighted calculation through the full connection layer; w (W) l αh And b α The weight matrix and the bias of the full connection layer are respectively; beta m Is calculated by softmax activation function and assigned to corresponding h m Final weight of (c); and face toThe quantity γ is an important feature of the extraction. And LSTM predicts the characteristic weighted water quality time series.
Step 3: based on the preprocessed data, utilizing ADE to optimize the super-parameters of the ATT-LSTM water quality prediction model to obtain the optimal super-parameters ADE-ATT-LSTM water quality prediction model.
S31: the number of hidden layer neurons and the learning rate of the ATT-LSTM model are selected as optimization parameters of an ADE algorithm, the optimization range of the parameters to be optimized is determined, and the population P is initialized randomly.
Initialization of population P, the first step is to generate an initial population X in the N D dimension in the search space i,G ={x 1 i,G ,…,x D i,G },i=1,...,N,G=0,1,…,G max Where N represents population size, D represents the dimension of the decision vector, G max Representing the maximum number of iterations. In addition, setting the search upper and lower limits of each dimension in the decision variable according to the problem to be optimized, wherein the search lower limit is defined as X min ={x 1 min ,...,x D min Upper search limit defined as X max ={x 1 max ,...,x D max }. In order for the initial population to cover the entire search space as much as possible, the population individuals are generally uniformly and randomly initialized within the given upper and lower search limits as follows:
wherein rand (0, 1) represents a random variable uniformly distributed in the range of [0,1 ].
S32: calculating the fitness value of each individual in the ADE algorithm:
wherein p is the number of samples, y p As the true value of the sample,is a predicted value.
S33: randomly dividing the whole population P into exploratory sub-populations P 1 Developing sub-population P 2 And a balancer population P 3 And adaptively select mutation strategies. How to select the mutation strategy is as follows:
sub-population adaptive selection mutation strategy:
1) Sonde population P 1
Sonde population P 1 The DE/rand/2 is adopted as a mutation strategy, and the mutation strategy uses two random differential vectors to interfere a target individual, so that the mutation strategy has stronger disturbance and better global searching capability, and can obviously improve the diversity of the population. The mutation strategy is as follows:
“DE/rand/2”:V i,G =X r1,G +F×(X r2,G -X r3,G )+F×(X r4,G -X r5,G )
wherein V is i,G For individuals X in the current population i,G A mutation vector is generated using a mutation strategy. r is (r) 1 、r 2 、r 3 、r 4 、r 5 Respectively represent [1, N ]]Mutually exclusive integers randomly generated within the range. F epsilon [0,1]]Is a mutation factor.
2) Developing sub-populations
Development of sub-population P 2 DE/best/2 was used as a mutation strategy. The mutation strategy searches near the optimal individuals of the current population, has good local development capability, and is beneficial to the convergence of the whole population. The mutation strategy is as follows:
“DE/best/2”:V i,G =X best,G +F×(X r2,G -X r3,G )+F×(X r4,G -X r5,G )
wherein X is best,G The individual vector with the best fitness value in the G generation population.
3) Balance sub-population
For the balancer population P 3 And dividing the current iteration to the generation G into an excellent population and a common population according to the fitness value of the individuals. Through excellent population and common speciesThe cooperation of the clusters achieves an improvement in the performance of the algorithm. The excellent population is intended to provide the most desirable direction of evolution, thereby enhancing the local search capabilities of the algorithm. The common population aims at adjusting the searching direction so as to increase the diversity of the population, increase the global searching capability and avoid premature convergence. In the variation strategy of the improved differential evolution algorithm, X r1,G ,X r2,G ,X r4,G Randomly selecting from a superior population, X r3,G And X r5,G Randomly selected from a common population. The adaptive mutation strategy was selected as follows:
wherein the proportion of the excellent population scale to the whole population scale is set to 0.4, Q G For the probability of being selected in the two mutation strategies of the above formula, the following is calculated:
s34: entering a mutation stage, and executing a corresponding particle mutation method according to a corresponding mutation strategy and the adaptive mutation factor F; the adaptive mutation factor F is generated as follows:
F=F 0 ·2 λ
wherein F is 0 For the initial value of the mutation factor, G is the number of current iterations, G m The maximum iteration number; f from 2F 0 Decrementing to F 0 Therefore, the global searching capability of the algorithm can be enhanced in the early stage of the algorithm, the searching range can be enlarged, and the convergence rate of the algorithm can be improved in the later stage.
S35: and entering a mutation stage, and executing a corresponding particle mutation method according to the adaptive crossover probability Cr. The adaptive crossover probability Cr for each individual is generated as follows:
wherein is Cr max ,Cr min Is a maximum value and a minimum value given to Cr, f i ,f min And f max Respectively representing the fitness of the ith individual, the average value of the population fitness, the fitness of the optimal individual and the fitness of the worst individual.
S36: calculating the fitness value of the individual, determining the optimal value in the 3 sub-populations, and combining the 3 sub-populations;
s37: determining whether the algorithm satisfies a condition for terminating the iteration; if the iteration number reaches the maximum value, returning to the optimal super-parameters of the model; otherwise, S23 is repeated to continue execution until the algorithm satisfies the termination condition.
Step 4: based on the preprocessed data, a training set and a testing set are constructed to train the optimal super-parameter ADE-ATT-LSTM water quality prediction model.
To verify that ADE-ATT-LSTM can be put into practical use, a certain amount of data set is required for verification and output of a predicted value. The model predictive ability is evaluated based on the predicted value and the actual value of the validation sample.
Step 5: the collected data set comprising the historical data of pH, conductivity, water temperature, turbidity, potassium permanganate, total phosphorus, ammonia nitrogen, total nitrogen and dissolved oxygen at the previous moments is input into a trained ADE-ATT-LSTM water quality prediction model to obtain DO prediction results, wherein the specific process is as follows:
s51: acquiring a water quality data sample, and sequentially performing abnormality, deletion and normalization;
s52: inputting the processed water quality data sample into a trained ADE-ATT-LSTM water quality prediction model;
s53: and outputting a final water quality prediction result through calculation of the neural network.
To objectively and equitably evaluate the predictive effect of the proposed ADE-ATT-LSTM model, a Root Mean Square Error (RMSE), a Mean Absolute Error (MAE), a mean percent error (MAPE), and a decision coefficient (R) are selected 2 ) As an evaluation index. The correlation formula is as follows:
wherein N is the number of samples, y n To be a true value of the value,is the average of the true values, +.>Is the predicted value of the model.
The performance index of all models is shown in table 1.
Table 1 evaluation index results of each classification model
Comparing the model of the present invention with LSTM, ATT-LSTM, PSO-LSTM, DE-LSTM and DE-ATT-LSTM, it can be seen from Table 1 that the R of the DE-ATT-LSTM prediction algorithm of the present invention is superior to other algorithms 2 RMSE, MAPE and MAEIs optimal. DE-ATT-LSTM was improved over standard LSTM in all four criteria. Compared with the DE-LSSVM, after the attention mechanism and the self-adaptive DE are integrated, the classification performance of the ADE-ATT-LSSVM is greatly improved, and the sewage quality prediction problem can be effectively solved.
The foregoing embodiments are merely illustrative of the technical concept and features of the present invention, and are intended to enable those skilled in the art to understand the present invention and to implement the same, not to limit the scope of the present invention. All equivalent changes or modifications made according to the spirit of the present invention should be included in the scope of the present invention.

Claims (7)

1. An LSTM sewage water quality prediction method based on an improved DE and attention mechanism is characterized by comprising the following steps:
step 1: preprocessing an important characteristic data set of a sewage treatment plant, wherein the characteristic data set comprises pH, conductivity, water temperature, turbidity, potassium permanganate, total phosphorus, ammonia nitrogen, total nitrogen and dissolved oxygen DO historical data at the previous moments;
step 2: constructing and initializing an ATT-LSTM water quality prediction model, wherein the ATT-LSTM water quality prediction model is a long-term and short-term memory LSTM neural network model based on an attention mechanism ATT;
step 3: based on the preprocessed data, optimizing the super-parameters of the ATT-LSTM water quality prediction model by utilizing an improved differential evolution algorithm ADE to obtain an optimal super-parameter ADE-ATT-LSTM water quality prediction model;
step 4: constructing a training set and a testing set based on the preprocessed data to train the optimal super-parameter ADE-ATT-LSTM water quality prediction model;
step 5: and inputting the collected data set comprising the pH, conductivity, water temperature, turbidity, potassium permanganate, total phosphorus, ammonia nitrogen, total nitrogen and dissolved oxygen historical data at the previous moments into a trained ADE-ATT-LSTM water quality prediction model to obtain a future DO value prediction result.
2. The LSTM wastewater quality prediction method for improving DE and attention mechanisms according to claim 1, wherein the step of preprocessing the data set in step 1 comprises:
s11: outlier processing: firstly, carrying out descriptive statistics on characteristic values to check unreasonable data and whether the data are subjected to normal distribution, and when the average value of the sample distance is greater than 3 standard deviations, recognizing the sample as an abnormal value and deleting the abnormal value in a data set;
s12: missing value processing: indexing the data containing the missing values in the data set, and filling the indexed missing values according to the data of the previous time point and the next time point;
s13: normalization: the data of different scales and ranges are mapped into a unified range to eliminate dimensional differences between different features.
3. The LSTM sewage quality prediction method for improving DE and attention mechanism according to claim 1, wherein the attention mechanism in step 2 assigns corresponding weights according to the importance of the input features, and the calculation formula is as follows:
wherein T is the total time step; h is a m Is the output eigenvector of LSTM; alpha m Is the result of the first weighted calculation through the full connection layer; w (W) l αh And b α The weight matrix and the bias of the full connection layer are respectively; beta m Calculated by softmax activation functionAssigned to corresponding h m Final weight of (c); and vector γ is an important feature of extraction.
4. The LSTM wastewater quality prediction method for improving DE and attention mechanisms according to claim 1, wherein optimizing the super parameters of the ATT-LSTM water quality prediction model using ADE based on the preprocessed data in the step 3 comprises:
s31: the number of hidden layer neurons and the learning rate of the ATT-LSTM water quality prediction model are selected as optimization parameters of an ADE algorithm, the optimization range of the parameters to be optimized is determined, and the population P is initialized randomly;
s32: calculating the fitness value of each individual in the ADE algorithm:
wherein p is the number of samples, y p As the true value of the sample,is a predicted value;
s33: randomly dividing the whole population P into exploratory sub-populations P 1 Developing sub-population P 2 And a balancer population P 3 And adaptively selecting a mutation strategy;
s34: entering a mutation stage, and executing a corresponding particle mutation method according to a corresponding mutation strategy and the adaptive mutation factor F;
s35: entering a mutation stage, and executing a corresponding particle mutation method according to the self-adaptive crossover probability Cr;
s36: calculating the fitness value of the individual, determining the optimal value in the 3 sub-populations, and combining the 3 sub-populations;
s37: judging whether the condition of ending the iteration is satisfied; if the iteration number reaches the maximum value, returning to the optimal super-parameters of the model; otherwise, S33 is repeated to continue execution until the termination condition is satisfied.
5. The LSTM wastewater quality prediction method for improving DE and attention mechanisms according to claim 4, wherein the S33 neutron population adaptive selection mutation strategy is specifically as follows:
1) Sonde population P 1
Sonde population P 1 DE/rand/2 was used as a mutation strategy; the target individual is interfered by using two random differential vectors, and the mutation strategy is as follows:
“DE/rand/2”:V i,G =X r1,G +F×(X r2,G -X r3,G )+F×(X r4,G -X r5,G )
wherein V is i,G For individuals X in the current population i,G Generating a mutation vector by using mutation strategy, r 1 、r 2 、r 3 、r 4 、r 5 Respectively represent [1, N ]]Mutually exclusive integers randomly generated in range, F E [0,1]Is a variation factor;
2) Development of sub-population P 2
Development of sub-population P 2 DE/best/2 is used as a mutation strategy to search near the optimal individuals of the current population, and the mutation strategy is as follows:
“DE/best/2”:V i,G =X best,G +F×(X r2,G -X r3,G )+F×(X r4,G -X r5,G )
wherein X is best,G The individual vector with the best fitness value in the G generation population is obtained;
3) Balancer population P 3
For the balancer population P 3 According to the size of individual fitness value, dividing the current iteration to the G generation population into an excellent population and a common population, and in the variation strategy of the improved differential evolution algorithm, X r1,G ,X r2,G ,X r4,G Randomly selecting from a superior population, X r3,G And X r5,G Random selection from the common population, adaptive mutation strategy selection is as follows:
wherein the proportion of the excellent population scale to the whole population scale is set to 0.4, Q G For the probability of being selected in the two mutation strategies of the above formula, the following is calculated:
6. the LSTM sewage quality prediction method for improving DE and attention mechanisms according to claim 4, wherein the step S34 is performed by performing a corresponding particle mutation method according to a corresponding mutation strategy and an adaptive mutation factor F, and the adaptive mutation factor F is generated as follows:
F=F 0 ·2 λ
wherein F is 0 For the initial value of the mutation factor, G is the number of current iterations, G m The maximum iteration number; f from 2F 0 Decrementing to F 0
7. The LSTM wastewater quality prediction method for improving DE and attention mechanisms according to claim 4, wherein said adaptive crossover probability Cr for each individual of S35 is generated as follows:
wherein is Cr max ,Cr min Is a maximum value and a minimum value given to Cr, f i ,f min And f max Respectively representing the fitness of the ith individual, the average value of the population fitness, the fitness of the optimal individual and the fitness of the worst individual.
CN202311148279.3A 2023-09-06 2023-09-06 LSTM sewage water quality prediction method based on improved DE and attention mechanism Pending CN117291069A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311148279.3A CN117291069A (en) 2023-09-06 2023-09-06 LSTM sewage water quality prediction method based on improved DE and attention mechanism

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311148279.3A CN117291069A (en) 2023-09-06 2023-09-06 LSTM sewage water quality prediction method based on improved DE and attention mechanism

Publications (1)

Publication Number Publication Date
CN117291069A true CN117291069A (en) 2023-12-26

Family

ID=89256354

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311148279.3A Pending CN117291069A (en) 2023-09-06 2023-09-06 LSTM sewage water quality prediction method based on improved DE and attention mechanism

Country Status (1)

Country Link
CN (1) CN117291069A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118016201A (en) * 2024-04-08 2024-05-10 长春理工大学 Portable networking water quality detection method and system
CN118016201B (en) * 2024-04-08 2024-06-28 长春理工大学 Portable networking water quality detection method and system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118016201A (en) * 2024-04-08 2024-05-10 长春理工大学 Portable networking water quality detection method and system
CN118016201B (en) * 2024-04-08 2024-06-28 长春理工大学 Portable networking water quality detection method and system

Similar Documents

Publication Publication Date Title
CN110705743B (en) New energy consumption electric quantity prediction method based on long-term and short-term memory neural network
CN112884056A (en) Optimized LSTM neural network-based sewage quality prediction method
CN111860982A (en) Wind power plant short-term wind power prediction method based on VMD-FCM-GRU
CN113468803B (en) WOA-GRU flood flow prediction method and system based on improvement
CN110059867B (en) Wind speed prediction method combining SWLSTM and GPR
CN110910004A (en) Reservoir dispatching rule extraction method and system with multiple uncertainties
CN112733997B (en) Hydrological time series prediction optimization method based on WOA-LSTM-MC
CN112884236B (en) Short-term load prediction method and system based on VDM decomposition and LSTM improvement
CN113537469B (en) Urban water demand prediction method based on LSTM network and Attention mechanism
CN109472346B (en) Emergency material demand prediction method considering fuzzy and missing of partial data
CN110956309A (en) Flow activity prediction method based on CRF and LSTM
CN116451556A (en) Construction method of concrete dam deformation observed quantity statistical model
CN116187835A (en) Data-driven-based method and system for estimating theoretical line loss interval of transformer area
CN115759415A (en) Power consumption demand prediction method based on LSTM-SVR
CN109408896B (en) Multi-element intelligent real-time monitoring method for anaerobic sewage treatment gas production
CN113762591B (en) Short-term electric quantity prediction method and system based on GRU and multi-core SVM countermeasure learning
CN113537539B (en) Multi-time-step heat and gas consumption prediction model based on attention mechanism
CN116911459A (en) Multi-input multi-output ultra-short-term power load prediction method suitable for virtual power plant
CN111310974A (en) Short-term water demand prediction method based on GA-ELM
CN116303786A (en) Block chain financial big data management system based on multidimensional data fusion algorithm
CN115456286A (en) Short-term photovoltaic power prediction method
CN117291069A (en) LSTM sewage water quality prediction method based on improved DE and attention mechanism
CN115759343A (en) E-LSTM-based user electric quantity prediction method and device
CN113902492A (en) Time-sharing electricity price prediction method and system
CN113435628B (en) Medium-long-term runoff prediction method and system based on linear discriminant analysis and IALO-ELM

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination