#### Abstract

Stochastic neural network has the characteristics of good global convergence and fast gradient-based learning ability. It can be applied to multidimensional nonlinear systems, but its generalization ability is poor. In this paper, combined with rule base, through the PCA method, an improved multimodal variable-structure random-vector neural network algorithm (MM-P-VSRVNN) is proposed for coagulant dosing, which is a key production process in water purification process. Ensuring for qualified water, how to control coagulation dosage effectively, obtain valid production cost, and increase more profits is a focus in the water treatment plan. Different with the normal neural network mode, PCA is used to optimize hidden-layer nodes and update the neural network structure at every computation. This method rectifies coagulant dosage effectively while keeping valid coagulation performance. By the way, the MM-P-VSRVNN algorithm can decrease computation time and avoid overfitting learning ability. Finally, the method is proved feasible through the experiment and analyzed by the simulation result.

#### 1. Introduction

In water purification process, one important point is coagulant dosing. The effect of coagulation is to make dosage mixed with colloidal particles and tiny suspended solids in raw water, subsided in live embodiment of the amorphous substance in the coagulation and sedimentation tank. Coagulant dosing is a complex, physical, and chemical process with time-varied, delay, and nonlinear characteristics. In addition, there are still many actual factors, such as pH value, turbidity, water flow rate, and coagulation dosage that affect coagulation performance. In many references about coagulant dosing, most water plants take two methods, namely, manual dosing and automatic dosing. Manual dosing mostly depends on workers’ experience that is an obvious open-loop control method. It is difficult to save cost effectively. The second is automatic dosing; its control method is related with actual waterworks technology. There is still no uniform control method. Currently, PID control and feedforward control are commonly used, but some water plants still work in manual dosing. Take a water plant in Changsha as an example. Its coagulation effect takes about 90 minutes of delay, and the turbidity after coagulation, named turbidity before filtration, is generally about 5 NTU or less. And the most important thing is that the water plants are still in manual dosing that needs more workers to work by turns. The above being concerned, how to complete coagulant dosing automatically is a hot problem. At present, the automatic control of coagulant dosing mainly adopts a single-factor closed-loop method, which needs to change the method from traditional PID control to intelligent control for complex control objects [1, 2]. Researchers take some predictors to finish coagulant dosing with different manufacturing techniques. Some people try to find a mathematical model of coagulant dosing, as shown in [3–7]. In [3], based on the iterative feedback tuning (IFT), combined with Smith predictive control, a data-driven direct control method is proposed that need not understand the actual time-delay object model. It can initialize the controller and take online self-tuning. In [4], after studying coagulant dosing process in water plants, a feedforward and feedback control method combined with the generalized predictive control (GPC) and PID is proposed for dosing. In [5], a two-stage control structure is designed for dosage target calculation and dynamic optimization of the coagulant dosing system. The model predictive control (MPC), a bounder control method, requires less information of the controlled object and proves its validity by simulation. In [6], this paper focuses on analyzing the structure and principle of coagulant dosing and uses predictive autodisturbance rejection control (PADRC) to design an online self-tuning dosing controller. In [7], a multimodal control strategy is proposed based on artificial intelligence, which simulates actual operation without any manual control and ensures the effect of coagulant dosing. Coagulant dosage mainly depends on the accuracy of the computation outcome of the system's mathematical mode. So, modeling accurately is the most difficult to realize the target here.

With the development of the artificial neural network (ANN), it provides another data-driven solution without any mathematical model for such a nonlinear system. Commonly used ANN also includes the radial basis function (RGF) neural network, backpropagation (BP) neural network, cerebella model control articulation (CMCA) neural network, and self-organizing neural network. Some people have applied these types of feedforward neural networks in coagulant dosing, as shown in [8–11]. In [8], a predictive control strategy is proposed for coagulant dosing in wastewater treatment process, an adaptive neural network model is established to analyze the relationship between dosage and detergency, and it is optimized by the gradient descent method. In [9], a RBF neural network predictor with a feedforward compensation is proposed. For a single-input and single-output system, a nonlinear autoregressive moving average model is built up and predicted for coagulant dosing. In [10] after analyzing the characters of raw water and finding out related factors of coagulant dosing, a feedforward controller is designed combined with the CMAC neural network and fuzzy algorithm, and offline modeling is finished in order to realize online optimization and predict coagulant dosage. In [11], a neural network and an adaptive fuzzy model are established to simulate the coagulant dosing process. Finally, simulation is proved valid. Take the neural network model is feasible that has a lower request, self-learning ability, and generalization ability. This method can be applied to complex industry process without building an accurate mathematical model [12]. However, those mentioned gradient-learning algorithms have an obvious problem: overfitting ability and local optimum. So, it is little difficult to design a specific neural network structure which is invariant with lower flexibility.

