# Employing Artificial Neural Networks to Predict the Performance of Domestic Sewage Treatment Terminals in the Rural Region

Authors: Qiang Lin; Ancheng Luo; Yan Zhang; Yunlong Wang; Zhiwei Liang; Ping Yuan
Journal: Mathematical Problems in Engineering
 (2021)

---

## Abstract

Domestic sewage in rural regions is mainly treated by small-scale treatment terminals in China. The large quantities and high dispersion of these terminals render the chemical measurement of effluent to be a time and energy intensive work and further hinder the efficient surveillance of terminals’ performance. After a thorough investigation of 136 operating terminals, this study successfully employs two artificial neural network (ANN) models to predict effluent total nitrogen (TN) and COD (R2 both higher than 0.8) by setting some easily detectable parameters, e.g., pH and conductivity, as inputs. To prevent ANN models getting stuck on local optima and enhance the model performance, genetic algorithm (GA) and particle swarm optimization (PSO) are introduced into ANN, respectively. By comparison, ANN-PSO excels in modelling both TN and COD. The root mean square error (RMSE) and R2 of ANN-PSO in modelling TN are 9.14 and 0.90, respectively, in the training stage, and 11.54 and 0.90, respectively, in the validation stage. The RMSE and R2 of ANN-PSO in modelling COD are 22.10 and 0.90, respectively, in the training stage, and 26.57 and 0.85, respectively, in the validation stage. This is the first study to provide performance prediction models that are available for different terminals. Two established ANN-PSO models show great practical significance in monitoring huge amounts of terminals despite the slight sacrifice of models’ accuracy caused by the great heterogeneity of different terminals.


---

## Body

## 1. Introduction

The economic boom and fast increase in the living standards of residents brings about the growing production of rural domestic sewage (RDS). It is estimated that, in China, the annual RDS discharge reaches up to 19.5 billion tons, which is about 63% of the urban domestic sewage [1]. In light of the large amounts of nutrients like organic matter or nitrogen contained in the RDS, either direct discharge or improper treatment of RDS will impose non-negligible threats to the receiving water [2]. In many developing countries, RDS has become the main source of pollution in the rural region [3, 4].In the Zhejiang province, RDS is mainly treated by small-scale terminals with treatment capacities ranging from tons to dozens of tons. Traditional biological treatment (A2O) dominates the technology mainstream of these terminals with regard to its competitive edge in a low construction cost and energy demands. Whereas, the notorious problem of A2O that the performance of the biological process is easily affected by the ambient environment has gradually stood out in recent years [5]. The approach of periodical manual sampling integrated with a traditional chemical test has been adopted as the main monitoring strategy to determine some important effluent index, like COD or total nitrogen (TN), by most regional governments and carried out for decades. However, the large quantities and high dispersion (sometimes, tens of thousands of terminals scatter throughout one city) of these terminals render the surveillance work to be a time and energy intensive work and require large capital investment.


### 1.1. Application of the ANN Model on Modelling the Water Quality

Machine learning (ML) methods provide some potential alternatives to control or simulate targets through examples or past experiences [6]. Among them, an artificial neural network (ANN) has become increasingly popular in the field of wastewater treatment and exhibited more excellent accuracy in modelling nonlinear targets like effluent water quality than many other ML methods [7]. For instance, Abyaneh [8] found ANN excelled higher accuracy and adequacy capacity in modelling BOD and COD of WWTP, compared with the multivariate linear regression method. In addition, in the study by Mahdiyah et al. [9], ANN obtained the best prediction performance in accuracy relative to the extreme learning machine and support vector machine methods.The backpropagation (BP) ANN model is one of the most studied ANN models, which can redistribute errors from the output to input layer by iterations in order to find the appropriate model parameters like weights and thresholds. Excellent self-learning and adaptability of BP ANN has already been reflected by the applications in multiple fields [10]. For instance, Antwi et al. [11] employed two BP ANN models in the prediction of ammonia and total nitrogen removal and demonstrated a good result (R2 > 0.98). Likewise, Mandal et al. [12] also used BP ANN in simulating As(III) removal with R2 above 0.97 for both training and validation processes. However, the drawbacks of BP ANN that it tends to be trapped by local optima due to severe initialization sensitivity are often put forward by researchers [13]. Apart from that, the high requirements for computational complexity and memory in some BP ANN intrinsic algorithms like Levenberg–Marquardt also deserve proper attention [14].


### 1.2. Application of Hybrid ANN on Modelling the Water Quality

Evolutionary algorithms, like particle swarm optimization (PSO) and genetic algorithm (GA), are often introduced into ANN as optimization strategies [15]. The principle of PSO is to globally search the solution space in order to select the most well-behaved particles [16]. It has edges in the low computing volume, strong memory ability for remembering the best position of each particles, and higher convergence characteristics as it only depends on the particle velocity to do the searching job [15, 17]. Improvement in the prediction accuracy of the PSO-based hybrid model has been documented in many previous studies. Mei et al. [18] introduced PSO into ANN in a electro-oxidation system and achieved accurate predictions with R2 of 0.99 and 0.9944 for COD removal and total energy consumption, respectively. Khajeh et al. [19] validated the hybrid model, ANN-PSO, which was robust in modelling Mn(II) and Co(II) removal efficiency in adsorption (R2 was 0.942 and 0.944 for Mn(II) and Co(II)alt, respectively). GA is a metaheuristic algorithm inspired from the natural selection process [20]. It is suitable to search for a single and exclusive target and obtain satisfying performance with reduced complexity of ANN [15]. ANN-GA models have also shown to be superior than ANN in various fields. The study of Azad et al. [21] showed that ANFIS models (adaptive neuro fuzzy inference system) only displayed good simulation in the training stage of modelling precipitation in the winter and spring, and the accuracy of models in the validation stage was very poor. ANFIS-GA made up for these shortcomings and achieved the purpose of optimization. Jalalkamali [22] reported that ANFIS-PSO and ANFIS-GA both exhibited excellent simulation of spatiotemporal groundwater quality, and the ANFIS-PSO model yielded better performance than ANFIS-GA.


### 1.3. Limitations of Current Cases Applied on Modelling the Effluent of RDS Terminals

Although many successful ANN cases have been applied to predict effluent quality of WWTP, two significant shortcomings are worth highlighting when these cases are extended to RDS: (1) database of the established model mainly comes from the historical data of a single target, like a specific WWTP. Great heterogeneity among terminals will inevitably challenge the availability of the model (established for a specific terminal) for other terminals, while constructing the model for each terminals would be too costly. (2) Inputs contained some parameters that are difficult or costly to be measured. In some cases, influent TN even served as inputs for effluent TN prediction [23].This research is dedicated to finding a universal, practicable, and affordable monitoring approach for different terminals. To make the model applicable to as many terminals as possible, data from 136 operating terminals were collected. Then, ANN, ANN-GA, and ANN-PSO models are employed in this study to predict effluent TN and COD by setting some easily detectable and low cost parameters like pH and conductivity as inputs.


## 1.1. Application of the ANN Model on Modelling the Water Quality

Machine learning (ML) methods provide some potential alternatives to control or simulate targets through examples or past experiences [6]. Among them, an artificial neural network (ANN) has become increasingly popular in the field of wastewater treatment and exhibited more excellent accuracy in modelling nonlinear targets like effluent water quality than many other ML methods [7]. For instance, Abyaneh [8] found ANN excelled higher accuracy and adequacy capacity in modelling BOD and COD of WWTP, compared with the multivariate linear regression method. In addition, in the study by Mahdiyah et al. [9], ANN obtained the best prediction performance in accuracy relative to the extreme learning machine and support vector machine methods.The backpropagation (BP) ANN model is one of the most studied ANN models, which can redistribute errors from the output to input layer by iterations in order to find the appropriate model parameters like weights and thresholds. Excellent self-learning and adaptability of BP ANN has already been reflected by the applications in multiple fields [10]. For instance, Antwi et al. [11] employed two BP ANN models in the prediction of ammonia and total nitrogen removal and demonstrated a good result (R2 > 0.98). Likewise, Mandal et al. [12] also used BP ANN in simulating As(III) removal with R2 above 0.97 for both training and validation processes. However, the drawbacks of BP ANN that it tends to be trapped by local optima due to severe initialization sensitivity are often put forward by researchers [13]. Apart from that, the high requirements for computational complexity and memory in some BP ANN intrinsic algorithms like Levenberg–Marquardt also deserve proper attention [14].


## 1.2. Application of Hybrid ANN on Modelling the Water Quality

Evolutionary algorithms, like particle swarm optimization (PSO) and genetic algorithm (GA), are often introduced into ANN as optimization strategies [15]. The principle of PSO is to globally search the solution space in order to select the most well-behaved particles [16]. It has edges in the low computing volume, strong memory ability for remembering the best position of each particles, and higher convergence characteristics as it only depends on the particle velocity to do the searching job [15, 17]. Improvement in the prediction accuracy of the PSO-based hybrid model has been documented in many previous studies. Mei et al. [18] introduced PSO into ANN in a electro-oxidation system and achieved accurate predictions with R2 of 0.99 and 0.9944 for COD removal and total energy consumption, respectively. Khajeh et al. [19] validated the hybrid model, ANN-PSO, which was robust in modelling Mn(II) and Co(II) removal efficiency in adsorption (R2 was 0.942 and 0.944 for Mn(II) and Co(II)alt, respectively). GA is a metaheuristic algorithm inspired from the natural selection process [20]. It is suitable to search for a single and exclusive target and obtain satisfying performance with reduced complexity of ANN [15]. ANN-GA models have also shown to be superior than ANN in various fields. The study of Azad et al. [21] showed that ANFIS models (adaptive neuro fuzzy inference system) only displayed good simulation in the training stage of modelling precipitation in the winter and spring, and the accuracy of models in the validation stage was very poor. ANFIS-GA made up for these shortcomings and achieved the purpose of optimization. Jalalkamali [22] reported that ANFIS-PSO and ANFIS-GA both exhibited excellent simulation of spatiotemporal groundwater quality, and the ANFIS-PSO model yielded better performance than ANFIS-GA.


## 1.3. Limitations of Current Cases Applied on Modelling the Effluent of RDS Terminals

Although many successful ANN cases have been applied to predict effluent quality of WWTP, two significant shortcomings are worth highlighting when these cases are extended to RDS: (1) database of the established model mainly comes from the historical data of a single target, like a specific WWTP. Great heterogeneity among terminals will inevitably challenge the availability of the model (established for a specific terminal) for other terminals, while constructing the model for each terminals would be too costly. (2) Inputs contained some parameters that are difficult or costly to be measured. In some cases, influent TN even served as inputs for effluent TN prediction [23].This research is dedicated to finding a universal, practicable, and affordable monitoring approach for different terminals. To make the model applicable to as many terminals as possible, data from 136 operating terminals were collected. Then, ANN, ANN-GA, and ANN-PSO models are employed in this study to predict effluent TN and COD by setting some easily detectable and low cost parameters like pH and conductivity as inputs.


