毛湘云(1994-), 女, 主要从事市政工程研究, E-mail:
Mao Xiangyun (1994-), main research interest: municipal engineering, E-mail:
Xu Bingfeng(corresponding author), associate professor, E-mail:
针对余氯量在供水系统内非线性变化的特性,建立了PSO-SVM与BP神经网络组合模型对管网末端余氯进行预测分析。该模型通过粒子群优化算法(PSO),对SVM的特性参数进行优化;采用BP神经网络对模型进行残差修正。通过对单一的BP模型和SVM模型、组合模型的预测精度进行分析。结果表明:组合模型预测比BP和SVM单一预测均方误差分别降低了62.30%、75.29%,平均相对误差降低了55.03%、54.27%。综上所述,该模型具有强大的非线性拟合能力,预测精度高,运行稳定性强,对供水企业控制余氯的投加量和设置二次加氯点有一定的指导作用。
Due to the nonlinearity of residual chlorine in the pipe network, a PSO-SVM and BP neural network combined model was developed to prediction of residual chlorine.This model through particle swarm optimization algorithm (PSO) to optimization the characteristics parameter of the SVM, and use the BP neural network model to residual error correction. The prediction precision of combined model was ananysed by comparing the single prediction model of BP and SVM. The results show that compared with the single prediction of BP and SVM, the mean square error of the combined model decreased by 62.30% and 75.29% respectively, but the average relative error decreased by 55.03% and 54.27% respectively. In a conclusion, the combined model had strong nonlinear fitting capability, high prediction accuracy, and strong operation stability. This model plays an important role in controlling the residual chlorine dosing and setting the secondary chlorination point for water supply enterprise.
氯是供水处理中使用最广泛的一种消毒剂,余氯作为衡量管网水质的一项重要指标,对控制水中的细菌滋生,保证管网水质安全十分重要。《生活饮用水卫生标准》(GB 5749—2006)[
由于余氯浓度在管网中的削减是非线性变化,且管网内影响余氯的因素众多,若采用机理性模型进行预测,其准确性差,建立难度大,求解困难[
支持向量机(Support Vector Machine)是基于统计学理论发展起来的机器学习算法[
由于管网内余氯浓度成非线性变化,管网末端的余氯浓度,受到多种因素的影响。供水管网中余氯浓度主要受到上游监测点出厂水的余氯浓度、浊度、管网输配时间、管道内的腐蚀程度、PH值、管网材料和细菌总数的影响[
对某水厂的187个数据样本进行随机排列,取不同的组合方式对模型进行训练,最终确定将数据分为2部分,85%的数据作为训练数据,均分为各含有80个数据,分别建立PSO-SVM模型和BP残差模型;剩下的27个数据作为验证数据,进行交叉验证,以验证组合模型精度。末端取样点距离水厂的直线距离为2.4 km,末端余氯浓度范围为0.02~0.06 mg/L,每个样本内都含有出厂余氯浓度、pH值、浊度及管网末端取样点余氯浓度。由于数据指标不相同,数量级有一定的差别,为方便计算,需要对样本数据进行归一化处理,使数据值都归一至[0, 1]之间,归一化公式为
将第1组归一化后的出厂水的余氯浓度、pH值及浊度设为输入值,管网末端出水余氯浓度作为输出值,输入到SVM模型内进行训练。首先,通过高斯径向核函数
式中:
式中:
因此,可以定义如式(4)所示的Lagrange函数求解上述优化问题,即
式中:
将式(5)带入式(4), 将
式中:
对于SVM参数选取的盲目性,采用PSO算法进行优化。数据进行初始化参数设定,生成随机粒子,创建一个二维空间,粒子群规模为10。其中,第
其中:
粒子群迭代曲线
Particle swarm optimization algorithm iteration curve
得到其最优参数为:均方误差mse=1.217,核函数参数
为进一步提高模型的精度,采用BP神经网络进行残差修正。用PSO-SVM模型对第2组数据进行预测,将预测值记录下来。以第2组数据中出厂水余氯量、出厂浊度和出厂pH值作为输入值
BP神经网络系统残差修正结构
Residual correction structure of BP neural network system
对网络输入层、隐含层和输出层神经元之间的连接权值
根据输入的变量
再采用logsig函数作为隐含层到输出层的传递函数,计算BP神经网络的预测输出
用期望输出
设置输出层传递函数为logsig函数,训练函数为trainlm函数,精度取0.000 000 001,学习率为0.1%,训练次数1 000次,经过试验确定,隐含层数为16时,模型的均方误差最小,实验结果见
组合算法不同隐含层的均方误差
The MSE of different hidden layers in combination algorithm
由此建立了3-16-1结构的BP神经网络残差模型,其中,
将第3组数据带入上述PSO-SVM模型和BP神经网络残差模型内,验证组合模型的预测效果,由PSO-SVM模型得到管网末端余氯预测值
组合模型结构图
Combined model flow chart
将第3组数据作为预测输入组合模型,并以相同的输入输出,分别输入BP神经网络和PSO-SVM模型中对余氯进行预测,以验证组合模型的预测效果,预测结果如
各算法预测结果比较
Prediction results comparison for different arithmetic
由
模型模拟精度对比
Comparison of model simulation precision
模型类型 | 平均绝对误差 | 均方误差 | 平均相对误差/% | 最大相对误差/% | |
组合模型 | 4.5×10-3 | 4.2×10-5 | 0.84 | 13.32 | 58.11 |
SVM模型 | 1.1×10-2 | 1.7×10-4 | 0.67 | 29.13 | 75.35 |
BP模型 | 9.2×10-3 | 1.3×10-4 | 0.72 | 29.62 | 107.80 |
从
通过PSO算法优化SVM模型参数,并使用BP神经网络对模型结果进行残差修正,建立了PSO-SVM+BP神经网络余氯预测模型,找到多个因素与管网末端余氯的关系,通过不同模型产生的误差进行模型性能的对比分析。发现该模型可以实现对管网末端余氯量的预测,有效地简化了余氯在管网中衰减变化的复杂非线性关系,克服了SVM模型参数选择的盲目性,利用BP网络对结果进行优化,进一步提升了预测的精度和模型运行的稳健性。结果表明,该模型具有良好的预测性能,能够使供水企业更早地发现水质恶化的趋势,及时采取相关措施,在控制末端水水质的前提下,降低消毒副产物的产生,并为二次消毒点的选取提供参考。参考文献:
卫生部.生活饮用水卫生标准[J].经济管理文摘, 2006(11):36-38.
Ministry of Health. Standards for drinking water quality[J].Economic Management Digest, 2006(11):36-38.
周广宇, 莫罹, 赵新华, 等.基于多组分水质模型的供水管网细菌风险研究[J].中国给水排水, 2016, 32(5):64-69, 73.
ZHOU G Y, MO L, ZHAO X H, et al. Assessment of bacteria risk in water distribution system based on multispecies water quality model[J]. China Water & Wastewater, 2016, 32(5):64-69, 73.(in Chinese)
杨航, 李敏, 俞国平.基于人工神经网络的市政管网水质模型研究[J].给水排水, 2012, 48(Sup1):471-475.
YANG H, LI M, YU G P. Water quality model of municipal network based on artificial neural network[J]. Water & Wastewater Engineering, 2012, 48(Sup1):471-475.(in Chinese)
戴舒, 郭姣.南方某市供水管网水质模型的建立与校核[J].供水技术, 2017, 11(4):29-32.
DAI S, GUO J.Establishment and calibration of water quality model for water distribution system in a city of South China[J]. Water Technology, 2017, 11(4):29-32.
刘国红, 廖玉学, 黄广文, 等.深圳市2016年生活饮用水水质影响因素[J].中国热带医学, 2018, 18(1):72-75.
LIU G H, LIAO Y X, HUANG G W, et al. Factors influencing drinking water quality in Shenzhen, 2016[J]. China Tropical Medicine, 2018, 18(1):72-75.(in Chinese)
谢昕, 郭鹏飞, 詹小丽, 等.基于RBF神经网络的余氯浓度预测模型研究[J].传感器与微系统, 2012, 31(8):64-65, 68.
XIE X, GUO P F, ZHAN X L, et al. Research on prediction model of residual chlorine concentration based on RBF neural network[J]. Transducer and Microsystem Technologies, 2012, 31(8):64-65, 68.(in Chinese)
BOWDEN G J, NIXON J B, DANDY G C, et al. Forecasting chlorine residuals in a water distribution system using a general regression neural network[J]. Mathematical and Computer Modelling, 2006, 44(5/6):469-484.
何自立, 王云霏, 马孝义, 等.基于改进PSO-WNN模型的管网余氯预测研究[J].中国农村水利水电, 2015(2):86-88, 92.
HE Z L, WANG Y F, MA X Y, et al. Residual chlorine prediction in water supply system based on improved PSO-WNN model[J]. China Rural Water and Hydropower, 2015(2):86-88, 92.(in Chinese)
何自立, 郭占娟, 杨建国, 等.基于PSO-SVR模型的供水系统余氯预测研究[J].长江科学院院报, 2015, 32(10):6-10.
HE Z L, GUO Z J, YANG J G, et al. Residual chlorine prediction in water supply system based on support vector machine regression model optimized by PSO method[J]. Journal of Yangtze River Scientific Research Institute, 2015, 32(10):6-10.(in Chinese)
谢芳, 唐德善.农业灌溉用水量的LS-SVM预测模型研究[J].安徽农业科学, 2010, 38(19):10273-10275, 10288.
XIE F, TANG D S. Forecasting irrigation water requirement based on least squares support vector machine[J]. Journal of Anhui Agricultural Sciences, 2010, 38(19):10273-10275, 10288.(in Chinese)
ABHISEK U. Support vector machine[J]. Computer Science, 2002, 1(4):1-28.
SUN L F, ZHANG Y Y, SAQI R N. Research on the fouling prediction of heat exchanger based on support vector machine optimized by particle swarm optimization algorithm[C]//2009 International Conference on Mechatronics and Automation, Changchun, China, 2009: 2002-2007
EBERHART R C, SHI Y H. Comparison between genetic algorithms and particle swarm optimization[M]. Evolutionary Programming Ⅶ Springer Berlin Heidelberg, 1998:611-616.
LIU J, LIU Z, XIONG Y. Method of parameters optimization in SVM based on PSO[J]. Transactions on Computer Science & Technology, 2013, 2(1):9-16.
党安朋, 刘占峰, 朱延玲, 等.基于BP与Elman神经网络的发动机缸壁间隙检测[J].山东交通学院学报, 2015, 23(1):1-5.
DANG A P, LIU Z F, ZHU Y L, et al. The detection of engine cylinder wall clearance based on BP and elman neural network[J]. Journal of Shandong Jiaotong University, 2015, 23(1):1-5.(in Chinese)
陈明. MATLAB神经网络原理与实例精解[M].北京:清华大学出版社, 2013.
CHEN M. Principles and examples of MATLAB neural network[M]. Beijing:Tsinghua University dress, 2013.
WANG J J, SHI P, JIANG P, et al. Application of BP neural network algorithm in traditional hydrological model for flood forecasting[J]. Water, 2017, 9(1):48.
LI C, YU J, ZHANG T, et al. The effect of factors on chlorine decay and trihalomethane formation in a pilot-scale distribution system[J]. Fresenius Environmental Bulletin, 2014, 23(1):223-227.
POWELL J C, HALLAM N B, WEST J R, et al. Factors which control bulk chlorine decay rates[J]. Water Research, 2000, 34(1):117-126.
钟丹, 袁一星, 马文成, 等.供水管网内生物膜与余氯衰减交互作用[J].哈尔滨工业大学学报, 2017, 49(8):49-54.
ZHONG D, YUAN Y X, MA W C, et al. Interaction effects between biofilm and chlorine decay in water distribution network[J]. Journal of Harbin Institute of Technology, 2017, 49(8):49-54.(in Chinese)
郝艳萍.余氯衰减一级模型参数确定方法试验研究[D].哈尔滨: 哈尔滨工业大学, 2016.
HAO Y P. Study on method of the first order chlorine decay model parameters determination[D]. Harbin: Harbin Institute of Technology, 2016.(in Chinese)
黄锐, 李翠梅, 罗贤达, 等.影响供水管网中余氯与浊度的因素及相关性分析[J].给水排水, 2015, 51(5):147-151.
HUANG R, LI C M, LUO X D, et al. Factors and correlation analysis of residual chlorine and turbidity in water supply pipe network[J].Water & Wastewater Engineering, 2015, 51(5):147-151.
田一梅, 吴迷芳, 王阳, 等.基于SVR的城市供水管网余氯预测分析[J].重庆建筑大学学报, 2006, 28(2):74-78.
TIAN Y M, WU M F, WANG Y, et al. Prediction and analyses of residual chlorine based on support vector regression in urban water distribution system[J]. Journal of Chongqing Jianzhu University, 2006, 28(2):74-78.(in Chinese)