For improving the neural network, currently, random-vector neural networks have been developed rapidly in recent years because of their learning speed and generalization ability better than traditional neural network algorithms [13, 14]. In many applications, random-vector neural networks are also used in nonlinear complex systems and verified effectively [15–18]. As we know, water purification itself is a nonlinear complex industrial process; for the dynamic mechanism of coagulant dosing is complex, the internal state is unclear. If we need to find the functional relationship between input and output factors about coagulant dosing, it is very hard to do well in setting up a mathematical model. In this paper, we select a water plant in Changsha as the target and analyze its coagulant dosing process and related factors. Considering the difficulty of building up the neural network model, we propose a variable-structure random-vector neural network (VS-RVNN) model for online learning for optimization of coagulant dosage.

#### 2. Analysis and Modeling for Coagulation Dosing Process

##### 2.1. Analysis for Coagulation Dosing Process

The water purification process mainly includes drug administration, coagulation-sedimentation, filtration, and chlorine disinfection. Each subprocess is independent and related to each other. The coagulation process is composed of data sampler, controller, coagulation-sedimentation tank, and execution equipment. Taking a water plant in Changsha as an example, its process is shown in Figure 1.

When raw water passes through the water pump room, its turbidity and flow velocity are measured before the coagulation tank. In addition, after the coagulant and running water are mixed in an appropriate proportion, the mixture enters the coagulation tank by the dosing pump and performs coagulation reaction with raw water. The coagulant dosing will take effects after about 90 minutes, meaning a long-delay process. At the outlet of the tank, turbidity is measured one more time and judged whether its values reach set values or not. The key point is that necessary data are sampled by equipment, computed by the controller, and an optimum coagulant for dosing pump operation is obtained. Pump adjusts its speed and opening to optimize online coagulant dosage. As we know, coagulant dosing process is complicated, varied, and nonlinear, with long delay. It cannot find the direct relationship between input and output information. So, it is not easy to establish a correct mathematical model.

##### 2.2. Modeling and Control for Coagulant Dosing Process

There are three common modeling methods at current, namely, mechanism model, knowledge-based model, and data-driven model. Firstly, the mechanism model depends too much on the system internal mechanism. However, a system becomes more nonlinear and strong coupling than before; its interior mechanism is complicated and cannot be shown obviously and clearly by formula. Secondly, the knowledge-based model mostly relies on limited expert knowledge with poor adaptability. Lastly, the data-driven model need not know what system’s inner state is; however, it still can predict and give a reasonable decision by a lot of data analyses and intelligent deduction. After analyzing the three methods, establishing a data-driven model has become one powerful method for a complex system in recent years. Neural network model (NNM) is one of them that can deal with inaccurate and complicated information of the complex system [19–21]. In the paper, coagulant dosing process is just such a type without analyzing its mechanism, collecting insufficient and inaccurate expert knowledge. However, coagulant dosing process runs independently; its necessary parameters can be measured and monitored. Taking a water plant in Changsha as an example, water supply varies in different seasons and at different times of a day. Especially at rush hour, water supply must increase sharply. Then, coagulant dosage will be predicted appropriately in advance. Furthermore, there are two main problems about the target water plant at current. One is that it still takes simple manual dosing. The other problem is that system delay is a little long, and working condition is changeable. So, only one simple NNM cannot work useful with abrupt events. Through local investigation, we gather related data and get to a conclusion: turbidity, flow velocity, working pumps affect coagulation obviously. Other parameters such as pH and water temperature also affect coagulation slowly. How to control coagulant dosage is a concerned topic. It satisfies turbidity while decreasing production cost as much as possible. To sum up, aiming at the actual object, a nonlinear autoregressive multimode (NARM) is set up as follows:where historical data are also concerned. A multimodal function is provided in formula (1). is the input data set, is the output, is the lag step , and are different respective nonlinear relations between input parameters and output parameters at different modes. Combining with NARM, for solving the above two problems concerned in this paper, we design a multimodal control scheme, as shown in Figure 2.

In the control scheme, rule base (RB) just contains a lot of dosing parameters and several modal decision rules. The most important focus is the variable-structure random-weight neural network (VS-RVNN). It can build up variable-structure NN which can optimize its model and online-compute the optimum dosage. RB will provide suitable operational parameters for the dosing pump. All data will be stored in a database after one computation is completed. According to the analysis for related factors of coagulant dosing in this part, RB will make a decision by systems’ operating state, select the most suitable mode, and rectify existed rules. The neural network controller updates the target value and training data set, varies the computation model, calculates optimum dosage, and keeps continuous cycle operation. The whole control method mainly combines RB and VS-RVNN and designs a MM-P-VSRVNN algorithm. The design is figured out in Figures 3 and 4.