## 2. Methods and Materials

### 2.1. Investigation of Rural Domestic Sewage Terminal

Changxing is a county located in Huzhou City, Zhejiang Province, with a total area of 1430 sq. km. It has a subtropical monsoon climate, with an average annual temperature ranging from 14°C ∼ 22°C. According to the official data, there are more than 0.27 million residents living in the rural region. Domestic sewage in this region is mainly treated by small-scale A2O treatment terminals. To have a full mastering of the current performance and preparing for the next round terminal upgrading, a survey was conducted from March to April, 2018. A total of 136 A2O rural sewage treatment terminals were investigated.


### 2.2. Analysis of Water Quality and Selection of Inputs

Influent and effluent water samples were carefully collected at each terminal and stored in a −20° fridge until analysis. NH4+–N, TP, TN, and COD were determined by the HACH Kit (HACH, USA). Conductivity (DDSJ-308A, INESA, China), pH (HQ11 d, HACH, USA), and turbidity (2100Q, HACH, USA) were measured by an online parameter. Pollutant removal efficiency is computed according to the following formula:(1)Removal Efficiency=Influent concentration−effluent concentrationInfluent concentration.The parameters that are significantly correlated with effluent TN and COD are screened out through IBM SPSS statistics 24. Then, principal component analysis (PCA), subtractive clustering algorithm (SCA), and fuzzy c-means algorithm (FCM) are used in this study to further determine dimensions of inputs [24–26]. Initially, PCA is used to ensure the importance of inputs and minimize the redundancy problems caused by massive strongly intercorrelated data. Then, SCA and FCM are used to determine the number of clusters and clustering centers of outputs and inputs, respectively. Eventually, clustering centers of these inputs and outputs are treated by the Johnson Algorithm in the Rosetta Software to determine the input dimensions.


### 2.3. Methodology of ANN, ANN-GA, and ANN-PSO

#### 2.3.1. ANN

Figure1 shows the typical structure of classical ANN. Briefly, the ANN model consists of several layers, and according to their distinctive layers, neurons can be subdivided into input, hidden, and output neurons. Hidden layers, serving as feature detectors to introduce nonlinearity into the network, can be either single or multiarchitecture, depending on the case need. The construction of the ANN model includes training (input feed forward and error back propagation) and validation.Figure 1
Typical structure of the ANN neural network.(i) Input Feed Forward. Simplified feed forward calculations are as follows [10]:Hidden neurons receive signals from the input neurons through a set of specific weights, thresholds, and transferring functions as follows [10]:(2)bj=F∑i=1mai×wij+Pj.Again, the signals are passed to the output neuron and form the final predicted values (output neurons) as follows [10]:(3)c′=F′∑i=1nvj×bj+Q,where aj represents the value of the input neuron; bj represents the value of the hidden neuron; wija and vj are the weights between the input neuron ai and hidden neuron bi,j and hidden neuron bj and output neuron, respectively; Pj and Q are the connection thresholds of the hidden neuron and output neuron, respectively; F and F′ means the transfer function from input neurons to hidden neurons and hidden neurons to output neurons, respectively. c′ is the predicted value of effluent TN or COD concentration. Initially, wij, Pj, vj, and Q are all randomly selected small values and will be readjusted in the latter feedback works.(ii) Error Back Propagation. The core of back propagation lies in redistribution of errors from the output layer to the former layer and readjustment of the parameters like weight and connection threshold accordingly. After certain iterations of back propagation, the error will be minimized, and the model will obtain a better fitness. In this study, the Levenberg–Marquardt Algorithm is adopted as the network training function for the update of previous parameters with regard to its fast computing speed and outstanding training ability. Models that are only established under the circumstances of the mean square error (MSE) is small enough [10],(4)MSE=1m∑k=1mck′−ck2,where c′ and c stand for the predicted value and measured value, respectively. m is the number of samples.(iii) Validation Procedure of Models. Validation is the last important procedure to retest the reliability after model establishment. Subsequent model applications can be only carried out under the circumstances that the results of validation fit expectations.


#### 2.3.2. ANN-GA

As aforementioned, to prevent the models trapped by local optima, GA and PSO are used for the selection of suitable initial weights and thresholds for ANN (Figure2). The idea of GA was derived from the principles of natural selection and genetics. It treats the parameters (initial weights and thresholds) that need optimization as chromosomes. Chromosomes with high fitness will be selected, and others will be replaced by genetic propagation like crossover and mutation [28]. It is reported that GA is very good at global searching, independent of the initial value to achieve the convergence. However, compared to PSO, complicated processes like crossover and mutation will slow down the convergence rate of GA [15]. The brief methodology of GA can be made as previous studies and method description partly reproduces their wording [27]: (1)
Start ANN and obtain the corresponding initial weight and threshold. These parameters are subsequently encoded into binary strings to form chromosomes.(2)
Compute the fitness coefficient of each chromosome and retain the ones with high fitness.(3)
Use crossover and mutation to treat rest chromosomes.Crossover operator [27]:(5)AKJ=AKJ1−B+ALJB,ALJ=ALJ1−B+AKJB,where AKJ and ALJ are the Kth and the Lth chromosomes; B is the random value from 0 to 1.Mutation operator [27]:(6)QIJ=QIJ+QIJ−Qmax⋅R2⋅1−gGmax,α>0.5,QIJ+Qmin−QIJ⋅R2⋅1−gGmax,α≤0.5,where QIJ is the Jth gene of the Ith chromosome; Qmax and Qmin are the maximum and minimum of gene QIJ; g is the current iteration time; R2 is a random number; Gmax is the maximum iteration time; and α is a random number ranging from 0 to 1.(4)
Repeat step 2 until obtaining chromosomes with the best fitness after several iterations. Decode the chromosomes and replace the initial weights and threshold of the ANN model with these optimized ones.Figure 2
Flowchart of ANN-GA and ANN-PSO [27].


#### 2.3.3. ANN-PSO

PSO is a modern heuristic algorithm derived from natural foraging and swarming of birds or fish [17]. The bases of PSO is built on the team cooperation and information sharing [29]. The algorithm treats the parameters that need optimization (like initial weights and thresholds) as particles. Each particle represents an individual solution, and the swarms of particles show the whole solution space. The individual particle is not only aware of the position of itself and others, but also searches the solution space through its present velocity, previous experience, and the experience of its neighbour particles [16]. Hence, apart from fast convergence, PSO also has advantages in remembering particles’ best location. However, as velocity, a key parameter for searching process, is lack of dynamic adjustment, PSO sometimes will lead to the consequences of difficult convergence and low convergence accuracy [15]. The following methodology of PSO-ANN has been obtained from previous studies, and the method description partly reproduces their wording [27].(1)
Start ANN and obtain the corresponding initial weight and threshold. These parameters are subsequently encoded into particles of a group, and each particles get their corresponding position (ep) and velocity (fp) information [27],(7)ep=ep1,ep2,ep3,...,eph,fp=fp1,fp2,fp3,...,fph,where h means the dimension of space.(2)
Determine the fitness of each particle (pbest) and compare it to the best historical value of pbest.(3)
Evaluate the overall fitness of the group (gbest) and compare it with the best historical value of the gbest.(4)
Update the velocity and position information of each particle by the following formula [27]:(8)fph=ω⋅fph+h1⋅Rand1⋅pbestph−eph+h2⋅Rand2⋅gbestph−eph,eph=eph+fph,where Rand1 and Rand2 are two uniform random functions, and h1 and h2 are the learn rates(5)
Repeat step 2 until the particles with the best fitness after several iterations are obtained. Replace the initial weights and threshold of the ANN model with these optimized ones.


#### 2.3.4. Modeling Performance Criteria

The root mean square error (RMSE), the coefficient of determination (R2), mean absolute percentage error (MAPE), and nash sutcliffe efficiency coefficient (NSEC) are the four criteria to evaluate model precision from different aspects [30, 31],(9)RMSE=∑k=1mck′−ck2m,R2=m∑k=1mckck′−∑k=1mck∑k=1mck′m∑k=1mck2−∑k=1mck2×m∑k=1mck2′−∑k=1mck′22,MAPE=1m∑k=1mck−ck′ck×100,(10)NSEC=∑k=1mck′−ck2∑k=1mck−ck¯2,where c¯ stands for the measured value.


#### 2.3.5. Index Contribution and Sensibility Analysis

For a better description of the contribution from each input parameter within models, the importance of each input parameter is computed by the subsequent formula from the perspective of the weights of the input neurons [32],(11)Ci=∑j=1nhABSwij∑l=1nv∑j=1nhABSwijl,where Ci stands for the contribution index of the input i; nh stands for the number of hidden neurons; nv stands for the number of input variables; wij stands for the weight of the input layer to the hidden layer; and ABS represents the absolute value of function.The Morris screening method is used to identify the sensibility of the model to each input from the perspective of the prediction outcome [33]. Briefly, the sensitivity of a certain input parameter will be evaluated by increasing or decreasing its value by 10% and keeping others intact and seeing how the model will react to the change [33],(12)di,k=inputb,kck″−ck′inputpc,k−inputb,kck′,μi=1m∑k=1mdi,k,where inputb refers to the original input value; inputpc refers to the proportional change in the original input value; c′ is the original outcome of the model; c″ is the model reaction to the corresponding changes of inputp c; and μi is the sensibility index of each input.All the aforementioned processes are performed in IBM SPSS statistics 24, Matlab R2017b, Excel 2016, and AutoCAD 2019.


## 2.1. Investigation of Rural Domestic Sewage Terminal

Changxing is a county located in Huzhou City, Zhejiang Province, with a total area of 1430 sq. km. It has a subtropical monsoon climate, with an average annual temperature ranging from 14°C ∼ 22°C. According to the official data, there are more than 0.27 million residents living in the rural region. Domestic sewage in this region is mainly treated by small-scale A2O treatment terminals. To have a full mastering of the current performance and preparing for the next round terminal upgrading, a survey was conducted from March to April, 2018. A total of 136 A2O rural sewage treatment terminals were investigated.


## 2.2. Analysis of Water Quality and Selection of Inputs

