Received 6 January 2016; accepted 15 February 2016; published 18 February 2016
With the rapid development of social economy, water pollution has become an important environmental monitoring content. The determination of ammonia nitrogen content in water quality is the basic item of water quality monitoring, and is the key index to evaluate water quality. At present, the method of on-line water quality and ammonia nitrogen content determination system  is often used in electrochemical method or the method of spectro photometry. Electrochemical method is based on the electrode sensor, the determination of the size of the ammonia sensor electrode, the indirect determination of ammonia nitrogen content. Nessler’s points spectro photometric method based on light chromaticity determination, mercuric iodide and potassium iodide solution will react with ammonia and will generate red brown compound, chroma and water content of ammonia and nitrogen in a proportional relationship. The main disadvantage of electrochemical detection is that it is easy to interfere with the concentration of ions in water samples, and in the long run, the sensor can easily be contaminated, and the sensitivity of the sensor is obviously decreased. The disadvantages of the method of spectro photometry  are that the reagent cost is relatively high, the determination time is long, the determination data are small, and the determination process is easy to be influenced by the environmental changes and other factors.
The frequently used method to solve the data reliability is to establish a data prediction model. Neural network   , support vector machine  and other forecasting methods can be used to establish data prediction model, but the neural network requires a large number of training sample data, not suitable for the determination of ammonia nitrogen content analysis. Support vector machine is less than the sample data required, suitable for the establishment of data prediction model. Least squares support vector machine (LS-SVM) is the improvement of basic support vector machine (SVM), which can solve the problem of its generalization ability, and it has a better prediction data bias, which has better prediction learning speed, but its prediction robustness is obviously decreased. Weighted least squares support vector machine (WLS-SVM)  based on the standard least squares support vector machine based on the increase of weight components, can get good results and improve the robustness of the algorithm.
This article aims to design the on-line automatic ammonia nitrogen monitoring system. The accuracy of the data fluctuates during measurement of ammonia nitrogen content by spectro-photometry. The weighted least squares support vector machine (WLS-SVM) is applied to the analysis of ammonia nitrogen content, and the model is established to improve the accuracy of the data.
2. Algorithm Principle
Support vector machine is proposed by Vapnik et al. This algorithm is based on the learning theory of limited sample, which is followed by the principle of structural risk minimization. The disadvantage of standard support vector machine is that it is relatively large in the prediction of abnormal data. The least squares support vector machine is based on the standard support vector machine, which is proposed by Suykens  et al. By changing the constraint condition and risk function of SVM, it can be used to improve the shortcomings of standard SVM, but its robustness is reduced. Weighted least squares support vector machine can improve the robustness of the least square support vector machine by adding weights to the error components.
2.1. Support Vector Machine Theory
The training set D with a given sample number is N, and D region is expressed as:, in which x is the input data, y is the output data. Using a nonlinear mapping, the sample data from the
original space to high dimensional feature space is mapped. In this space,
the optimal decision function is constructed:, the parameters & b are to be determined, is weight vector, b is threshold value.
The objective optimization function of support vector machine is:
The error component in above objective optimization function is,; the parameter C is regularization parameter and can be used to balance error and complexity.
2.2. Weighted Least Square Support Vector Machine Theory
The objective optimization function of least squares support vector machine is based on the principle of different structural risk selected.
In order to improve the robustness of the least squares support vector machine algorithm, on the basis of the above optimization function, weights are added   . Lagrange method is used to solve the above optimization function,
In above function, is the multiplier, solving partial derivative, , , ,
Setting it to zero, the optimization problem can be converted into linear equation as follows:
Setting Ω is N × N symmetric matrices, such as (5) formula:
Defined kernel function, conform to (6) formula Mercer condition.
Obtained the model of weighted least squares support vector machine is:
The selected of kernel function can be constructed by different support vector machine, and the radial basis function (RBF) has the characteristics of fast learning speed, and its formula is (8).
The regularization parameter C and kernel width parameter σ are two adjustable parameters of the algorithm, and their values are determined by the generalization performance and learning ability of the algorithm.
We can use the search method to choose the parameters, and then use the cross validation method to find the optimal parameters of the objective function to find the best parameters.
3. Water Quality Online Automatic Ammonia Nitrogen Monitoring System
Water quality online automatic ammonia nitrogen monitoring system, based on the method of nano-determina- tion of ammonia nitrogen content of the measurement, the overall structure of the system is shown in Figure 1. The system is shown in Figure 2. The system is composed of industrial computer, PLC controller, LCD touch screen, spectro-photometer, reactor, metering device, injection pump, multi solenoid valve and all kinds of reagent. Through LCD touch screen display software interface, through the PLC controller, on the other hand, the measurement of the reactive color data of the reactor is used to calculate the content of ammonia nitrogen. The basic working process is as follows:
Figure 1. Overall structure system diagram.
Figure 2. Overall structure of the system.
A) Control of multi pass solenoid valve, access to water samples, drive the injection pump, pump the water samples into the metering device.
B) Once achieve the specified capacity of the metering device, switch to the solenoid valve, pump the water sample from the metering device into the reactor.
C) Switch the multi pass solenoid valve, the masking agent is pumped into the metering device, to achieve the specified capacity, pumping into the reactor.
D) Switch to the solenoid valve, the nano’s reagent is pumped into the metering device, to achieve the specified capacity, pumped into the reactor.
E) Standing 10 minutes, then measure the output of the spectrophotometer, and get the intensity of the measurement.
F) Switch to the solenoid valve, the reactor solution to the liquid bottle.
G) Switch to the solenoid valve, the distilled water is pumped into the metering device, to achieve the specified capacity, pumping into the reactor. Again, the output of the spectrophotometer is measured, and the reference intensity is obtained.
H) After the completion of the reactor, and then the waste water is pumped into the waste liquid bottle. Complete the whole measurement process.
4. Measurement Results and Analysis of the Monitoring System
Water quality monitoring system of on-line automatic ammonia nitrogen, based on the measurement data to calculate the final ammonia nitrogen content, and its input data for measuring the zero point of light intensity, reference intensity and measuring intensity, select the 40 groups of ammonia nitrogen standard solution, its ammonia nitrogen content from 0 mg/L, with 0.25 mg/L increments, until 10 mg/L. A set of measurement results of the monitoring system is used as sample data, the total sample data are 40, the first 20 are training samples, and the 20 is the test sample, and the training sample data are shown in Table 1. Neural network model and WLS-SVM model were used to predict and analyze the experimental results. The experimental results are shown in Table 2.
Table 1. Training sample data sheet.
Table 2. Analysis of the experimental results data sheet.
Figure 3. Comparison of the forecast data with actual measurement results.
Using the neural network model and WLS-SVM model to analyze and forecast the ammonia nitrogen content, the monitoring system of the actual measurement results and the two groups of forecasting data, as shown in Figure 3. According to Table 2, based on neural network model, the maximum relative error is 12.66%, the average relative error is 5.47%. Based on WLS-SVM model, the average relative error is 2.87%, the average relative error is 1.25%, and the accuracy of WLS-SVM model is significantly higher.
This article introduces that during on-line monitoring system on the water quality, the WLS-SVM model is applied to the analysis and prediction of ammonia nitrogen content measurement data. The forecast results compared with the actual results show that the WLS-SVM model is a very effective forecasting model, which can be applied to the actual data analysis and forecasting. WLS-SVM model only needs two changeable model parameters, the regularization parameter C and kernel width parameter, which can be used cross validation method to determine the parameters of the model. The model has a fast convergence speed, high forecast accuracy and wide application prospect.
Sichuan University of Science and Engineering Incubation Project (2012PY12), Artificial Intelligence Key Laboratory Project of Sichuan Province (2013RZY03), Enterprise Informatization and the Internet of Things Measurement and Control Technology Key Laboratory Project (2013WZY04, 2014WYY01), Luzhou Lao Jiao scholarship (15LJZK04).