In Figure 3, about RB, we set multiple modes and design a mode switcher. Through the main influencing factors which have been defined, a series of decision rules are constructed and categorized into the designed mode. These rules are also the criterion of judgement for the switching mode. Furthermore, in each mode, there are some typical control rules about water pump control parameters. The selected control rule will be connected to the ANN controller as a guideline for further optimization.

In Figure 4, we design an initial NNM which has an initial value of hidden-layer nodes in the leftmost. When real-time data are sampled, NNM judges working mode once again and takes a new computation after retraining the neural network with the corresponding training data, and the hidden-layer nodes decrease from to by PCA , and the structure of the neural network is updated for real-time computation. This means NNM will have -type structures after the PCA dimension.

Notation: here, NNM, proposed in Figure 4, has a variable structure. Because the number of hidden-layer nodes is always a key point for modeling, here, NNM is not fixed when we perform principal component analysis (PCA) for hidden-layer nodes. So, NNM has a variable structure at each computation. This method can effectively solve the problem of overfitting and robustness of neural networks and improve the computational speed and generalization ability.

#### 3. MM-P-VSRVNN Algorithm

Combining with Section 2.2, the whole algorithm mainly includes two parts, namely, modal switching and dimensionality reduction by PCA. The prediction algorithm is executed by the MM-P-VSRVNN. It takes two stages: offline modeling and online optimization.

Here, the whole algorithm steps are as follows:

Before computation, we choose a multimodal data set for training samples: . And each mode has its independent data subset in it.(i)Step 1: sample real-time data, and judge the working mode by RB. For example, if , it gives a decision for NNM and switches to the *i*th control strategy.(ii)Step 2: build up a VS-RVNN with a random layer ( nodes) and an output layer ( nodes). The initial value of is set to 60. The random layer can be constructed by the hidden layer and input layer.(iii)Step 3: take the corresponding data subset of training samples for NNM. Then, the functional of the random layer is defined as when mode = *k.* Then, the function of the random layer is defined as where is the input weight of the *j*th hidden-layer node, is the threshold value of the *j*th hidden-layer node, is the random-weight vector of the hidden-layer nodes, and is the input to the network.(iv)Step 4: set the training target, and start to train the NNM with the given data subset.(v)Step 5: let . Repeat to run step 4 until training meets the given target. Otherwise, it restarts at step 2 and computes once again.(vi)Step 6: construct a random-layer training matrix . Each column of represents a random-layer output node, and each row represents a training sample output.(vii)Step 7: perform weighted difference to training matrix , and remove its nonlinear or multimodal characteristics. Next, continue to standardize . Then, the standardized matrix is , and find its correlation coefficient matrix , which meets its mean value per column which is 0 and standard deviation which is 1: where represents the correlation coefficient between variable and variable . After that, the eigenvalue decomposition of is done, eigenvalues and eigenvectors of are computed, and these eigenvalues are sorted by size.(viii)Step 8: calculate the contribution rate of each eigenvalue, and sort all eigenvalues to sum up the components' added contribution rate one by one and compute whether it is over 95 percent or not. If it is, then count the number of major components and construct a transfer matrix: which is based on its corresponding *d* eigenvectors, and the random-layer matrix is met and satisfies the equality .(ix)Step 9: input the latest collected samples into NNM, and calculate the function value of each output-layer node = . All necessary data are stored.(x)Step 10: compare the predicted outcome with the dosage value in the RB, correct control parameters of pumps online, and finish dosing.(xi)Step 11: update the training sample set.(xii)Step 12: wait for the next sampling, and repeat the work from steps 1 to 11. Notation: compared with the traditional RVNN, RS-RVNN can perform mode switching and train the original neural network with the corresponding data set and system’s control state. The output matrix of the hidden layer is obtained through multiple training times and can be reduced dimensionally by PCA. The neural network structure can be optimized under different modalities to ensure the system’s continuous stability. Furthermore, the neural network controller implements dynamic optimization of the variable structure every time. Network training is performed during mode switching, and it enhances the flexibility of the controller.

#### 4. Experiment Results and Discussion

In this paper, we analyze the actual water purification process of Changsha’s water plant. This plant was built up as a two-phase project, which mainly has two storage tanks, alum tanks, coagulation tanks, and pump workshop for capacity expansion. And now, one of them is working. The water purification process with related parameters is shown timely and stored in the system database. Its coagulant dosing system is shown in Figure 5.

Through these data provided by applied instruments and electromechanical equipment, we choose the important factors related to coagulation efficiency: turbidity before filtration (NTU), turbidity of raw water (NTU), discharge of water , water temperature (°C), frequency , pH, pump stroke (percent), target turbidity (NTU), historical data of turbidity (NTU), water flow rate , and coagulant dosing . These are prepared for building up a NNM. Two of them, target turbidity (NTU) and prediction value of coagulant dosing , are output targets of the NNM. From parts 2 and 3, the number of hidden-layer nodes cannot be determined. In our NNM, we set an initial value (60) for hidden-layer nodes, which can be decreased by PCA. Then, the structure of the NNM is optimized, and the prediction for coagulant dosage is obtained. A new NNM is named P-VSRVNN.