Influent and effluent water samples were carefully collected at each terminal and stored in a −20° fridge until analysis. NH4+–N, TP, TN, and COD were determined by the HACH Kit (HACH, USA). Conductivity (DDSJ-308A, INESA, China), pH (HQ11 d, HACH, USA), and turbidity (2100Q, HACH, USA) were measured by an online parameter. Pollutant removal efficiency is computed according to the following formula:(1)Removal Efficiency=Influent concentration−effluent concentrationInfluent concentration.The parameters that are significantly correlated with effluent TN and COD are screened out through IBM SPSS statistics 24. Then, principal component analysis (PCA), subtractive clustering algorithm (SCA), and fuzzy c-means algorithm (FCM) are used in this study to further determine dimensions of inputs [24–26]. Initially, PCA is used to ensure the importance of inputs and minimize the redundancy problems caused by massive strongly intercorrelated data. Then, SCA and FCM are used to determine the number of clusters and clustering centers of outputs and inputs, respectively. Eventually, clustering centers of these inputs and outputs are treated by the Johnson Algorithm in the Rosetta Software to determine the input dimensions.


## 2.3. Methodology of ANN, ANN-GA, and ANN-PSO

### 2.3.1. ANN

Figure1 shows the typical structure of classical ANN. Briefly, the ANN model consists of several layers, and according to their distinctive layers, neurons can be subdivided into input, hidden, and output neurons. Hidden layers, serving as feature detectors to introduce nonlinearity into the network, can be either single or multiarchitecture, depending on the case need. The construction of the ANN model includes training (input feed forward and error back propagation) and validation.Figure 1
Typical structure of the ANN neural network.(i) Input Feed Forward. Simplified feed forward calculations are as follows [10]:Hidden neurons receive signals from the input neurons through a set of specific weights, thresholds, and transferring functions as follows [10]:(2)bj=F∑i=1mai×wij+Pj.Again, the signals are passed to the output neuron and form the final predicted values (output neurons) as follows [10]:(3)c′=F′∑i=1nvj×bj+Q,where aj represents the value of the input neuron; bj represents the value of the hidden neuron; wija and vj are the weights between the input neuron ai and hidden neuron bi,j and hidden neuron bj and output neuron, respectively; Pj and Q are the connection thresholds of the hidden neuron and output neuron, respectively; F and F′ means the transfer function from input neurons to hidden neurons and hidden neurons to output neurons, respectively. c′ is the predicted value of effluent TN or COD concentration. Initially, wij, Pj, vj, and Q are all randomly selected small values and will be readjusted in the latter feedback works.(ii) Error Back Propagation. The core of back propagation lies in redistribution of errors from the output layer to the former layer and readjustment of the parameters like weight and connection threshold accordingly. After certain iterations of back propagation, the error will be minimized, and the model will obtain a better fitness. In this study, the Levenberg–Marquardt Algorithm is adopted as the network training function for the update of previous parameters with regard to its fast computing speed and outstanding training ability. Models that are only established under the circumstances of the mean square error (MSE) is small enough [10],(4)MSE=1m∑k=1mck′−ck2,where c′ and c stand for the predicted value and measured value, respectively. m is the number of samples.(iii) Validation Procedure of Models. Validation is the last important procedure to retest the reliability after model establishment. Subsequent model applications can be only carried out under the circumstances that the results of validation fit expectations.


### 2.3.2. ANN-GA

As aforementioned, to prevent the models trapped by local optima, GA and PSO are used for the selection of suitable initial weights and thresholds for ANN (Figure2). The idea of GA was derived from the principles of natural selection and genetics. It treats the parameters (initial weights and thresholds) that need optimization as chromosomes. Chromosomes with high fitness will be selected, and others will be replaced by genetic propagation like crossover and mutation [28]. It is reported that GA is very good at global searching, independent of the initial value to achieve the convergence. However, compared to PSO, complicated processes like crossover and mutation will slow down the convergence rate of GA [15]. The brief methodology of GA can be made as previous studies and method description partly reproduces their wording [27]: (1)
Start ANN and obtain the corresponding initial weight and threshold. These parameters are subsequently encoded into binary strings to form chromosomes.(2)
Compute the fitness coefficient of each chromosome and retain the ones with high fitness.(3)
Use crossover and mutation to treat rest chromosomes.Crossover operator [27]:(5)AKJ=AKJ1−B+ALJB,ALJ=ALJ1−B+AKJB,where AKJ and ALJ are the Kth and the Lth chromosomes; B is the random value from 0 to 1.Mutation operator [27]:(6)QIJ=QIJ+QIJ−Qmax⋅R2⋅1−gGmax,α>0.5,QIJ+Qmin−QIJ⋅R2⋅1−gGmax,α≤0.5,where QIJ is the Jth gene of the Ith chromosome; Qmax and Qmin are the maximum and minimum of gene QIJ; g is the current iteration time; R2 is a random number; Gmax is the maximum iteration time; and α is a random number ranging from 0 to 1.(4)
Repeat step 2 until obtaining chromosomes with the best fitness after several iterations. Decode the chromosomes and replace the initial weights and threshold of the ANN model with these optimized ones.Figure 2
Flowchart of ANN-GA and ANN-PSO [27].


### 2.3.3. ANN-PSO

PSO is a modern heuristic algorithm derived from natural foraging and swarming of birds or fish [17]. The bases of PSO is built on the team cooperation and information sharing [29]. The algorithm treats the parameters that need optimization (like initial weights and thresholds) as particles. Each particle represents an individual solution, and the swarms of particles show the whole solution space. The individual particle is not only aware of the position of itself and others, but also searches the solution space through its present velocity, previous experience, and the experience of its neighbour particles [16]. Hence, apart from fast convergence, PSO also has advantages in remembering particles’ best location. However, as velocity, a key parameter for searching process, is lack of dynamic adjustment, PSO sometimes will lead to the consequences of difficult convergence and low convergence accuracy [15]. The following methodology of PSO-ANN has been obtained from previous studies, and the method description partly reproduces their wording [27].(1)
Start ANN and obtain the corresponding initial weight and threshold. These parameters are subsequently encoded into particles of a group, and each particles get their corresponding position (ep) and velocity (fp) information [27],(7)ep=ep1,ep2,ep3,...,eph,fp=fp1,fp2,fp3,...,fph,where h means the dimension of space.(2)
Determine the fitness of each particle (pbest) and compare it to the best historical value of pbest.(3)
Evaluate the overall fitness of the group (gbest) and compare it with the best historical value of the gbest.(4)
Update the velocity and position information of each particle by the following formula [27]:(8)fph=ω⋅fph+h1⋅Rand1⋅pbestph−eph+h2⋅Rand2⋅gbestph−eph,eph=eph+fph,where Rand1 and Rand2 are two uniform random functions, and h1 and h2 are the learn rates(5)
Repeat step 2 until the particles with the best fitness after several iterations are obtained. Replace the initial weights and threshold of the ANN model with these optimized ones.


### 2.3.4. Modeling Performance Criteria

The root mean square error (RMSE), the coefficient of determination (R2), mean absolute percentage error (MAPE), and nash sutcliffe efficiency coefficient (NSEC) are the four criteria to evaluate model precision from different aspects [30, 31],(9)RMSE=∑k=1mck′−ck2m,R2=m∑k=1mckck′−∑k=1mck∑k=1mck′m∑k=1mck2−∑k=1mck2×m∑k=1mck2′−∑k=1mck′22,MAPE=1m∑k=1mck−ck′ck×100,(10)NSEC=∑k=1mck′−ck2∑k=1mck−ck¯2,where c¯ stands for the measured value.


### 2.3.5. Index Contribution and Sensibility Analysis

For a better description of the contribution from each input parameter within models, the importance of each input parameter is computed by the subsequent formula from the perspective of the weights of the input neurons [32],(11)Ci=∑j=1nhABSwij∑l=1nv∑j=1nhABSwijl,where Ci stands for the contribution index of the input i; nh stands for the number of hidden neurons; nv stands for the number of input variables; wij stands for the weight of the input layer to the hidden layer; and ABS represents the absolute value of function.The Morris screening method is used to identify the sensibility of the model to each input from the perspective of the prediction outcome [33]. Briefly, the sensitivity of a certain input parameter will be evaluated by increasing or decreasing its value by 10% and keeping others intact and seeing how the model will react to the change [33],(12)di,k=inputb,kck″−ck′inputpc,k−inputb,kck′,μi=1m∑k=1mdi,k,where inputb refers to the original input value; inputpc refers to the proportional change in the original input value; c′ is the original outcome of the model; c″ is the model reaction to the corresponding changes of inputp c; and μi is the sensibility index of each input.All the aforementioned processes are performed in IBM SPSS statistics 24, Matlab R2017b, Excel 2016, and AutoCAD 2019.


## 2.3.1. ANN

Figure1 shows the typical structure of classical ANN. Briefly, the ANN model consists of several layers, and according to their distinctive layers, neurons can be subdivided into input, hidden, and output neurons. Hidden layers, serving as feature detectors to introduce nonlinearity into the network, can be either single or multiarchitecture, depending on the case need. The construction of the ANN model includes training (input feed forward and error back propagation) and validation.Figure 1
Typical structure of the ANN neural network.(i) Input Feed Forward. Simplified feed forward calculations are as follows [10]:Hidden neurons receive signals from the input neurons through a set of specific weights, thresholds, and transferring functions as follows [10]:(2)bj=F∑i=1mai×wij+Pj.Again, the signals are passed to the output neuron and form the final predicted values (output neurons) as follows [10]:(3)c′=F′∑i=1nvj×bj+Q,where aj represents the value of the input neuron; bj represents the value of the hidden neuron; wija and vj are the weights between the input neuron ai and hidden neuron bi,j and hidden neuron bj and output neuron, respectively; Pj and Q are the connection thresholds of the hidden neuron and output neuron, respectively; F and F′ means the transfer function from input neurons to hidden neurons and hidden neurons to output neurons, respectively. c′ is the predicted value of effluent TN or COD concentration. Initially, wij, Pj, vj, and Q are all randomly selected small values and will be readjusted in the latter feedback works.(ii) Error Back Propagation. The core of back propagation lies in redistribution of errors from the output layer to the former layer and readjustment of the parameters like weight and connection threshold accordingly. After certain iterations of back propagation, the error will be minimized, and the model will obtain a better fitness. In this study, the Levenberg–Marquardt Algorithm is adopted as the network training function for the update of previous parameters with regard to its fast computing speed and outstanding training ability. Models that are only established under the circumstances of the mean square error (MSE) is small enough [10],(4)MSE=1m∑k=1mck′−ck2,where c′ and c stand for the predicted value and measured value, respectively. m is the number of samples.(iii) Validation Procedure of Models. Validation is the last important procedure to retest the reliability after model establishment. Subsequent model applications can be only carried out under the circumstances that the results of validation fit expectations.


## 2.3.2. ANN-GA

As aforementioned, to prevent the models trapped by local optima, GA and PSO are used for the selection of suitable initial weights and thresholds for ANN (Figure2). The idea of GA was derived from the principles of natural selection and genetics. It treats the parameters (initial weights and thresholds) that need optimization as chromosomes. Chromosomes with high fitness will be selected, and others will be replaced by genetic propagation like crossover and mutation [28]. It is reported that GA is very good at global searching, independent of the initial value to achieve the convergence. However, compared to PSO, complicated processes like crossover and mutation will slow down the convergence rate of GA [15]. The brief methodology of GA can be made as previous studies and method description partly reproduces their wording [27]: (1)
Start ANN and obtain the corresponding initial weight and threshold. These parameters are subsequently encoded into binary strings to form chromosomes.(2)
Compute the fitness coefficient of each chromosome and retain the ones with high fitness.(3)
Use crossover and mutation to treat rest chromosomes.Crossover operator [27]:(5)AKJ=AKJ1−B+ALJB,ALJ=ALJ1−B+AKJB,where AKJ and ALJ are the Kth and the Lth chromosomes; B is the random value from 0 to 1.Mutation operator [27]:(6)QIJ=QIJ+QIJ−Qmax⋅R2⋅1−gGmax,α>0.5,QIJ+Qmin−QIJ⋅R2⋅1−gGmax,α≤0.5,where QIJ is the Jth gene of the Ith chromosome; Qmax and Qmin are the maximum and minimum of gene QIJ; g is the current iteration time; R2 is a random number; Gmax is the maximum iteration time; and α is a random number ranging from 0 to 1.(4)
Repeat step 2 until obtaining chromosomes with the best fitness after several iterations. Decode the chromosomes and replace the initial weights and threshold of the ANN model with these optimized ones.Figure 2
Flowchart of ANN-GA and ANN-PSO [27].


## 2.3.3. ANN-PSO

PSO is a modern heuristic algorithm derived from natural foraging and swarming of birds or fish [17]. The bases of PSO is built on the team cooperation and information sharing [29]. The algorithm treats the parameters that need optimization (like initial weights and thresholds) as particles. Each particle represents an individual solution, and the swarms of particles show the whole solution space. The individual particle is not only aware of the position of itself and others, but also searches the solution space through its present velocity, previous experience, and the experience of its neighbour particles [16]. Hence, apart from fast convergence, PSO also has advantages in remembering particles’ best location. However, as velocity, a key parameter for searching process, is lack of dynamic adjustment, PSO sometimes will lead to the consequences of difficult convergence and low convergence accuracy [15]. The following methodology of PSO-ANN has been obtained from previous studies, and the method description partly reproduces their wording [27].(1)
Start ANN and obtain the corresponding initial weight and threshold. These parameters are subsequently encoded into particles of a group, and each particles get their corresponding position (ep) and velocity (fp) information [27],(7)ep=ep1,ep2,ep3,...,eph,fp=fp1,fp2,fp3,...,fph,where h means the dimension of space.(2)
Determine the fitness of each particle (pbest) and compare it to the best historical value of pbest.(3)
Evaluate the overall fitness of the group (gbest) and compare it with the best historical value of the gbest.(4)
Update the velocity and position information of each particle by the following formula [27]:(8)fph=ω⋅fph+h1⋅Rand1⋅pbestph−eph+h2⋅Rand2⋅gbestph−eph,eph=eph+fph,where Rand1 and Rand2 are two uniform random functions, and h1 and h2 are the learn rates(5)
Repeat step 2 until the particles with the best fitness after several iterations are obtained. Replace the initial weights and threshold of the ANN model with these optimized ones.


## 2.3.4. Modeling Performance Criteria

The root mean square error (RMSE), the coefficient of determination (R2), mean absolute percentage error (MAPE), and nash sutcliffe efficiency coefficient (NSEC) are the four criteria to evaluate model precision from different aspects [30, 31],(9)RMSE=∑k=1mck′−ck2m,R2=m∑k=1mckck′−∑k=1mck∑k=1mck′m∑k=1mck2−∑k=1mck2×m∑k=1mck2′−∑k=1mck′22,MAPE=1m∑k=1mck−ck′ck×100,(10)NSEC=∑k=1mck′−ck2∑k=1mck−ck¯2,where c¯ stands for the measured value.


## 2.3.5. Index Contribution and Sensibility Analysis

For a better description of the contribution from each input parameter within models, the importance of each input parameter is computed by the subsequent formula from the perspective of the weights of the input neurons [32],(11)Ci=∑j=1nhABSwij∑l=1nv∑j=1nhABSwijl,where Ci stands for the contribution index of the input i; nh stands for the number of hidden neurons; nv stands for the number of input variables; wij stands for the weight of the input layer to the hidden layer; and ABS represents the absolute value of function.The Morris screening method is used to identify the sensibility of the model to each input from the perspective of the prediction outcome [33]. Briefly, the sensitivity of a certain input parameter will be evaluated by increasing or decreasing its value by 10% and keeping others intact and seeing how the model will react to the change [33],(12)di,k=inputb,kck″−ck′inputpc,k−inputb,kck′,μi=1m∑k=1mdi,k,where inputb refers to the original input value; inputpc refers to the proportional change in the original input value; c′ is the original outcome of the model; c″ is the model reaction to the corresponding changes of inputp c; and μi is the sensibility index of each input.All the aforementioned processes are performed in IBM SPSS statistics 24, Matlab R2017b, Excel 2016, and AutoCAD 2019.


## 3. Results and Discussion

### 3.1. Performance of Rural Domestic Sewage Terminal

Seven vital water parameters were measured and listed in Table1. Indeed, the average NH3-N, TN, TP, and COD concentrations reached up to 53.41 mg/L, 68.32 mg/L, 5.19 mg/L, and 208.92 mg/L, respectively, in the influent, which can be bracketed with or even higher than the pollutant load in some WWTPs [34]. The average NH3-N concentration is very close to the average TN concentration, implying that ammonia nitrogen dominates the nitrogen form in the RDS. Besides that, substantial differences are demonstrated among influents from different terminals. Discrepant regional customs and dilution effect from various factors like rainfall contribute to these differences.Table 1
Influent and effluent parameter of the rural domestic sewage terminal.
ParameterMinMaxAverageInfluentEffluentInfluentEffluentInfluentEffluentpH6.26.38.568.676.886.96Conductivity (μs/cm)24850.614791502972.78948.7Turbidity (NTU)41.7143598.652.5522.46NH3-N (mg/L)4.4113115653.4145.98TN (mg/L)221113014168.3257.92TP (mg/L)0.30.3711.03115.1874.248COD (mg/L)273659335208.92103.43Figure3 shows that the terminals had relatively limited power for pollutant removal. The average removal efficiency of turbidity, NH3-N, TN, TP, and COD were only 11.18%, 16.09%, 13.31%, and 46.39%, respectively. Negative removal efficiency of these pollutants occasionally occurred on some terminals due to factors like releasing of bulking sludge [35]. Similarly, Yu et al. [36] identified about 29% of RDS terminals in Jiaxing (another city in Zhejiang), which were in the ineffective operation. The following reasons are speculated for unsatisfied performance: (1) unstability of biochemical reaction; (2) relatively limited maintenance in light of the massive amounts of terminals; (3) traditional chemical measurement cannot satisfy the need of real-time assessment as it requires intensive time for the digestion of pollutants [37]. Failure to evaluate the performance of terminals on time will let the problematic terminals fall into a worse situation. Every year, local governments have to bear great financial burdens and put considerable amount of economic and human resources into more surveillance. Finding an easier and quicker monitoring approach is an urgent desire at present.Figure 3
Removal efficiency of the terminals for TN, NH3-N, COD, and TP.


### 3.2. Selection of Input Parameters