Coagulant dosing process contains 3 working modes. In this experiment, we select 1000 groups of data. Among them, 960-group data are divided into 3 subsets for training different working modes. And each subset includes 320-group data. The remaining data are also divided into 3 types for testing. A new group of data is obtained by hourly sampling, which includes connected information working mode. We need to set up different NNMs for each different training set. The whole experiment includes such works as follows. The whole control model mentioned in the paper is called MM-P-VSRVNN.

(1) As NARM is described, building a valid optimized VSRVNN is a key work. It mainly computes node contribution about 95 percent, retains the corresponding nodes, and avoids overfitting learning. VSRVNN is constructed offline with updated training set by PCA, which reduces 60 original hidden-layer nodes to when it works in the *i*th mode. 40 groups of dimension reduction for the testing set are listed in Table 1.

Table 1 shows us that the structure of the VSRVNN is variable at different modes. Even at the same mode, optimized result may not be the same. The value of is changed from 7 to 9, and 8 is the majority. Taking one computation as an example, the first eight principal components’ analysis outcomes are shown in Table 2.

The first eight principal components’ effects are added to more than 95 percent, which are displayed on the VSRVNN. Because its training set changes after one computation, the optimized result is also varied but still meets 95 percent node contribution. (2) For checking the validity of the VSRVNN, we program an algorithm named MM-P-VSRVNN. And contrasting its predicted results to actual values, the total 40 points are shown in Figures 6 and 7.

Two parameters are compared in separated figures. Real line labeled as “” symbol is the actual dosage, and the other line labeled as “” is the predicted dosage. In this test, predicted dosage varies around the actual value and remains consistent with its tendency. Average predicted dosage is reduced about 0.4165 percent in Figure 6; meanwhile, average predicted turbidity increases about 0.5 percent in Figure 7. The simulation result is acceptable for enterprise. To them, it already meets needs of water purification process, reduces total coagulant dosage and saves manufacturing cost to a certain extent. (3) A further test is to analyze the performance of the MM-P-VSRVNN in contrast with other three similar algorithms. Other similar algorithms are single-modal random-vector neural network (SM-RVNN), SM-RVNN after dimension reduction (SM-P-RVNN), and multimodal random-vector neural network (MM-RVNN). All predictive results are in contrast, visually, as shown in Figures 8 and 9.

On the contrary, all the algorithms are in contrast with their statistical parameters, separately named root mean square error (RMSE), mean absolute error (MAE), and standard deviation (SD). The statistical results are computed by different methods and shown in Tables 3 and 4.

These four aforementioned algorithms used the same data set and original mode. In Figure 6, the method provided in this paper has better result accuracy and tendency. It proves that, after quantitative computation, MM-P-VSRVNN can optimize the neural network mode and classify the operating mode that led to a better prediction.

(4) For improving the generalization ability of the MM-P-VSRVNN, NNM takes a new computation once a new group of data is measured. Then, NNM is optimized again because hidden-layer nodes vary. Now, for a further check, the next experiment changes the hidden-layer node number from 1 to 20 and computes RMSE for different algorithms. And these results are compared with those provided by the MM-P-VSRVNN in Figures 10 and 11.

In Figures 10 and 11, MM-P-VSRVNN provided in the paper has lower RMSE and better generalization ability, which can avoid the overfitting problem when the neural network is operating.

Notation: with all the experiments, as we know, the number of hidden-layer nodes takes a new update when a new computation occurs, computation mode is optimized, and the system provides a suitable result. By the way, this computation for RMSE is also operated until hidden-layer nodes increased to 300 one by one, but we found the operating time is too long, and the contrast result is indistinct. Therefore, considering the known information, we set the maximum number as 20.

#### 5. Conclusion

This paper aims at coagulant dosing in water purification process for a water plant in Changsha. After analyzing the actual process and previous control modes, we put up a NNM and applied a new MM-P-VSRVNN algorithm for dosage prediction. This NNM is optimized by the MM-P-VSRVNN algorithm and gives an appropriate control result to perform a new dynamic dosing. At last, we also perform a series of experiments with the designed NNM and its algorithm to prove the practicability. The algorithm provides an improved method, and the coagulant dosing control realizes automatically.

#### Data Availability

All the data used to support the findings of this study are included within the article.

#### Conflicts of Interest

The authors declare no conflicts of interest.

#### Acknowledgments

This study was funded by the Natural Science Foundation of Hunan Province (Grant no. 2018JJ3891).