Significant correlations between some critical water parameters have been referred in the previous studies. Some easily detectable parameters can serve as rough surrogates for pollutant concentration or problems during the operation. For instance, the study of Yu et al. [36] demonstrated that conductivity was significantly correlated with TN, NH4+-N, TP, and COD within both the influent and effluent. Thus, a low correlation between conductivity and TN might imply the leakage of sewer transporting system. Analogously, strong correlations were found between turbidity and parameters like TN and COD [38]. The study of Slaets et al. [39] showed that turbidity is a reliable and cost-effective predictor variable for the linear mixed model developed to account for TN. Apart from conductivity and turbidity, pH had also presented a weak correlation with TN and was served as input in the ANN model to predict TN [40]. Figure 4 shows that these rules are also applicable in the field of RDS. Effluent TN of RDS displays strong correlations with influent conductivity, effluent conductivity, influent ammonia, effluent ammonia, effluent turbidity, respectively, and a weak correlation with influent pH, effluent pH, and effluent turbidity, respectively. Effluent COD of RDS exhibits strong correlations with effluent turbidity, effluent ammonia, influent conductivity, and effluent conductivity, respectively, and a weak correlation with influent ammonia, influent turbidity, influent pH, and effluent pH, respectively. Remarkably, R2 between effluent TN and effluent conductivity can reach 0.80, indicating nitrogen might be mainly presented in the dissolved ammonia form. The high R2 (0.77) between effluent COD and effluent turbidity implies that particle pollutants play an important role in the effluent COD.Figure 4
Correlation coefficient (R2) matrix of influent and effluent parameters (number with the single-asterisk indicates significant correlation, and two-asterisks indicate extremely significant correlation.Correlation analyses indicate that ANN models can be developed to account for effluent TN and COD with these easily detectable parameters (pH, turbidity, conductivity, and ammonia of influent and effluent) as inputs. The results of PCA (Table2.) show that the first principle can explain 44.77% of all variance, and first four components contain 88.99% of variance. Generally, the overall data can be characterized by components that explain more than 85% of variance [41]. SCA, FCM, and Johnson Algorithm are subsequently used to determine the dimension of inputs. Clustering centers of all parameters are shown in Table 3, and the final results of the Johnson Algorithm show that pH, turbidity, ammonia concentration, and conductivity of both influent and effluent can all act as inputs.Table 2
The results of PCA analysis.
ComponentsCharacteristic valueContribution rate, %Accumulated contribution rate, %13.58244.77244.7721.87823.47868.2531.03612.94681.240.6247.79788.9950.4265.32694.3260.2112.63896.9670.1461.82398.7880.0981.22100Table 3
Clustering centers of inputs and outputs.
ParameterCluster centersEffluent TN (mg/L)59Effluent COD (mg/L)128Influent pH6.64Effluent pH6.75Influent ammonia concentration (mg/L)56.5Effluent ammonia concentration (mg/L)53.5Influent conductivity (us/cm)976Effluent conductivity (us/cm)928Influent turbidity (NTU)39.9Effluent turbidity (NTU)10.9


### 3.3. ANN Prediction Performance

Fan et al. [15] concluded 44 studies that used ANN to model and optimize pollutant removal processes. In this review, most studies used about 60% to 80% of data as the training database. Accordingly, this study uses data from 100 terminals as the training database (73.53% of total), then the rest data from 36 terminals are applied to validate the performance of the model. A trial and error approach is used in this study to determine the number of hidden neurons [42, 43]. Since the standard multilayer feedforward network with one hidden layer has been considered as a universal approximator, analogously, this study also configures all models with only one hidden layer [44, 45]. Eventually, ANN, ANN-GA, and ANN-PSO models all contain three distinctive layers. A total of 8 neurons, including pH, conductivity, turbidity, and ammonia concentration of both influent and effluent, are set in the input layer, and 15 neurons are set in the hidden layer. The preset parameters, weights, and thresholds of models can be found in Tables 4 and 5.Table 4
Parameters setting in ANN, ANN-GA, and ANN-PSO.
ModelCommon setting for ANNOthersANNInputnum = 8 (number of input neurons); Hiddennum =15 (number of hidden neurons); Outputnum = 1 (number of output neurons); Net.trainParam.epochs = 20000; Net.trainParam.lr = 0.01 (learning rate); Net.trainParam.goal = 0.000004 (training goal); Purelin, transfer function from input layer to hidden layer; Tansig, transfer function from hidden layer to output layer;NoneANN-GAMaxgen = 100 (number of Iterations); Sizepop =10 (size of population); Pcross = 0.7 (possibility of crossover); Pmutation = 0.1(possibility of mutation)ANN-PSOMaxgen = 100 (number of Iterations); Sizepop =10 (size of population); Vmax = 1 (maximum speed); Vmin = −1(minimum speed); Popmax = 5 (maximum population); Popmin = −5 (minimum population)Table 5
Weights and thresholds of ANN, ANN-GA, and ANN-PSO in modelling TN and COD.
ANN in modelling TNANN in modelling CODWijVjPjQWijVjPjQ−1.49−0.231.070.62−1.091.60−1.65−2.44−0.474.060.09−1.20−1.94−0.542.22−0.211.370.44−1.670.304.42−0.46−0.47−0.630.200.22−1.83−1.35−2.371.980.903.40−0.53−2.31−0.810.69−1.951.24−1.960.140.583.320.991.543.66−1.442.001.23−1.54−1.282.17−3.11−0.66−1.21−0.68−0.540.76−3.240.68−2.42−1.172.321.80−0.770.960.012.50−0.67−1.05−2.190.89−2.80−0.04−1.81−2.771.021.52−0.530.160.59−0.15−2.501.222.14−2.100.110.86−0.721.830.98−0.09−1.70−0.80−2.651.391.82−0.121.96−0.23−0.430.42−0.442.793.51−3.27−0.010.220.65−0.050.53−0.662.01−0.740.20−2.75−0.121.77−0.35−2.351.770.391.160.461.44−1.140.181.53−0.572.67−1.60−0.23−1.24−0.45−1.34−0.59−2.220.37−1.68−1.971.14−0.271.71−1.77−1.511.64−0.061.07−2.492.29−0.80−0.450.01−0.76−3.041.53−0.06−0.11−0.04−1.071.840.220.241.37−1.170.43−3.650.21−0.090.10−3.38−0.59−0.770.110.57−0.16−0.700.042.75−0.932.46−0.870.340.761.442.721.39−1.681.34−1.36−1.37−0.261.502.451.44−0.051.390.24−2.121.80−0.54−0.380.650.401.382.64−0.971.203.192.090.160.46−0.421.402.911.891.061.80−0.941.47−1.440.661.13−0.840.38−1.88−0.783.66−0.830.451.46−1.28−2.790.141.812.120.350.64−3.390.69−2.42−0.81−2.26−0.511.441.710.20−2.23−1.172.240.320.21−2.390.692.211.470.28−0.710.682.010.530.633.42−0.681.322.60−0.41−0.77−1.78−1.710.27−1.11−5.16−2.020.09−1.85−0.381.140.05−2.401.03−0.59−3.491.801.532.55−0.412.84−1.701.51−0.920.082.98−2.12−0.22−0.890.402.20−0.642.181.36−0.78−3.80ANN-GA in modelling TNANN-GA in modelling CODWijVjPjQWijVjPjQ−3.601.620.98−1.10−1.751.782.331.26−0.232.561.311.591.46−1.22−1.861.780.262.050.630.180.070.720.57−0.13−0.93−2.53−3.16−0.34−0.191.87−1.031.112.07−1.351.431.093.271.881.26−0.310.79−2.75−0.890.201.35−3.210.63−1.97−1.722.21−1.260.821.72−2.45−3.49−3.35−0.75−1.860.120.760.150.97−0.160.411.001.233.26−1.15−1.950.99−1.40−2.542.142.28−2.46−0.113.13−0.032.571.191.20−2.37−1.38−2.33−0.15−1.83−0.672.241.963.06−0.75−1.69−2.59−2.062.62−0.20−2.370.96−0.07−0.250.060.980.94−0.043.551.300.721.40−2.60−2.511.00−2.58−1.030.502.571.78−0.03−1.233.10−1.410.091.811.280.020.820.970.90−1.640.26−2.58−1.262.46−1.52−2.762.57−0.272.312.602.860.37−0.11−0.170.01−2.37−2.19−1.18−1.47−0.95−2.450.47−0.211.162.202.49−1.95−2.661.13−0.190.03−2.430.001.39−2.621.992.79−2.270.362.96−1.62−0.98−0.690.100.260.10−2.60−2.35−3.06−1.70−1.561.37−0.10−0.56−1.550.601.45−1.35−0.440.65−0.522.221.98−0.40−2.152.880.48−3.24−2.39−1.431.67−1.90−0.06−0.390.08−0.83−2.87−0.65−1.441.671.561.64−1.050.131.802.33−0.26−2.18−0.26−2.65−1.50−2.28−0.28−0.912.38−2.280.060.08−2.66−2.670.57−2.400.882.172.93−1.94−2.731.131.03−3.281.03−1.35−0.320.69−0.70−1.00−2.90−2.300.28−0.930.952.861.401.32−2.88−0.830.390.30−2.63−0.88−2.41−1.400.671.160.62−0.41−1.33−0.021.610.022.64−0.740.36−2.86−0.22−0.992.24−0.13−0.100.39−2.19−0.260.401.54−0.58−1.750.820.36−1.440.451.08−3.23−0.220.26−2.33−2.18−2.881.53−3.611.570.15−2.420.011.01ANN-PSO in modelling TNANN-PSO in modelling CODWijVjPjQWijVjPjQ1.79−0.100.741.930.170.84−4.762.350.23−3.411.670.00−0.872.81−0.48−0.97−1.511.72−1.020.530.18−0.271.091.87−0.19−0.840.52−1.654.391.910.120.14−1.98−3.063.022.25−0.47−2.81−0.301.29−0.03−1.67−0.58−0.381.411.081.37−2.12−2.30−1.79−0.20−3.280.150.54−0.68−1.06−0.762.01−2.59−0.300.03−1.60−0.30−2.75−1.992.57−2.930.13−1.78−2.240.27−0.552.841.13−0.711.000.440.73−1.35−0.500.171.10−0.743.692.14−0.35−0.59−1.620.93−1.752.143.730.382.301.62−0.13−0.660.74−0.801.970.101.940.270.82−4.790.03−0.881.91−1.671.49−0.010.85−2.560.11−0.320.330.89−0.73−2.310.04−0.392.043.58−3.08−0.98−0.232.68−3.231.06−3.40−0.081.28−0.48−1.471.32−2.14−0.98−1.38−0.953.04−0.21−0.400.040.871.753.903.390.32−0.47−0.080.25−0.951.430.55−1.70−0.98−0.790.87−1.362.720.43−1.00−1.020.46−2.06−3.303.72−1.78−1.802.03−0.021.58−2.44−1.82−0.06−1.51−0.351.641.470.05−0.11−2.22−1.031.41−0.05−0.69−3.22−0.09−0.583.08−0.250.121.201.320.96−3.060.672.040.96−1.76−0.23−1.05−4.771.84−0.02−0.093.69−0.17−2.130.910.202.86−1.240.83−0.551.92−0.20−0.420.860.320.13−0.76−1.162.98−2.13−0.081.79−0.420.26−0.89−0.261.610.261.13−0.080.050.07−1.100.85−1.44−0.89−0.29−0.031.432.14−0.012.194.940.45−1.44−0.021.95−1.741.191.143.42−0.970.801.87−1.670.091.593.16−1.631.233.20−0.93−3.10−1.58−0.70−3.852.801.763.190.830.210.150.660.39−0.86−0.220.622.20−1.14−0.84−1.53−2.88−1.220.893.130.22−2.730.30−0.62−1.862.82−0.781.29−0.960.80−0.330.44The prediction performance of the three models for TN and COD can be seen in Figures5 and 6, respectively. The prediction curves of the three models not only acquire the knowledge base of these terminals, but also closely capture the fluctuation trend of the true curves. As shown in Figure 7, the linear fit for ANN-PSO curves is closest to the reference line (100% accuracy), followed by the linear fit for ANN-GA curves and finally ANN curves, demonstrating ANN-PSO yields the best predicting performance for both TN and COD [27]. Table 6 shows ANN-PSO also obtained the most reliable performance in terms of the model error. The R2, RMSE, and MAPE of ANN-PSO in modelling TN are 0.90, 9.14, and 16.19%, respectively, in training, and 0.90, 11.54, and 16.79%, respectively, in validation. In terms of COD prediction, R2, RMSE, and MAPE of ANN-PSO are 0.90, 22.10, and 34.57%, respectively, in training, and 0.85, 26.57, and 22.30%, respectively, in validation. Considering that ANN-PSO models possess higher R2 and lower RMSE than ANN models, ANN-PSO models neither get into overfitting nor underfitting after optimization. In addition, this study uses NSEC to evaluate the predictive power of models. Theoretically, NSEC ranges from −∞ to 1. 0 indicates that the prediction performance of the model is close to the mean of the measured value; in the other words, the overall result is credible and 1 indicates that the model is in the perfect prediction. The closer NSEC is to 1, the more accuracy models can reach [30]. The NSEC of ANN-PSO in modelling TN are both 0.97 for training and validation and NSEC of ANN-PSO in modelling COD are 0.89 and 0.84, respectively, for training and validation, showing strong prediction power of ANN-PSO. Except the accuracy advantage, ANN-PSO shows superiority in terms of computational time. It takes ANN-PSO less than 1 min for 100 iterations of model convergence, while it takes ANN-GA about 6 min to do the same work.Figure 5
Performance of TN prediction.Figure 6
Performance of COD prediction.Figure 7
Linear regression curve of ANN, ANN-GA, and ANN-PSO models.Table 6
Error analysis about ANN, ANN-GA, and ANN-PSO.
ModelInput parametersPredicted parametersR2RMSEMAPENSECANNInfluent pH,effluent pH, influent conductivity, effluent conductivity, influent turbidity, effluent turbidity, influent NH3-N, effluent NH3-N.Effluent TN0.84 for training;11.40 for training18.99% for training;0.95 for training;0.85 for validation13.49 for validation19.93% for validation0.95 for validationEffluent COD0.81 for training;30.88 for training;45.42% for training;0.80 for training;0.82 for validation30.00 for validation24.54% for validation0.80 for validationANN-GAEffluent TN0.90 for training;9.42 for training;14.90% for training;0.97 for training;0.84 for validation13.56 for validation20.09% for validation0.95 for validationEffluent COD0.76 for training;34.31 for training;53.92% for training;0.76 for training;0.85 for validation26.25 for validation26.91% for validation0.84 for validationANN-PSOEffluent TN0.90 for training;9.14 for training;16.19% for training;0.97 for training;0.90 for validation11.54 for validation16.79% for validation0.97 for validationEffluent COD0.90 for training;22.10 for training;34.57% for training;0.90 for training;0.85 for validation26.57 for validation22.30% for validation0.84 for validation


### 3.4. Contributions and Sensibility Analysis of Each Input

Contributions of inputs in the ANN-PSO models are calculated in Figure8. In the ANN-PSO modelling TN, the indices range from 10.16% to 15.84% among parameters. Influent turbidity makes the biggest contribution to TN prediction. Although the ANN model is often regarded as a black box, lacking a direct mechanism to demystify the interrelationship between neurons, the contribution results strongly suggests that inputs like influent turbidity play more important roles than others in the ANN-PSO modelling TN [32, 46]. While, in the ANN-PSO modelling COD, the contributions of inputs range from 6.43% to 15.00%. Inputs like effluent conductivity and pH significantly participate in the COD prediction.Figure 8
Contribution analysis of ANN-PSO in modelling TN and COD.Morris screening is used to identify the sensibility of each input for ANN-PSO models (Table7) [33]. Accordingly, the sensibility index (μi) higher than 1 implies that the outcomes of the model exhibit more drastic changes than the corresponding changes of inputs. Therefore, in the ANN-PSO modelling TN, only effluent and influent pH cause larger change to the model. While, in the ANN-PSO modelling COD, not only effluent and influent pH, but also influent and effluent conductivity yield μi higher than 1. The sensibility results show that, in both two models, effluent and influent pH are the most sensible inputs, the second most sensible inputs are influent and effluent conductivity and NH3-N, the less sensible inputs are effluent and influent turbidity.Table 7
Sensibility analysis of ANN-PSO in the modelling of TN and COD.
TNUpper 10%Lower 10%Ranke_pH3.084.491i_PHi2.342.712i_Con0.640.653e_Con0.580.654e_NH30.410.385i_NH30.330.296e_Tur0.280.147i_Tur0.10.18CODe_pH5.576.171i_PHi3.012.682i_Con1.331.453e_Con1.181.184i_NH30.570.565e_NH30.410.386e_Tur0.350.357i_Tur0.110.118


### 3.5. Advantages, Limitations, and Recommendation for Future Works

Table8 summarizes some previous successful studies. By comparison, R2 of the two ANN-PSO models in this study (0.85 to 0.90) are at a similar level to that in the previous studies (about 0.70 to 0.99). One shortcoming of this study lies in our relatively high RMSE. The sharp fluctuation of TN and COD cannot be ignored for this issue. For example, effluent COD mostly fluctuated within 10 to 60 mg/L in the study of Luo et al. [23]. In contrast, the range is magnified to 3–335 mg/L in this study. Great heterogeneity among these terminals will inevitably introduce new errors into the models and make the models slightly lose their edges in precision. However, compared with previous studies, two ANN-PSO models in this study are both available for different terminals and do not require historical data from terminals, which obviously save a lot of time and energy and be more practical even at the cost of sacrificing certain degree of precision. Another special advantage of this study is that the inputs are easier to be obtained and can all be measured by electrodes (NH3-N was measured by traditional chemical methods in this study, but it can be also measured by using the ammonia gas sensing electrode [52]).Table 8
ANN application cases in the previous works.
Application scenarioModelInput parametersPredicted parametersR2ErrorAuthorsWWTPAdaptive neuro fuzzy inference systemInfluent pH, influent temperature, influent SS, and influent COD.Effluent SS0.88 for training; 0.89 for validation1.87 for training; 0.71 for validation∗∗[34]Effluent COD0.79 for training; 0.83 for validation3.83 for training; 2.47 for validation∗∗Effluent pH0.93 for training; 0.93 for validation0.07 for training; 0.05 for validation∗∗∗∗Fenton reactorArtificial neural networkReaction time, pH, antibiotic concentration, H2O2, etcCOD removal efficiency0.9970.000376∗[47]WWTPArtificial neural network-feed forward back propagationCOD, BOD, TSSCOD0.93 for training;—[48]0.86 for validationAnoxic/oxic reactorArtificial neural networkInfluent COD, reflux ratio, carbon-nitrogen ratioEffluent COD0.985962.82∗[49]Artificial neural network-genetic algorithm0.994761.12∗The upflow anaerobic filter reactorMultilayer perceptron neural networkInfluent chemical oxygen demand, hydraulic retention time, and influent cyanide concentrationEffluent COD0.983 for training; 0.876 for validation104.75 for training; 98.35 for validation∗∗[31]Radial basis neural network0.995 for training; 0.708 for validation56.81 for training, 157.95 for validation∗∗Regression neural network0.951 for training; 0.751 for validation175.19 for training, 140.51 for validation∗∗LakesArtificial neural networkNH4-N, secchi depthTN0.72 for training, 0.69 for validation0.15 for training, 0.14 for validation∗∗[50]Partial-nitritation/anammox reactorBack propagation artificial neural networkInfluent NO3-, NO2-, pH and enfluent NO3-, NO2-,TN removal efficiency0.8890.091∗[51]WWTPFuzzy rough-back propagationReturn ratio, sludge volume, MLSS,DO, Q (flow), efﬂuent suspended solid, influent TP, influent TN, influent COD, influent ammonia concentraion.Effluent COD0.9212.86∗∗[23]Effluent TN0.8821.35∗∗Principal component analysis-back propagationEffluent COD0.8863.15∗∗Effluent TN0.8621.52∗∗Back propagation-neural networksEffluent COD0.8133.46∗∗Effluent TN0.8221.97∗∗In the error column, numbers with one asterisks is MSE, and numbers with two asterisks is RMSE.Based on the above findings, this study has the following two recommendations for future works: 1. As shown in Figure9, use electrodes to collect input data and realize remote online prediction of effluent water quality based on ANN-PSO, which has not been done before. 2. Since biological treatment is greatly influenced by procedure variables, like DO of aerobic tank [5], future studies can try to use some procedure variables as inputs for the improvement of model accuracy.Figure 9
Online prediction of TN and COD based on ANN-PSO models.


## 3.1. Performance of Rural Domestic Sewage Terminal

Seven vital water parameters were measured and listed in Table1. Indeed, the average NH3-N, TN, TP, and COD concentrations reached up to 53.41 mg/L, 68.32 mg/L, 5.19 mg/L, and 208.92 mg/L, respectively, in the influent, which can be bracketed with or even higher than the pollutant load in some WWTPs [34]. The average NH3-N concentration is very close to the average TN concentration, implying that ammonia nitrogen dominates the nitrogen form in the RDS. Besides that, substantial differences are demonstrated among influents from different terminals. Discrepant regional customs and dilution effect from various factors like rainfall contribute to these differences.Table 1
Influent and effluent parameter of the rural domestic sewage terminal.
ParameterMinMaxAverageInfluentEffluentInfluentEffluentInfluentEffluentpH6.26.38.568.676.886.96Conductivity (μs/cm)24850.614791502972.78948.7Turbidity (NTU)41.7143598.652.5522.46NH3-N (mg/L)4.4113115653.4145.98TN (mg/L)221113014168.3257.92TP (mg/L)0.30.3711.03115.1874.248COD (mg/L)273659335208.92103.43Figure3 shows that the terminals had relatively limited power for pollutant removal. The average removal efficiency of turbidity, NH3-N, TN, TP, and COD were only 11.18%, 16.09%, 13.31%, and 46.39%, respectively. Negative removal efficiency of these pollutants occasionally occurred on some terminals due to factors like releasing of bulking sludge [35]. Similarly, Yu et al. [36] identified about 29% of RDS terminals in Jiaxing (another city in Zhejiang), which were in the ineffective operation. The following reasons are speculated for unsatisfied performance: (1) unstability of biochemical reaction; (2) relatively limited maintenance in light of the massive amounts of terminals; (3) traditional chemical measurement cannot satisfy the need of real-time assessment as it requires intensive time for the digestion of pollutants [37]. Failure to evaluate the performance of terminals on time will let the problematic terminals fall into a worse situation. Every year, local governments have to bear great financial burdens and put considerable amount of economic and human resources into more surveillance. Finding an easier and quicker monitoring approach is an urgent desire at present.Figure 3
Removal efficiency of the terminals for TN, NH3-N, COD, and TP.


## 3.2. Selection of Input Parameters

Significant correlations between some critical water parameters have been referred in the previous studies. Some easily detectable parameters can serve as rough surrogates for pollutant concentration or problems during the operation. For instance, the study of Yu et al. [36] demonstrated that conductivity was significantly correlated with TN, NH4+-N, TP, and COD within both the influent and effluent. Thus, a low correlation between conductivity and TN might imply the leakage of sewer transporting system. Analogously, strong correlations were found between turbidity and parameters like TN and COD [38]. The study of Slaets et al. [39] showed that turbidity is a reliable and cost-effective predictor variable for the linear mixed model developed to account for TN. Apart from conductivity and turbidity, pH had also presented a weak correlation with TN and was served as input in the ANN model to predict TN [40]. Figure 4 shows that these rules are also applicable in the field of RDS. Effluent TN of RDS displays strong correlations with influent conductivity, effluent conductivity, influent ammonia, effluent ammonia, effluent turbidity, respectively, and a weak correlation with influent pH, effluent pH, and effluent turbidity, respectively. Effluent COD of RDS exhibits strong correlations with effluent turbidity, effluent ammonia, influent conductivity, and effluent conductivity, respectively, and a weak correlation with influent ammonia, influent turbidity, influent pH, and effluent pH, respectively. Remarkably, R2 between effluent TN and effluent conductivity can reach 0.80, indicating nitrogen might be mainly presented in the dissolved ammonia form. The high R2 (0.77) between effluent COD and effluent turbidity implies that particle pollutants play an important role in the effluent COD.Figure 4
Correlation coefficient (R2) matrix of influent and effluent parameters (number with the single-asterisk indicates significant correlation, and two-asterisks indicate extremely significant correlation.Correlation analyses indicate that ANN models can be developed to account for effluent TN and COD with these easily detectable parameters (pH, turbidity, conductivity, and ammonia of influent and effluent) as inputs. The results of PCA (Table2.) show that the first principle can explain 44.77% of all variance, and first four components contain 88.99% of variance. Generally, the overall data can be characterized by components that explain more than 85% of variance [41]. SCA, FCM, and Johnson Algorithm are subsequently used to determine the dimension of inputs. Clustering centers of all parameters are shown in Table 3, and the final results of the Johnson Algorithm show that pH, turbidity, ammonia concentration, and conductivity of both influent and effluent can all act as inputs.Table 2
The results of PCA analysis.
ComponentsCharacteristic valueContribution rate, %Accumulated contribution rate, %13.58244.77244.7721.87823.47868.2531.03612.94681.240.6247.79788.9950.4265.32694.3260.2112.63896.9670.1461.82398.7880.0981.22100Table 3
Clustering centers of inputs and outputs.
ParameterCluster centersEffluent TN (mg/L)59Effluent COD (mg/L)128Influent pH6.64Effluent pH6.75Influent ammonia concentration (mg/L)56.5Effluent ammonia concentration (mg/L)53.5Influent conductivity (us/cm)976Effluent conductivity (us/cm)928Influent turbidity (NTU)39.9Effluent turbidity (NTU)10.9


## 3.3. ANN Prediction Performance

Fan et al. [15] concluded 44 studies that used ANN to model and optimize pollutant removal processes. In this review, most studies used about 60% to 80% of data as the training database. Accordingly, this study uses data from 100 terminals as the training database (73.53% of total), then the rest data from 36 terminals are applied to validate the performance of the model. A trial and error approach is used in this study to determine the number of hidden neurons [42, 43]. Since the standard multilayer feedforward network with one hidden layer has been considered as a universal approximator, analogously, this study also configures all models with only one hidden layer [44, 45]. Eventually, ANN, ANN-GA, and ANN-PSO models all contain three distinctive layers. A total of 8 neurons, including pH, conductivity, turbidity, and ammonia concentration of both influent and effluent, are set in the input layer, and 15 neurons are set in the hidden layer. The preset parameters, weights, and thresholds of models can be found in Tables 4 and 5.Table 4
Parameters setting in ANN, ANN-GA, and ANN-PSO.
ModelCommon setting for ANNOthersANNInputnum = 8 (number of input neurons); Hiddennum =15 (number of hidden neurons); Outputnum = 1 (number of output neurons); Net.trainParam.epochs = 20000; Net.trainParam.lr = 0.01 (learning rate); Net.trainParam.goal = 0.000004 (training goal); Purelin, transfer function from input layer to hidden layer; Tansig, transfer function from hidden layer to output layer;NoneANN-GAMaxgen = 100 (number of Iterations); Sizepop =10 (size of population); Pcross = 0.7 (possibility of crossover); Pmutation = 0.1(possibility of mutation)ANN-PSOMaxgen = 100 (number of Iterations); Sizepop =10 (size of population); Vmax = 1 (maximum speed); Vmin = −1(minimum speed); Popmax = 5 (maximum population); Popmin = −5 (minimum population)Table 5
Weights and thresholds of ANN, ANN-GA, and ANN-PSO in modelling TN and COD.
ANN in modelling TNANN in modelling CODWijVjPjQWijVjPjQ−1.49−0.231.070.62−1.091.60−1.65−2.44−0.474.060.09−1.20−1.94−0.542.22−0.211.370.44−1.670.304.42−0.46−0.47−0.630.200.22−1.83−1.35−2.371.980.903.40−0.53−2.31−0.810.69−1.951.24−1.960.140.583.320.991.543.66−1.442.001.23−1.54−1.282.17−3.11−0.66−1.21−0.68−0.540.76−3.240.68−2.42−1.172.321.80−0.770.960.012.50−0.67−1.05−2.190.89−2.80−0.04−1.81−2.771.021.52−0.530.160.59−0.15−2.501.222.14−2.100.110.86−0.721.830.98−0.09−1.70−0.80−2.651.391.82−0.121.96−0.23−0.430.42−0.442.793.51−3.27−0.010.220.65−0.050.53−0.662.01−0.740.20−2.75−0.121.77−0.35−2.351.770.391.160.461.44−1.140.181.53−0.572.67−1.60−0.23−1.24−0.45−1.34−0.59−2.220.37−1.68−1.971.14−0.271.71−1.77−1.511.64−0.061.07−2.492.29−0.80−0.450.01−0.76−3.041.53−0.06−0.11−0.04−1.071.840.220.241.37−1.170.43−3.650.21−0.090.10−3.38−0.59−0.770.110.57−0.16−0.700.042.75−0.932.46−0.870.340.761.442.721.39−1.681.34−1.36−1.37−0.261.502.451.44−0.051.390.24−2.121.80−0.54−0.380.650.401.382.64−0.971.203.192.090.160.46−0.421.402.911.891.061.80−0.941.47−1.440.661.13−0.840.38−1.88−0.783.66−0.830.451.46−1.28−2.790.141.812.120.350.64−3.390.69−2.42−0.81−2.26−0.511.441.710.20−2.23−1.172.240.320.21−2.390.692.211.470.28−0.710.682.010.530.633.42−0.681.322.60−0.41−0.77−1.78−1.710.27−1.11−5.16−2.020.09−1.85−0.381.140.05−2.401.03−0.59−3.491.801.532.55−0.412.84−1.701.51−0.920.082.98−2.12−0.22−0.890.402.20−0.642.181.36−0.78−3.80ANN-GA in modelling TNANN-GA in modelling CODWijVjPjQWijVjPjQ−3.601.620.98−1.10−1.751.782.331.26−0.232.561.311.591.46−1.22−1.861.780.262.050.630.180.070.720.57−0.13−0.93−2.53−3.16−0.34−0.191.87−1.031.112.07−1.351.431.093.271.881.26−0.310.79−2.75−0.890.201.35−3.210.63−1.97−1.722.21−1.260.821.72−2.45−3.49−3.35−0.75−1.860.120.760.150.97−0.160.411.001.233.26−1.15−1.950.99−1.40−2.542.142.28−2.46−0.113.13−0.032.571.191.20−2.37−1.38−2.33−0.15−1.83−0.672.241.963.06−0.75−1.69−2.59−2.062.62−0.20−2.370.96−0.07−0.250.060.980.94−0.043.551.300.721.40−2.60−2.511.00−2.58−1.030.502.571.78−0.03−1.233.10−1.410.091.811.280.020.820.970.90−1.640.26−2.58−1.262.46−1.52−2.762.57−0.272.312.602.860.37−0.11−0.170.01−2.37−2.19−1.18−1.47−0.95−2.450.47−0.211.162.202.49−1.95−2.661.13−0.190.03−2.430.001.39−2.621.992.79−2.270.362.96−1.62−0.98−0.690.100.260.10−2.60−2.35−3.06−1.70−1.561.37−0.10−0.56−1.550.601.45−1.35−0.440.65−0.522.221.98−0.40−2.152.880.48−3.24−2.39−1.431.67−1.90−0.06−0.390.08−0.83−2.87−0.65−1.441.671.561.64−1.050.131.802.33−0.26−2.18−0.26−2.65−1.50−2.28−0.28−0.912.38−2.280.060.08−2.66−2.670.57−2.400.882.172.93−1.94−2.731.131.03−3.281.03−1.35−0.320.69−0.70−1.00−2.90−2.300.28−0.930.952.861.401.32−2.88−0.830.390.30−2.63−0.88−2.41−1.400.671.160.62−0.41−1.33−0.021.610.022.64−0.740.36−2.86−0.22−0.992.24−0.13−0.100.39−2.19−0.260.401.54−0.58−1.750.820.36−1.440.451.08−3.23−0.220.26−2.33−2.18−2.881.53−3.611.570.15−2.420.011.01ANN-PSO in modelling TNANN-PSO in modelling CODWijVjPjQWijVjPjQ1.79−0.100.741.930.170.84−4.762.350.23−3.411.670.00−0.872.81−0.48−0.97−1.511.72−1.020.530.18−0.271.091.87−0.19−0.840.52−1.654.391.910.120.14−1.98−3.063.022.25−0.47−2.81−0.301.29−0.03−1.67−0.58−0.381.411.081.37−2.12−2.30−1.79−0.20−3.280.150.54−0.68−1.06−0.762.01−2.59−0.300.03−1.60−0.30−2.75−1.992.57−2.930.13−1.78−2.240.27−0.552.841.13−0.711.000.440.73−1.35−0.500.171.10−0.743.692.14−0.35−0.59−1.620.93−1.752.143.730.382.301.62−0.13−0.660.74−0.801.970.101.940.270.82−4.790.03−0.881.91−1.671.49−0.010.85−2.560.11−0.320.330.89−0.73−2.310.04−0.392.043.58−3.08−0.98−0.232.68−3.231.06−3.40−0.081.28−0.48−1.471.32−2.14−0.98−1.38−0.953.04−0.21−0.400.040.871.753.903.390.32−0.47−0.080.25−0.951.430.55−1.70−0.98−0.790.87−1.362.720.43−1.00−1.020.46−2.06−3.303.72−1.78−1.802.03−0.021.58−2.44−1.82−0.06−1.51−0.351.641.470.05−0.11−2.22−1.031.41−0.05−0.69−3.22−0.09−0.583.08−0.250.121.201.320.96−3.060.672.040.96−1.76−0.23−1.05−4.771.84−0.02−0.093.69−0.17−2.130.910.202.86−1.240.83−0.551.92−0.20−0.420.860.320.13−0.76−1.162.98−2.13−0.081.79−0.420.26−0.89−0.261.610.261.13−0.080.050.07−1.100.85−1.44−0.89−0.29−0.031.432.14−0.012.194.940.45−1.44−0.021.95−1.741.191.143.42−0.970.801.87−1.670.091.593.16−1.631.233.20−0.93−3.10−1.58−0.70−3.852.801.763.190.830.210.150.660.39−0.86−0.220.622.20−1.14−0.84−1.53−2.88−1.220.893.130.22−2.730.30−0.62−1.862.82−0.781.29−0.960.80−0.330.44The prediction performance of the three models for TN and COD can be seen in Figures5 and 6, respectively. The prediction curves of the three models not only acquire the knowledge base of these terminals, but also closely capture the fluctuation trend of the true curves. As shown in Figure 7, the linear fit for ANN-PSO curves is closest to the reference line (100% accuracy), followed by the linear fit for ANN-GA curves and finally ANN curves, demonstrating ANN-PSO yields the best predicting performance for both TN and COD [27]. Table 6 shows ANN-PSO also obtained the most reliable performance in terms of the model error. The R2, RMSE, and MAPE of ANN-PSO in modelling TN are 0.90, 9.14, and 16.19%, respectively, in training, and 0.90, 11.54, and 16.79%, respectively, in validation. In terms of COD prediction, R2, RMSE, and MAPE of ANN-PSO are 0.90, 22.10, and 34.57%, respectively, in training, and 0.85, 26.57, and 22.30%, respectively, in validation. Considering that ANN-PSO models possess higher R2 and lower RMSE than ANN models, ANN-PSO models neither get into overfitting nor underfitting after optimization. In addition, this study uses NSEC to evaluate the predictive power of models. Theoretically, NSEC ranges from −∞ to 1. 0 indicates that the prediction performance of the model is close to the mean of the measured value; in the other words, the overall result is credible and 1 indicates that the model is in the perfect prediction. The closer NSEC is to 1, the more accuracy models can reach [30]. The NSEC of ANN-PSO in modelling TN are both 0.97 for training and validation and NSEC of ANN-PSO in modelling COD are 0.89 and 0.84, respectively, for training and validation, showing strong prediction power of ANN-PSO. Except the accuracy advantage, ANN-PSO shows superiority in terms of computational time. It takes ANN-PSO less than 1 min for 100 iterations of model convergence, while it takes ANN-GA about 6 min to do the same work.Figure 5
Performance of TN prediction.Figure 6
Performance of COD prediction.Figure 7
Linear regression curve of ANN, ANN-GA, and ANN-PSO models.Table 6
Error analysis about ANN, ANN-GA, and ANN-PSO.
ModelInput parametersPredicted parametersR2RMSEMAPENSECANNInfluent pH,effluent pH, influent conductivity, effluent conductivity, influent turbidity, effluent turbidity, influent NH3-N, effluent NH3-N.Effluent TN0.84 for training;11.40 for training18.99% for training;0.95 for training;0.85 for validation13.49 for validation19.93% for validation0.95 for validationEffluent COD0.81 for training;30.88 for training;45.42% for training;0.80 for training;0.82 for validation30.00 for validation24.54% for validation0.80 for validationANN-GAEffluent TN0.90 for training;9.42 for training;14.90% for training;0.97 for training;0.84 for validation13.56 for validation20.09% for validation0.95 for validationEffluent COD0.76 for training;34.31 for training;53.92% for training;0.76 for training;0.85 for validation26.25 for validation26.91% for validation0.84 for validationANN-PSOEffluent TN0.90 for training;9.14 for training;16.19% for training;0.97 for training;0.90 for validation11.54 for validation16.79% for validation0.97 for validationEffluent COD0.90 for training;22.10 for training;34.57% for training;0.90 for training;0.85 for validation26.57 for validation22.30% for validation0.84 for validation


## 3.4. Contributions and Sensibility Analysis of Each Input

Contributions of inputs in the ANN-PSO models are calculated in Figure8. In the ANN-PSO modelling TN, the indices range from 10.16% to 15.84% among parameters. Influent turbidity makes the biggest contribution to TN prediction. Although the ANN model is often regarded as a black box, lacking a direct mechanism to demystify the interrelationship between neurons, the contribution results strongly suggests that inputs like influent turbidity play more important roles than others in the ANN-PSO modelling TN [32, 46]. While, in the ANN-PSO modelling COD, the contributions of inputs range from 6.43% to 15.00%. Inputs like effluent conductivity and pH significantly participate in the COD prediction.Figure 8
Contribution analysis of ANN-PSO in modelling TN and COD.Morris screening is used to identify the sensibility of each input for ANN-PSO models (Table7) [33]. Accordingly, the sensibility index (μi) higher than 1 implies that the outcomes of the model exhibit more drastic changes than the corresponding changes of inputs. Therefore, in the ANN-PSO modelling TN, only effluent and influent pH cause larger change to the model. While, in the ANN-PSO modelling COD, not only effluent and influent pH, but also influent and effluent conductivity yield μi higher than 1. The sensibility results show that, in both two models, effluent and influent pH are the most sensible inputs, the second most sensible inputs are influent and effluent conductivity and NH3-N, the less sensible inputs are effluent and influent turbidity.Table 7
Sensibility analysis of ANN-PSO in the modelling of TN and COD.
TNUpper 10%Lower 10%Ranke_pH3.084.491i_PHi2.342.712i_Con0.640.653e_Con0.580.654e_NH30.410.385i_NH30.330.296e_Tur0.280.147i_Tur0.10.18CODe_pH5.576.171i_PHi3.012.682i_Con1.331.453e_Con1.181.184i_NH30.570.565e_NH30.410.386e_Tur0.350.357i_Tur0.110.118


## 3.5. Advantages, Limitations, and Recommendation for Future Works

Table8 summarizes some previous successful studies. By comparison, R2 of the two ANN-PSO models in this study (0.85 to 0.90) are at a similar level to that in the previous studies (about 0.70 to 0.99). One shortcoming of this study lies in our relatively high RMSE. The sharp fluctuation of TN and COD cannot be ignored for this issue. For example, effluent COD mostly fluctuated within 10 to 60 mg/L in the study of Luo et al. [23]. In contrast, the range is magnified to 3–335 mg/L in this study. Great heterogeneity among these terminals will inevitably introduce new errors into the models and make the models slightly lose their edges in precision. However, compared with previous studies, two ANN-PSO models in this study are both available for different terminals and do not require historical data from terminals, which obviously save a lot of time and energy and be more practical even at the cost of sacrificing certain degree of precision. Another special advantage of this study is that the inputs are easier to be obtained and can all be measured by electrodes (NH3-N was measured by traditional chemical methods in this study, but it can be also measured by using the ammonia gas sensing electrode [52]).Table 8
ANN application cases in the previous works.
Application scenarioModelInput parametersPredicted parametersR2ErrorAuthorsWWTPAdaptive neuro fuzzy inference systemInfluent pH, influent temperature, influent SS, and influent COD.Effluent SS0.88 for training; 0.89 for validation1.87 for training; 0.71 for validation∗∗[34]Effluent COD0.79 for training; 0.83 for validation3.83 for training; 2.47 for validation∗∗Effluent pH0.93 for training; 0.93 for validation0.07 for training; 0.05 for validation∗∗∗∗Fenton reactorArtificial neural networkReaction time, pH, antibiotic concentration, H2O2, etcCOD removal efficiency0.9970.000376∗[47]WWTPArtificial neural network-feed forward back propagationCOD, BOD, TSSCOD0.93 for training;—[48]0.86 for validationAnoxic/oxic reactorArtificial neural networkInfluent COD, reflux ratio, carbon-nitrogen ratioEffluent COD0.985962.82∗[49]Artificial neural network-genetic algorithm0.994761.12∗The upflow anaerobic filter reactorMultilayer perceptron neural networkInfluent chemical oxygen demand, hydraulic retention time, and influent cyanide concentrationEffluent COD0.983 for training; 0.876 for validation104.75 for training; 98.35 for validation∗∗[31]Radial basis neural network0.995 for training; 0.708 for validation56.81 for training, 157.95 for validation∗∗Regression neural network0.951 for training; 0.751 for validation175.19 for training, 140.51 for validation∗∗LakesArtificial neural networkNH4-N, secchi depthTN0.72 for training, 0.69 for validation0.15 for training, 0.14 for validation∗∗[50]Partial-nitritation/anammox reactorBack propagation artificial neural networkInfluent NO3-, NO2-, pH and enfluent NO3-, NO2-,TN removal efficiency0.8890.091∗[51]WWTPFuzzy rough-back propagationReturn ratio, sludge volume, MLSS,DO, Q (flow), efﬂuent suspended solid, influent TP, influent TN, influent COD, influent ammonia concentraion.Effluent COD0.9212.86∗∗[23]Effluent TN0.8821.35∗∗Principal component analysis-back propagationEffluent COD0.8863.15∗∗Effluent TN0.8621.52∗∗Back propagation-neural networksEffluent COD0.8133.46∗∗Effluent TN0.8221.97∗∗In the error column, numbers with one asterisks is MSE, and numbers with two asterisks is RMSE.Based on the above findings, this study has the following two recommendations for future works: 1. As shown in Figure9, use electrodes to collect input data and realize remote online prediction of effluent water quality based on ANN-PSO, which has not been done before. 2. Since biological treatment is greatly influenced by procedure variables, like DO of aerobic tank [5], future studies can try to use some procedure variables as inputs for the improvement of model accuracy.Figure 9
Online prediction of TN and COD based on ANN-PSO models.


## 4. Conclusion

Complicated influent situation and unsatisfying treatment performance of large numbers of rural domestic sewage terminals highlight the urgent need to find a quicker and simpler effluent measurement. Significant correlations are found between some easily detectable parameters (e.g., conductivity and turbidity) and effluent TN and COD, which triggers the idea of using these easily detectable parameters as inputs to predict effluent TN and COD in the ANN models. The results turn out that the ANN models can successfully simulate the effluent TN and COD withR2 both higher than 0.8. Then, GA and PSO are used as two optimization strategies to improve the ANN performance. By comparison, ANN-PSO yields the better prediction capacity for both TN and COD. R2 and RMSE of ANN-PSO on modelling TN are 0.90 and 9.14, respectively, in the training, 0.90 and 11.54, respectively, in the validation. R2 and RMSE of ANN-PSO on modelling COD are 0.90 and 22.10, respectively, in the training, 0.85 and 26.57, respectively, in the validation. Contribution analysis shows that influent turbidity and effluent conductivity make the biggest contribution to ANN-PSO on modelling TN and COD, respectively. Sensibility analysis shows that effluent and influent pH are the two most sensible inputs for both two models. In the end, considering that all inputs can be detected by the electrodes, this study also proposes an ANN-PSO-based remote online water quality monitoring approach.



---

*Source: 5264531-2021-12-23.xml*