本發(fā)明屬于無線傳感器網(wǎng)絡(luò)(WSN)數(shù)據(jù)可靠性檢測(cè)技術(shù)領(lǐng)域,具體是涉及一種基于MEA-BP神經(jīng)網(wǎng)絡(luò)WSN異常檢測(cè)方法。
背景技術(shù):
無線傳感器網(wǎng)絡(luò)(WSN)作為一種無線自組織網(wǎng)絡(luò),無線傳感器網(wǎng)絡(luò)具有低能耗、節(jié)點(diǎn)分別靈活、甚至無需人工維護(hù),可以在惡劣環(huán)境中長(zhǎng)時(shí)間工作等特點(diǎn)。通過將傳感器網(wǎng)絡(luò)節(jié)點(diǎn)散布在目標(biāo)監(jiān)測(cè)區(qū)域中,進(jìn)行環(huán)境數(shù)據(jù)的采集以及特定事件的監(jiān)測(cè)是目前最為普遍的應(yīng)用之一。由于無線傳感器節(jié)點(diǎn)資源有限,又容易受到外界因素的干擾和破壞,或者外部環(huán)境突發(fā)事件的影響,節(jié)點(diǎn)采集到的數(shù)據(jù)很有可能與正常情況下的環(huán)境特征產(chǎn)生明顯偏差,這類數(shù)據(jù)稱為異常數(shù)據(jù)。因此,設(shè)計(jì)一種有效的異常檢測(cè)方法是近年來無線傳感器網(wǎng)絡(luò)異常檢測(cè)研究的重點(diǎn)。
傳統(tǒng)BP神經(jīng)網(wǎng)絡(luò)在訓(xùn)練學(xué)習(xí)時(shí)許多參數(shù)的選擇沒有理論依據(jù),使得實(shí)際的神經(jīng)網(wǎng)絡(luò)應(yīng)用具有局限性,存在不足之處主要有學(xué)習(xí)速度慢、容錯(cuò)能力差、會(huì)收斂于局部極小值等。以用于環(huán)境監(jiān)測(cè)無線傳感器網(wǎng)絡(luò)節(jié)點(diǎn)為例,無線傳感器網(wǎng)絡(luò)節(jié)點(diǎn)采集到的溫度數(shù)據(jù)無論是波動(dòng)的幅度、頻率,或者均值、中值、方差等統(tǒng)計(jì)特征都會(huì)和同一采樣時(shí)間段內(nèi)的其他數(shù)據(jù)有明顯的差異,如果不考慮不同類型數(shù)據(jù)之間的差異性,無疑會(huì)影響檢測(cè)算法的性能,想要更精確的判斷數(shù)據(jù)異常,除了數(shù)據(jù)自身的時(shí)間相關(guān)性還要考慮空間相關(guān)性。另外,針對(duì)無線傳感器網(wǎng)絡(luò)環(huán)境數(shù)據(jù)的異常檢測(cè)問題,BP神經(jīng)網(wǎng)絡(luò)算法存在容易陷入局部最優(yōu)解、訓(xùn)練時(shí)間長(zhǎng)、效率低等問題。
技術(shù)實(shí)現(xiàn)要素:
發(fā)明目的:為了克服現(xiàn)有技術(shù)中存在的不足,本發(fā)明提供一種基于MEA-BP神經(jīng)網(wǎng)絡(luò)WSN異常檢測(cè)方法,針對(duì)BP神經(jīng)網(wǎng)絡(luò)算法存在容易陷入局部最優(yōu)解、訓(xùn)練時(shí)間長(zhǎng)、效率低等問題,利用思維進(jìn)化算法對(duì)BP神經(jīng)網(wǎng)絡(luò)進(jìn)行改進(jìn),提高了BP神經(jīng)網(wǎng)絡(luò)算法性能,加快了BP神經(jīng)網(wǎng)絡(luò)的學(xué)習(xí)速率,有效提高了異常數(shù)據(jù)檢測(cè)的準(zhǔn)確率,降低了誤報(bào)率。
技術(shù)方案:為實(shí)現(xiàn)上述目的,本發(fā)明的基于MEA-BP神經(jīng)網(wǎng)絡(luò)WSN異常檢測(cè)方法,所述方法包括以下步驟:
S1將各分布傳感器節(jié)點(diǎn)初始化,各傳感器節(jié)點(diǎn)開始采集數(shù)據(jù);
設(shè)傳感器節(jié)點(diǎn)個(gè)數(shù)為n,各傳感器節(jié)點(diǎn)為Xtj(j=1,2,…,n),傳感器節(jié)點(diǎn)Xtj的滑動(dòng)窗口為Wj,各傳感器節(jié)點(diǎn)的滑動(dòng)窗口大小均為m,則傳感器節(jié)點(diǎn)Xtj在其滑動(dòng)窗口Wj上的測(cè)量數(shù)據(jù)序列為傳感器節(jié)點(diǎn)Xtj在tp時(shí)刻采集的數(shù)據(jù)為該數(shù)據(jù)包括h個(gè)屬性測(cè)量值,則
S2利用K-means算法對(duì)各傳感器節(jié)點(diǎn)進(jìn)行空間劃分得到若干組分簇;
設(shè)q+1個(gè)傳感器節(jié)點(diǎn)組成一組分簇,每組分簇中包括1個(gè)簇頭節(jié)點(diǎn)Xtc和q個(gè)分布節(jié)點(diǎn)(Xt1,Xt2,…,Xtq);
S3利用思維進(jìn)化算法對(duì)BP神經(jīng)網(wǎng)絡(luò)進(jìn)行參數(shù)優(yōu)化,通過趨同異化操作對(duì)BP神經(jīng)網(wǎng)絡(luò)的權(quán)值和閾值進(jìn)行優(yōu)化,得到最優(yōu)權(quán)值和閾值,輸入最優(yōu)權(quán)值和閾值,建立MEA-BP神經(jīng)網(wǎng)絡(luò)模型;
S4采用分布式的算法,對(duì)每組分簇中傳感器節(jié)點(diǎn)(Xt1,Xt2,…,Xtq)獨(dú)立執(zhí)行異常檢測(cè),異常檢測(cè)完畢后傳感器節(jié)點(diǎn)(Xt1,Xt2,…,Xtq)將檢測(cè)結(jié)果傳遞到該組分簇的簇頭節(jié)點(diǎn)Xtc進(jìn)一步驗(yàn)證。
進(jìn)一步地,所述步驟S2包括以下步驟:
S21首先從目標(biāo)監(jiān)測(cè)區(qū)域分布傳感器節(jié)點(diǎn)對(duì)象中任意選擇K個(gè)傳感器節(jié)點(diǎn)對(duì)象作為K個(gè)聚類中心;
S22然后針對(duì)除聚類中心以外的傳感器節(jié)點(diǎn)對(duì)象,分別計(jì)算傳感器節(jié)點(diǎn)對(duì)象與K個(gè)聚類中心之間的相似度,得到與傳感器節(jié)點(diǎn)對(duì)象相似度最接近的聚類中心;
S23將傳感器節(jié)點(diǎn)對(duì)象分配給與該傳感器節(jié)點(diǎn)對(duì)象相似度最接近的聚類中心的聚類,將所有傳感器節(jié)點(diǎn)分配完成后得到K個(gè)聚類;
S24重新計(jì)算該K個(gè)聚類的聚類中心,得到新的聚類中心;
S25重新計(jì)算各傳感器節(jié)點(diǎn)與新的聚類中心的相似度,回到步驟S22;
S26當(dāng)重新計(jì)算的聚類中心收斂時(shí),結(jié)束本操作。
進(jìn)一步地,所述步驟S3包括以下步驟:產(chǎn)生訓(xùn)練數(shù)據(jù);確定BP神經(jīng)網(wǎng)絡(luò)拓?fù)浣Y(jié)構(gòu);通過思維進(jìn)化算法進(jìn)行參數(shù)設(shè)置;隨機(jī)產(chǎn)生初始種群、優(yōu)勝子種群和臨時(shí)子種群;對(duì)子種群進(jìn)行趨同操作;對(duì)子種群進(jìn)行異化操作;判斷是否滿足結(jié)束條件,如果滿足,則輸出最優(yōu)個(gè)體,獲取最優(yōu)權(quán)值和閾值,否則重新進(jìn)行趨同異化操作。
進(jìn)一步地,所述步驟S4包括以下步驟:
S41通過時(shí)間相關(guān)性對(duì)傳感器節(jié)點(diǎn)(Xt1,Xt2,…,Xtq)獨(dú)立執(zhí)行異常檢測(cè),利用每個(gè)當(dāng)前時(shí)刻通過傳感器節(jié)點(diǎn)Xtj滑動(dòng)窗口Wj的數(shù)據(jù)來訓(xùn)練神經(jīng)網(wǎng)絡(luò),完成下一時(shí)刻數(shù)據(jù)的預(yù)報(bào),選取訓(xùn)練數(shù)據(jù)的后v個(gè)樣本數(shù)據(jù),通過公式(1)計(jì)算MEA-BP神經(jīng)網(wǎng)絡(luò)的模型殘差S:
其中,Er(r=1,2,…,v)為選取的樣本數(shù)據(jù)值,F(xiàn)為選取的樣本數(shù)據(jù)平均值,
S42計(jì)算傳感器節(jié)點(diǎn)當(dāng)前時(shí)刻的置信區(qū)間,置信區(qū)間為其中Spre為MEA-BP神經(jīng)網(wǎng)絡(luò)對(duì)下一時(shí)刻數(shù)據(jù)的預(yù)測(cè)值,tα/2,v-1為自由度v-1的t分布,在t分布表中選取合適的α值,得到t值;
S43當(dāng)下一時(shí)刻數(shù)據(jù)Snew進(jìn)入傳感器節(jié)點(diǎn)滑動(dòng)窗口內(nèi)時(shí),判斷下一時(shí)刻數(shù)據(jù)Snew是否落入當(dāng)前時(shí)刻的置信區(qū)間范圍內(nèi),若是,則判斷該數(shù)據(jù)Snew為正常數(shù)據(jù);否則判斷該數(shù)據(jù)Snew為異常數(shù)據(jù);
S44異常檢測(cè)完畢后傳感器節(jié)點(diǎn)(Xt1,Xt2,…,Xtq)將檢測(cè)結(jié)果傳遞到該組分簇的簇頭節(jié)點(diǎn)Xtc中;
S45簇頭節(jié)點(diǎn)Xtc通過空間相關(guān)性檢測(cè)并引入投票機(jī)制驗(yàn)證傳感器節(jié)點(diǎn)異常數(shù)據(jù)產(chǎn)生原因,原因包括事件異常、節(jié)點(diǎn)故障異常和誤判。
進(jìn)一步地,所述步驟S42中,選取α=0.05。
進(jìn)一步地,所述步驟S45中進(jìn)行空間相關(guān)性檢測(cè)并引入投票機(jī)制包括以下步驟:
S451將傳感器節(jié)點(diǎn)的異常數(shù)據(jù)和與該傳感器節(jié)點(diǎn)在同一分簇中的其他節(jié)點(diǎn)數(shù)據(jù)進(jìn)行比較;設(shè)q+1個(gè)傳感器節(jié)點(diǎn)組成一組分簇,每組分簇中包括1個(gè)簇頭節(jié)點(diǎn)Xtc和q個(gè)分布節(jié)點(diǎn)(Xt1,Xt2,…,Xtq);
S452預(yù)先設(shè)定誤差值θ,設(shè)傳感器節(jié)點(diǎn)的異常數(shù)據(jù)為ST,設(shè)與該傳感器節(jié)點(diǎn)在同一分簇中的其他節(jié)點(diǎn)的數(shù)據(jù)為Si(i=1,2,…,q-1),若|ST-Si|<θ,則初始值為0的計(jì)數(shù)NN加1,統(tǒng)計(jì)最終的NN值;
S453若則判斷該檢測(cè)節(jié)點(diǎn)異常數(shù)據(jù)是由于事件異常;若則判斷該檢測(cè)節(jié)點(diǎn)異常數(shù)據(jù)是由于節(jié)點(diǎn)故障或誤判;若則選取該分簇中的參照節(jié)點(diǎn),設(shè)參照節(jié)點(diǎn)的數(shù)據(jù)為SCC,若|ST-SCC|≤θ,則判斷該傳感器節(jié)點(diǎn)異常數(shù)據(jù)是由于事件異常,若|ST-SCC|>θ,則判斷該傳感器節(jié)點(diǎn)異常數(shù)據(jù)是由于節(jié)點(diǎn)故障或誤判;其中參照節(jié)點(diǎn)為距離該分簇中聚類中心節(jié)點(diǎn)歐氏距離最近的節(jié)點(diǎn);
S454對(duì)于所述步驟S453中,當(dāng)判斷得到該傳感器節(jié)點(diǎn)異常數(shù)據(jù)是由于節(jié)點(diǎn)故障或誤判時(shí),進(jìn)一步判斷該傳感器節(jié)點(diǎn)異常數(shù)據(jù)是由于節(jié)點(diǎn)故障還是誤判,具體包括以下步驟:通過對(duì)傳感器節(jié)點(diǎn)進(jìn)行時(shí)間相關(guān)性檢測(cè),當(dāng)傳感器節(jié)點(diǎn)連續(xù)時(shí)間內(nèi)均產(chǎn)生異常數(shù)據(jù),則判斷該傳感器節(jié)點(diǎn)異常數(shù)據(jù)是由于節(jié)點(diǎn)故障;當(dāng)傳感器節(jié)點(diǎn)只有該時(shí)刻為異常數(shù)據(jù),其他時(shí)刻產(chǎn)生數(shù)據(jù)均為正常數(shù)據(jù),則判斷該傳感器節(jié)點(diǎn)異常數(shù)據(jù)是由于誤判。
有益效果:本發(fā)明與現(xiàn)有技術(shù)比較,具有的優(yōu)點(diǎn)是:
傳統(tǒng)BP神經(jīng)網(wǎng)絡(luò)算法存在容易陷入局部最優(yōu)解、訓(xùn)練時(shí)間長(zhǎng)、效率低等問題,難以滿足檢測(cè)需求,本發(fā)明提出的利用思維進(jìn)化算法對(duì)BP神經(jīng)網(wǎng)絡(luò)進(jìn)行改進(jìn)以提高BP神經(jīng)網(wǎng)絡(luò)算法性能,在處理多維數(shù)據(jù)時(shí)利用傳感器網(wǎng)路數(shù)據(jù)流之間的事件相關(guān)性和不同節(jié)點(diǎn)之間的空間相關(guān)性,從而有效提高了異常數(shù)據(jù)檢測(cè)的準(zhǔn)確率;
與常規(guī)的BP神經(jīng)網(wǎng)絡(luò)相比,本文方法通過優(yōu)化權(quán)值和閾值之后加快了BP神經(jīng)網(wǎng)絡(luò)的學(xué)習(xí)速率,提高了異常檢測(cè)率,降低了誤判率。
附圖說明
圖1是t分布表示意圖。
圖2是k-means聚類算法流程圖。
圖3是MEA優(yōu)化BP神經(jīng)網(wǎng)絡(luò)權(quán)值閾值流程圖。
圖4是MEA-BP神經(jīng)網(wǎng)絡(luò)異常數(shù)據(jù)檢測(cè)流程圖。
具體實(shí)施方式
下面結(jié)合附圖對(duì)本發(fā)明作更進(jìn)一步的說明。
本發(fā)明提出了一種基于MEA-BP神經(jīng)網(wǎng)絡(luò)WSN異常檢測(cè)方法,在介紹本發(fā)明方法之前,首先介紹一些定義:
1、傳感器網(wǎng)絡(luò)模型,在分布式傳感器網(wǎng)絡(luò)中,設(shè)傳感器節(jié)點(diǎn)個(gè)數(shù)為n,各傳感器節(jié)點(diǎn)為Xtj(j=1,2,…,n)。
2、時(shí)間序列數(shù)據(jù),是由傳感器節(jié)點(diǎn)按時(shí)間順序產(chǎn)生的一系列序列數(shù)據(jù),它的特點(diǎn)是變化快、大量和連續(xù)到達(dá)的。所以在建立檢測(cè)模型之前,首先要引入滑動(dòng)窗口機(jī)制,利用滑動(dòng)窗口來觀察最近一個(gè)時(shí)間段內(nèi)數(shù)據(jù)的變化情況,在滑動(dòng)窗口內(nèi)部進(jìn)行異常值檢測(cè)。
3、滑動(dòng)窗口模型,滑動(dòng)窗口模型是用來觀察最近一個(gè)采樣時(shí)間段內(nèi)的時(shí)間序列數(shù)據(jù),方法是對(duì)傳感器數(shù)據(jù)取一固定長(zhǎng)度的滑動(dòng)窗口,通過處理新加入和剛離開的數(shù)據(jù)降低時(shí)間復(fù)雜度;在分布式傳感器網(wǎng)絡(luò)中,設(shè)傳感器節(jié)點(diǎn)個(gè)數(shù)為n,各傳感器節(jié)點(diǎn)為Xtj(j=1,2,…,n),傳感器節(jié)點(diǎn)Xtj的滑動(dòng)窗口為Wj,各傳感器節(jié)點(diǎn)的滑動(dòng)窗口大小均為m,則傳感器節(jié)點(diǎn)Xtj在其滑動(dòng)窗口Wj上的測(cè)量數(shù)據(jù)序列為傳感器節(jié)點(diǎn)Xtj在tp時(shí)刻采集的數(shù)據(jù)為該數(shù)據(jù)包括h個(gè)屬性測(cè)量值,則
4、檢測(cè)率,是指算法檢測(cè)到的異常數(shù)據(jù)樣本數(shù)與實(shí)際的異常數(shù)據(jù)樣本總數(shù)之比。
5、誤報(bào)率,是指被算法誤判為異常的正常數(shù)據(jù)樣本數(shù)與總的正常數(shù)據(jù)樣本數(shù)之比。
本發(fā)明以傳感器節(jié)點(diǎn)的時(shí)空相關(guān)性為基礎(chǔ),使用K-means算法對(duì)空間節(jié)點(diǎn)進(jìn)行分簇,將數(shù)據(jù)相似的傳感器節(jié)點(diǎn)劃分到同一個(gè)簇中,然后提出基于MEA-BP神經(jīng)網(wǎng)絡(luò)WSN異常檢測(cè)方法,該方法主要分為參數(shù)優(yōu)化、異常數(shù)據(jù)的檢測(cè)和數(shù)據(jù)異常的判定三個(gè)步驟,其主要特點(diǎn)有:(1)使用思維進(jìn)化算法對(duì)BP神經(jīng)網(wǎng)絡(luò)進(jìn)行參數(shù)優(yōu)化,通過趨同異化等操作對(duì)BP神經(jīng)網(wǎng)絡(luò)的權(quán)值、閾值等進(jìn)行優(yōu)化;(2)在異常數(shù)據(jù)的檢測(cè)階段主要對(duì)傳感器節(jié)點(diǎn)采集到的數(shù)據(jù)流中可能存在的異常數(shù)據(jù)點(diǎn)進(jìn)行識(shí)別,該步驟采用分布式的算法,在各傳感器節(jié)點(diǎn)獨(dú)立執(zhí)行,然后各傳感器節(jié)點(diǎn)將結(jié)果傳遞到簇頭節(jié)點(diǎn)進(jìn)一步地驗(yàn)證;(3)異常數(shù)據(jù)檢測(cè)時(shí)提出每個(gè)當(dāng)前時(shí)刻通過傳感器節(jié)點(diǎn)滑動(dòng)窗口的歷史數(shù)據(jù)集訓(xùn)練神經(jīng)網(wǎng)絡(luò),來完成下一時(shí)刻的預(yù)報(bào),通過神經(jīng)網(wǎng)絡(luò)的模型殘差,確定用于判斷下一時(shí)刻數(shù)據(jù)異常的置信區(qū)間,當(dāng)下一時(shí)刻數(shù)據(jù)落入置信區(qū)間內(nèi),則該數(shù)據(jù)誒判定為正常,反之,該數(shù)據(jù)在簇頭節(jié)點(diǎn)中通過空間相關(guān)性進(jìn)一步地驗(yàn)證,具體的該方法包括以下步驟:
將各分部傳感器節(jié)點(diǎn)初始化,各傳感器節(jié)點(diǎn)開始采集數(shù)據(jù),設(shè)傳感器節(jié)點(diǎn)個(gè)數(shù)為n,各傳感器節(jié)點(diǎn)為Xtj(j=1,2,…,n),傳感器節(jié)點(diǎn)Xtj的滑動(dòng)窗口為Wj,各傳感器節(jié)點(diǎn)的滑動(dòng)窗口大小均為m,則傳感器節(jié)點(diǎn)Xtj在其滑動(dòng)窗口Wj上的測(cè)量數(shù)據(jù)序列為傳感器節(jié)點(diǎn)Xtj在tp時(shí)刻采集的數(shù)據(jù)為該數(shù)據(jù)包括h個(gè)屬性測(cè)量值,則
利用K-means算法對(duì)各傳感器節(jié)點(diǎn)進(jìn)行空間分簇得到若干組簇,將數(shù)據(jù)相似的傳感器節(jié)點(diǎn)劃分到同一個(gè)簇中,提高簇內(nèi)節(jié)點(diǎn)空間相似度,該工作在節(jié)點(diǎn)故障檢測(cè)前完成,完成后再對(duì)節(jié)點(diǎn)采集數(shù)據(jù)進(jìn)行時(shí)間相關(guān)性檢測(cè)和空間相關(guān)性檢測(cè),在空間相關(guān)性檢測(cè)時(shí)利用前面空間劃分的結(jié)果,傳感器節(jié)點(diǎn)對(duì)當(dāng)前時(shí)刻采集的數(shù)據(jù)先進(jìn)行時(shí)間相關(guān)性檢測(cè),當(dāng)時(shí)間相關(guān)性檢測(cè)顯示有問題時(shí),則該傳感器節(jié)點(diǎn)將可疑數(shù)據(jù)告知簇頭節(jié)點(diǎn),簇頭節(jié)點(diǎn)對(duì)該數(shù)據(jù)進(jìn)行空間相關(guān)性檢測(cè);參照?qǐng)D2,基本思想是:首先從傳感器節(jié)點(diǎn)對(duì)象中任意挑選K個(gè)對(duì)象作為聚類中心,對(duì)于剩下的傳感器節(jié)點(diǎn),則根據(jù)它們與被挑選出來的聚類中心的相似度(歐氏距離),分別將傳感器節(jié)點(diǎn)分配給與其最相似的聚類中心的聚類,然后再計(jì)算每個(gè)新聚類的聚類中心(該聚類中所有對(duì)象的均值),不斷重復(fù)這一過程直到聚類中心開始收斂為止;
K-means算法步驟如下:
設(shè)傳感器節(jié)點(diǎn)數(shù)目為p,傳感器節(jié)點(diǎn)的坐標(biāo)為{x(1),x(2),…,x(p)},每個(gè)x(i)(i=1,2,…,p)∈R;
步驟1,隨機(jī)選取K個(gè)傳感器節(jié)點(diǎn)作為聚類中心,K個(gè)聚類中心的坐標(biāo)為u(j)(j=1,2,…,k)∈R,K個(gè)聚類中心對(duì)應(yīng)K個(gè)聚類;
步驟2,重復(fù)下面的過程直到聚類中心收斂
{
對(duì)于每個(gè)傳感器節(jié)點(diǎn)樣例i,計(jì)算其應(yīng)該屬于的聚類,公式如下:
c(i):=argminj||x(i)-u(j)||2 公式(2)
對(duì)于每個(gè)聚類j,重新計(jì)算該聚類的聚類中心,公式如下:
公式(2)中u(j)代表K個(gè)聚類中心中的一個(gè),通過不斷調(diào)整參數(shù)j(j=1,2,…,k),使得每一個(gè)點(diǎn)的開銷函數(shù)c(i)達(dá)到最小值,c(i)代表傳感器節(jié)點(diǎn)樣例i與K個(gè)聚類中心中距離最近的聚類,把每一個(gè)點(diǎn)劃分到距離其最近的一個(gè)聚類中心的聚類;
公式(3)中分母表示每個(gè)聚類中樣本的總數(shù),分子是每個(gè)聚類中傳感器節(jié)點(diǎn)樣例i對(duì)應(yīng)的坐標(biāo)和。
最終得到若干組簇,設(shè)q+1個(gè)傳感器節(jié)點(diǎn)組成一組分簇,每組分簇中包括1個(gè)簇頭節(jié)點(diǎn)Xtc和q個(gè)分布節(jié)點(diǎn)(Xt1,Xt2,…,Xtq);
利用思維進(jìn)化算法對(duì)BP神經(jīng)網(wǎng)絡(luò)進(jìn)行參數(shù)優(yōu)化,通過趨同異化操作對(duì)BP神經(jīng)網(wǎng)絡(luò)的權(quán)值和閾值進(jìn)行優(yōu)化,得到最優(yōu)權(quán)值和閾值,輸入最優(yōu)權(quán)值和閾值,建立MEA-BP神經(jīng)網(wǎng)絡(luò)模型,優(yōu)化BP神經(jīng)網(wǎng)絡(luò)的流程如圖3所示,大致步驟如下:
步驟1:思維進(jìn)化初始群體產(chǎn)生,在解空間隨機(jī)產(chǎn)生N組數(shù)作為初始群體,每組數(shù)中包含n個(gè)元素代表一個(gè)個(gè)體(即神經(jīng)網(wǎng)絡(luò)結(jié)構(gòu)),每一個(gè)個(gè)體的矩陣為1*n,群體矩陣為N*n,群體包含N個(gè)個(gè)體;
步驟2:根據(jù)BP神經(jīng)網(wǎng)絡(luò)拓?fù)浣Y(jié)構(gòu),將解空間映射到編碼空間,每個(gè)編碼空間對(duì)應(yīng)問題的一個(gè)解,即一個(gè)個(gè)體,編碼長(zhǎng)度等于每個(gè)個(gè)體中的元素?cái)?shù)目,編碼長(zhǎng)度n為
n=tL+wL+L+w 公式(4)
公式(4)中,t為神經(jīng)網(wǎng)絡(luò)輸入節(jié)點(diǎn)數(shù),w為輸出節(jié)點(diǎn)數(shù),L為隱含層節(jié)點(diǎn)數(shù),此處選取t=19,L=20,w=1;
步驟3:定義跌代次數(shù)iter、優(yōu)勝子群體M和臨時(shí)子群體T的數(shù)目;進(jìn)化過程的每一代中的所有個(gè)體的集合成為一個(gè)群體,一個(gè)群體分為M個(gè)優(yōu)勝子群體和T個(gè)臨時(shí)子群體,每個(gè)優(yōu)勝子群體和臨時(shí)子群體包含了SG個(gè)個(gè)體,SG為:
SG=N/(M+T) 公式(5)
通常選取iter=10,M=T=5,N=200,SG=20;
步驟4:得分函數(shù)的確定,神經(jīng)網(wǎng)絡(luò)由輸入層、隱含層、輸出層組成,網(wǎng)絡(luò)訓(xùn)練樣本輸入層為AK=(a1k,a2k,…,atk),(K=1,2,…,P,P為訓(xùn)練樣本數(shù)),輸入矩陣為t*p,期望網(wǎng)絡(luò)輸出層為YK=(Y1k,Y2k,…,Ywk),輸出矩陣為w*p,每一個(gè)樣本輸入對(duì)應(yīng)一個(gè)輸出,樣本中一共有p個(gè)輸入輸出對(duì);網(wǎng)絡(luò)中間隱含層各節(jié)點(diǎn)輸入為ZK=(z1,z2,…,zL),中間隱含層各節(jié)點(diǎn)輸出為BK=(b1,b2,…,bL);網(wǎng)絡(luò)各節(jié)點(diǎn)輸入為QK=(q1,q2,…,qw),網(wǎng)絡(luò)輸出層各節(jié)點(diǎn)輸出為GK=(g1,g2,…,gw)。定義輸入層與隱含層權(quán)值Wij(i=1,2,…,t,j=1,2,…,L)、隱含層與輸出層權(quán)值Vju(j=1,2,…,L,u=1,2,…,w)、隱含層閾值為{θj(j=1,2,…,L)}、輸出層閾值{βu(u=1,2,…,w)},矩陣為w*w。根據(jù)編碼規(guī)則,Wij為單個(gè)個(gè)體中第1個(gè)到第(L*t)個(gè)元素,矩陣為L(zhǎng)*t;Vju為單個(gè)個(gè)體中第(L*t+1)個(gè)到(L*t+w*L)個(gè)元素,矩陣為w*L;θj為單個(gè)個(gè)體中第(L*t+w*L+1)個(gè)到第(L*t+w*L+L)個(gè)元素,矩陣為w*L;βu為單個(gè)個(gè)體中第(L*t+w*L+1)個(gè)到最后一個(gè)元素。計(jì)算網(wǎng)絡(luò)隱含層各節(jié)點(diǎn)輸入Zj,然后用{Zj}通過S型激活函數(shù)來計(jì)算隱含層各節(jié)點(diǎn)輸出{bj},S型函數(shù)表達(dá)式為:
bj=f(Zj),j=1,2,…L 公式(7)
公式(7)中∑Wa稱為此模型的激活值,是模型的輸入求和;公式(7)中f()為模型激活函數(shù)。
然后根據(jù)隱含層的輸出{bj},權(quán)值Vju及閾值{βu}計(jì)算輸出層各節(jié)點(diǎn)輸入Qu,然后用{Qu}通過S型函數(shù)來計(jì)算輸出層各節(jié)點(diǎn)的輸出{Gu}:
Gu=f(Qu)(u=1,2,…,w) 公式(9)
公式(8)(9)同上;
選擇訓(xùn)練樣本的均方誤差的倒數(shù)作為各個(gè)個(gè)體與群體的得分函數(shù)yk表示第K個(gè)訓(xùn)練樣本的期望輸出值,矩陣為w*p,Gk表示實(shí)際的輸出值,即通過神經(jīng)網(wǎng)絡(luò)訓(xùn)練出來的值,矩陣也為w*p,p為訓(xùn)練樣本數(shù)目;
步驟5:訓(xùn)練權(quán)值和閾值,對(duì)于每個(gè)個(gè)體在(-1,1)之間以均勻分布產(chǎn)生n組隨機(jī)數(shù),個(gè)體矩陣為1*n,作為初始的權(quán)值閾值群體,根據(jù)網(wǎng)絡(luò)計(jì)算規(guī)則,按照得分函數(shù)計(jì)算每個(gè)個(gè)體得分,得分最高的個(gè)體被稱為優(yōu)勝者,沖中選取q個(gè)得分最好的個(gè)體作為優(yōu)勝者,選取q=10;
步驟6:子群體趨同操作,在子群體中,個(gè)體成為勝者而競(jìng)爭(zhēng)的過程叫做趨同,一個(gè)子群體的趨同過程中,若不在產(chǎn)生新的勝者,則成為子群體成熟,趨同過程結(jié)束,分別以每一個(gè)優(yōu)勝者為中心,服從正態(tài)分布產(chǎn)生個(gè)體,形成M個(gè)優(yōu)勝子群體和T個(gè)臨時(shí)子群體,每個(gè)子群體包含SG個(gè)個(gè)體,該正態(tài)分布可以表示為N(u,∑),式中u是正態(tài)分布的中心向量,∑是該正態(tài)分布的協(xié)方差矩陣,正態(tài)分布的中心就是勝者的坐標(biāo),即勝者的權(quán)值和閾值;
步驟7:子群體異化操作。異化過程是整個(gè)解空間內(nèi)各子群體成為勝者而競(jìng)爭(zhēng)的過程。通過全局公告板,它記錄了各子群體得分函數(shù)值以及成熟度,在各個(gè)子群體之間進(jìn)行全局競(jìng)爭(zhēng),若一個(gè)臨時(shí)子群體得分高于某個(gè)成熟優(yōu)勝子群體得分,則臨時(shí)子群體替換掉優(yōu)勝子群體,原優(yōu)勝子群體中的個(gè)體被放棄;若一個(gè)成熟的臨時(shí)子群體的得分低于任意一個(gè)優(yōu)勝子群體的得分,則該臨時(shí)子群體被放棄,其中的個(gè)體被釋放。被放棄的臨時(shí)子群體的個(gè)數(shù)記為Tr,被放棄的優(yōu)勝子群體的個(gè)數(shù)記為Mr,在全局公告板的指導(dǎo)下,在解空間中重新產(chǎn)生Mr+Tr個(gè)臨時(shí)子群體;
步驟8:解析最優(yōu)個(gè)體。重復(fù)上述6,7步驟,當(dāng)滿足迭代停止條件時(shí),思維進(jìn)化算法結(jié)束優(yōu)化過程。此時(shí),根據(jù)編碼規(guī)則,對(duì)尋找到的最優(yōu)個(gè)體進(jìn)行解析,從而得到對(duì)應(yīng)的BP神經(jīng)網(wǎng)絡(luò)的最優(yōu)權(quán)值和閾值,輸入最優(yōu)權(quán)值和閾值,建立MEA-BP神經(jīng)網(wǎng)絡(luò)模型;
參照?qǐng)D4,采用分布式的算法,對(duì)每組分簇中傳感器節(jié)點(diǎn)(Xt1,Xt2,…,Xtq)獨(dú)立執(zhí)行異常檢測(cè),異常檢測(cè)完畢后傳感器節(jié)點(diǎn)(Xt1,Xt2,…,Xtq)將檢測(cè)結(jié)果傳遞到該組分簇的簇頭節(jié)點(diǎn)Xtc進(jìn)一步驗(yàn)證,包括以下步驟:
S41通過時(shí)間相關(guān)性對(duì)傳感器節(jié)點(diǎn)(Xt1,Xt2,…,Xtq)獨(dú)立執(zhí)行異常檢測(cè),利用每個(gè)當(dāng)前時(shí)刻通過傳感器節(jié)點(diǎn)Xtj滑動(dòng)窗口Wj的數(shù)據(jù)來訓(xùn)練神經(jīng)網(wǎng)絡(luò),完成下一時(shí)刻數(shù)據(jù)的預(yù)報(bào),選取訓(xùn)練數(shù)據(jù)的后v個(gè)樣本數(shù)據(jù),通過公式(1)計(jì)算MEA-BP神經(jīng)網(wǎng)絡(luò)的模型殘差S:
其中,Er(r=1,2,…,v)為選取的樣本數(shù)據(jù)值,F(xiàn)為選取的樣本數(shù)據(jù)平均值,
S42計(jì)算傳感器節(jié)點(diǎn)當(dāng)前時(shí)刻的置信區(qū)間,置信區(qū)間為其中Spre為MEA-BP神經(jīng)網(wǎng)絡(luò)對(duì)下一時(shí)刻數(shù)據(jù)的預(yù)測(cè)值,tα/2,v-1為自由度v-1的t分布,在t分布表中選取合適的α值,得到t值;t分布表如圖1所示,正態(tài)分布又名高斯分布,若隨機(jī)變量服從一個(gè)數(shù)學(xué)期望為μ、方差為σ2的高斯分布,記為N(μ,σ2),我們通常所說的標(biāo)準(zhǔn)正態(tài)分布是μ=0,σ=1的正態(tài)分布。從平均值為μ、方差為σ2的標(biāo)準(zhǔn)正態(tài)分布總體中抽取容量為v的樣本,樣本服從平均值為μ,方差為σ2/v的正態(tài)分布,總體方差σ2總是未知的,從而只能用s2來代替。如果v很大,那么,s2就是σ2的一個(gè)較好的估計(jì)量,仍然是一個(gè)近似的標(biāo)準(zhǔn)正態(tài)分布;如果v較小,s2與σ2的差異較大,因此,此時(shí)樣本分布就不再是一個(gè)標(biāo)準(zhǔn)正態(tài)分布,而是服從t分布,t分布是依自由度而變的一條曲線,在坐標(biāo)軸Y軸兩側(cè)對(duì)稱分布,且均值為0,t分布適用于當(dāng)總體標(biāo)準(zhǔn)差未知時(shí),然后用樣本標(biāo)準(zhǔn)差代替總體標(biāo)準(zhǔn)差。t分布中的自由度是指任何變量中可以自由變化的數(shù)目。此時(shí)的樣本t檢驗(yàn)僅估計(jì)一個(gè)參數(shù):總體均值,樣本大小v組成了v種用于估計(jì)總體均值及其變異性的信息,消耗一個(gè)自由度來估計(jì)均值,其余v-1個(gè)自由度用于估計(jì)變異性,因此,樣本t檢驗(yàn)使用自由度為v-1的t分布;當(dāng)不需要估計(jì)參數(shù)時(shí),自由度為v;通常選取α=0.05。
S43當(dāng)下一時(shí)刻數(shù)據(jù)Snew進(jìn)入傳感器節(jié)點(diǎn)滑動(dòng)窗口內(nèi)時(shí),判斷下一時(shí)刻數(shù)據(jù)Snew是否落入當(dāng)前時(shí)刻的置信區(qū)間范圍內(nèi),若是,則判斷該數(shù)據(jù)Snew為正常數(shù)據(jù);否則判斷該數(shù)據(jù)Snew為異常數(shù)據(jù);
S44異常檢測(cè)完畢后傳感器節(jié)點(diǎn)(Xt1,Xt2,…,Xtq)將檢測(cè)結(jié)果傳遞到該組分簇的簇頭節(jié)點(diǎn)Xtc中;
S45簇頭節(jié)點(diǎn)Xtc通過空間相關(guān)性檢測(cè)并引入投票機(jī)制驗(yàn)證傳感器節(jié)點(diǎn)異常數(shù)據(jù)產(chǎn)生原因,原因包括事件異常、節(jié)點(diǎn)故障異常和誤判,具體包括以下步驟:
S451將傳感器節(jié)點(diǎn)的異常數(shù)據(jù)和與該傳感器節(jié)點(diǎn)在同一分簇中的其他節(jié)點(diǎn)數(shù)據(jù)進(jìn)行比較;設(shè)q+1個(gè)傳感器節(jié)點(diǎn)組成一組分簇,每組分簇中包括1個(gè)簇頭節(jié)點(diǎn)Xtc和q個(gè)分布節(jié)點(diǎn)(Xt1,Xt2,…,Xtq);
S452預(yù)先設(shè)定誤差值θ,設(shè)傳感器節(jié)點(diǎn)的異常數(shù)據(jù)為ST,設(shè)與該傳感器節(jié)點(diǎn)在同一分簇中的其他節(jié)點(diǎn)的數(shù)據(jù)為Si(i=1,2,…,q-1),若|ST-Si|<θ,則初始值為0的計(jì)數(shù)NN加1,統(tǒng)計(jì)最終的NN值;
S453若則判斷該檢測(cè)節(jié)點(diǎn)異常數(shù)據(jù)是由于事件異常;若則判斷該檢測(cè)節(jié)點(diǎn)異常數(shù)據(jù)是由于節(jié)點(diǎn)故障或誤判;若則選取該分簇中的參照節(jié)點(diǎn),設(shè)參照節(jié)點(diǎn)的數(shù)據(jù)為SCC,若|ST-SCC|≤θ,則判斷該傳感器節(jié)點(diǎn)異常數(shù)據(jù)是由于事件異常,若|ST-SCC|>θ,則判斷該傳感器節(jié)點(diǎn)異常數(shù)據(jù)是由于節(jié)點(diǎn)故障或誤判;其中參照節(jié)點(diǎn)為距離該分簇中聚類中心節(jié)點(diǎn)歐氏距離最近的節(jié)點(diǎn);參照節(jié)點(diǎn):利用K-means算法對(duì)各傳感器節(jié)點(diǎn)進(jìn)行空間分簇得到若干組簇,將數(shù)據(jù)相似的傳感器節(jié)點(diǎn)劃分到同一個(gè)簇中,根據(jù)最終的分簇結(jié)果,選取距離該簇質(zhì)心歐式距離最近的節(jié)點(diǎn)為參照節(jié)點(diǎn);
S454對(duì)于所述步驟S453中,當(dāng)判斷得到該傳感器節(jié)點(diǎn)異常數(shù)據(jù)是由于節(jié)點(diǎn)故障或誤判時(shí),進(jìn)一步判斷該傳感器節(jié)點(diǎn)異常數(shù)據(jù)是由于節(jié)點(diǎn)故障還是誤判,具體包括以下步驟:通過對(duì)傳感器節(jié)點(diǎn)進(jìn)行時(shí)間相關(guān)性檢測(cè),當(dāng)傳感器節(jié)點(diǎn)連續(xù)時(shí)間內(nèi)均產(chǎn)生異常數(shù)據(jù),則判斷該傳感器節(jié)點(diǎn)異常數(shù)據(jù)是由于節(jié)點(diǎn)故障;當(dāng)傳感器節(jié)點(diǎn)只有該時(shí)刻為異常數(shù)據(jù),其他時(shí)刻產(chǎn)生數(shù)據(jù)均為正常數(shù)據(jù),則判斷該傳感器節(jié)點(diǎn)異常數(shù)據(jù)是由于誤判;
為了檢測(cè)節(jié)點(diǎn)中的異常數(shù)據(jù),每個(gè)節(jié)點(diǎn)都會(huì)以一定周期采集數(shù)據(jù),形成屬于該節(jié)點(diǎn)的數(shù)據(jù)流,為了保證該區(qū)域內(nèi)節(jié)點(diǎn)采集數(shù)據(jù)樣本的正確性,每個(gè)節(jié)點(diǎn)在上傳數(shù)據(jù)前,都需要利用神經(jīng)網(wǎng)絡(luò)預(yù)測(cè)的值替換掉滑動(dòng)窗口內(nèi)的異常值。
數(shù)據(jù)樣本來源于英特爾伯克利實(shí)驗(yàn)室的傳感器網(wǎng)絡(luò)數(shù)據(jù),該數(shù)據(jù)采樣頻率為每隔31秒采樣一次。選取傳感器節(jié)點(diǎn)1-5號(hào)節(jié)點(diǎn)100組溫度,濕度作為訓(xùn)練數(shù)據(jù),20組溫度,濕度作為預(yù)測(cè)數(shù)據(jù)。
S1訓(xùn)練=[20.6156,20.6254,20.6450,20.6352,20.6450,20.6156,20.6058,20.576420.4882,20.4588,20.4392,20.4196,20.3804,20.3510,20.3020,20.2726,20.2530,20.1942,20.184420.1354,20.0864,20.0668,20.0374,20.0178,19.9982,19.9786,19.9688,19.8414,19.8022,19.8022,19.7826,19.8022,19.8218,19.8316,19.8610,19.9002,19.9296,19.9786,19.9884,20.0080,20.0374,20.0472,20.1060,20.1060,20.1256,20.1354,20.1550,20.2236,20.2432,20.2432,20.3020,20.3216,20.3608,20.4588,20.4980,20.5176,20.5568,20.5666,20.5960,20.6254,21.4192,21.4094,21.3996,21.3604,21.3212,21.3016,21.2624,21.2330,21.2232,21.2036,21.1252,21.1252,21.1056,21.1056,21.0860,21.0860,21.0860,21.0762,21.0664,21.0664,21.0468,21.0076,20.9880,20.9586,20.9684,20.9096,20.8998,20.8998,20.8802,20.8704,20.8704,20.8704,20.8704,20.8802,20.8704,20.8802,20.8802,20.8802,20.8704,20.8704]
[37.5737,37.6079,37.6422,37.6422,37.7107,37.7107,37.7792,37.8477,38.0529,38.1213,38.189738.1897,38.3263,38.3946,38.4629,38.5311,38.5311,38.7357,38.8039,38.8720,39.0082,39.0763,39.1443,39.1783,39.2123,39.2803,39.3143,39.6200,39.755739.7896,39.755739.5521,39.5521,39.5521,39.4162,39.4502,39.3143,39.2803,39.2123,39.178339.1443,39.110339.0082,39.0082,38.9401,39.0082,38.9401,38.8379,38.8720,38.8039,38.7357,38.769838.7357,38.6675,38.4970,38.3946,38.3946,38.3263,38.2580,38.2580,38.2239,38.155537.9845,38.1897,38.1555,38.0529.37.9845,37.9161,37.8134,37.813437.8819,37.8819,37.9161,37.9503,37.9503,37.9161,37.9503,37.9161,37.8477,37.7792,37.7450,37.7450,37.7107,37.7107,37.7107,37.7107,37.6765,37.6765,37.6422,37.8134,37.7792,37.7107,37.7107,37.6765,37.6765,37.7107,37.7450,37.7792,37.9161,38.0529]
S1預(yù)測(cè)=[20.7724,20.7332,20.7528,20.7430,20.7332,20.7332,20.7234,20.7136,20.7234,22.1530,20.7038,20.6940,20.6940,20.7038,20.6940,22.1530,20.6744,20.6450,20.6352,20.6254][39.6200,39.9929,40.3652,40.9055,41.1414,41.2761,41.3771,41.4780,41.7805,41.8812,41.9818,41.9483,42.2500,42.3840,42.3170,52.3170,42.2500,42.2835,42.0824,41.9818]
S2訓(xùn)練=[20.6226,20.6224,20.6350,20.6352,20.6350,20.6256,20.6358,20.5764,20.4782,20.4388,20.4492,20.4296,20.3604,20.3310,20.3320,20.2326,20.2330,20.1042,20.1644,20.1354,20.0464,20.0468,20.0274,20.0178,19.9482,19.9486,19.9588,19.8614,19.8322,19.8222,19.7926,19.8122,19.8518,19.8516,19.8510,19.9502,19.9296,19.9386,19.9884,20.0080,20.0374,20.0472,20.1060,20.1060,20.1236,20.1454,20.1350,20.2236,20.2332,20.2432,20.3020,20.3216,20.3608,20.4588,20.4380,20.5376,20.5568,20.5666,20.5960,20.6354,20.6450,20.7136,20.7038,20.6744,20.7528,20.8412,20.8506,20.8600,20.8796,20.8802,20.8402,20.8704,20.8902,20.8704,20.8704,20.8704,20.8802,20.9096,20.9586,20.9782,20.9380,21.0376,21.0076,21.0174,21.0076,21.0272,21.0468,21.0566,20.9978,21.0370,21.0468,21.0366,21.0360,21.0368,21.0368,21.0634,21.0732,21.0938,21.0360,21.1356]
[37.5337,37.6179,37.6222,37.6322,37.7207,37.7307,37.7492,37.8277,38.0129,38.1113,38.149738.1597,38.3163,38.3546,38.4629,38.5311,38.5311,38.7357,38.8039,38.8720,39.0082,39.0763,39.1443,39.1783,39.2123,39.2803,39.3153,39.6200,39.7557,39.7896,39.7357,39.5521,39.5521,39.5521,39.4152,39.4502,39.3143,39.2803,39.2123,39.1783,39.1443,39.1103,39.0032,39.0082,38.9431,39.0042,38.8401,38.8479,38.8520,38.8039,38.7357,38.7698,38.7357,38.6635,38.4970,38.3946,38.3946,38.3263,38.2380,38.2380,38.2339,38.1355,37.9345,38.1897,38.1555,38.0529,37.9845,37.9161,37.8134,37.8134,37.8819,37.8819,37.9161,37.9503,37.9503,37.9161,37.9503,37.9161,37.8477,37.7792,37.7450,37.7450,37.7107,37.7107,37.7107,37.7107,37.6765,37.6765,37.6522,37.8034,37.7592,37.6907,37.6807,37.6565,37.6865,37.7207,37.7550,37.7732,37.9261,38.0629]
S2預(yù)測(cè)=(20.5670,20.5376,20.4788,20.4494,20.4984,20.4788,20.4592,20.4494,20.4788,20.4690,20.4788,20.4592,20.4592,20.4494,20.4396,20.4396,22.4396,20.4396,20.4396,20.3710)(39.4300,40.7863,40.4722,40.8955,41.3214,41.4361,41.5671,41.6880,41.8205,41.9036,42.0142,42.0100,42.3200,42.4140,42.3270,42.3370,52.3500,42.3825,42.1824,41.8918)
S3訓(xùn)練=[20.6156,20.6254,20.6450,20.6352,20.6450,20.6156,20.6058,20.576420.4882,20.4588,20.4392,20.4196,20.3804,20.3510,20.3020,20.2726,20.2530,20.1942,20.1844,20.1354,20.0864,20.0668,20.0374,20.0178,19.9982,19.9786,19.9688,19.8414,19.8022,19.8022,19.7826,19.8022,19.8218,19.8316,19.8610,19.9002,19.9296,19.9786,19.9884,20.0080,20.0374,20.0472,20.1060,20.1060,20.1256,20.1354,20.1550,20.2236,20.2432,20.2432,20.3020,20.3216,20.3608,20.4588,20.4980,20.5176,20.5568,20.5666,20.5960,20.6254,20.6450,20.7136,20.7038,20.6744,20.7528,20.8312,20.8606,20.8900,20.9096,20.8802,20.8802,20.8704,20.8802,20.8704,20.8704,20.8704,20.8802,20.9096,20.9586,20.9782,20.9880,21.0076,21.0076,21.0174,21.0076,21.0272,21.0468,21.0566,20.9978,21.0370,21.0468,21.0566,21.0860,21.0468,21.0468,21.0664,21.0762,21.0958,21.0860,21.1056]
[37.5737,37.6079,37.6422,37.6422,37.7107,37.7107,37.7792,37.8477,38.0529,38.1213,38.189738.1897,38.3263,38.3946,38.4629,38.5311,38.5311,38.7357,38.8039,38.8720,39.0082,39.0763,39.1443,39.1783,39.2123,39.2803,39.3143,39.6200,39.7557,39.7896,39.7557,39.5521,39.5521,39.5521,39.4162,39.4502,39.3143,39.2803,39.2123,39.1783,39.1443,39.1103,39.0082,39.0082,38.9401,39.0082,38.9401,38.8379,38.8720,38.8039,38.7357,38.7698,38.7357,38.6675,38.4970,38.3946,38.3946,38.3263,38.2580,38.2580,38.2239,38.1555,37.9845,38.1897,38.1555,38.0529,37.9845,37.9161,37.8134,37.8134,37.8819,37.8819,37.9161,37.9503,37.9503,37.9161,37.9503,37.9161,37.8477,37.7792,37.7450,37.7450,37.7107,37.7107,37.7107,37.7107,37.6765,37.6765,37.6422,37.8134,37.7792,37.7107,37.7107,37.6765,37.6765,37.7107,37.7450,37.7792,37.9161,38.0529]
S3預(yù)測(cè)=(20.4396,20.4102,20.4102,20.4004,20.3710,20.3612,20.3612,20.3612,20.3612,20.3514,20.3710,20.3808,20.3416,20.3220,20.3220,20.3318,20.3318,22.3220,20.3514,20.3416)(39.4200,40.7963,40.4422,40.8755,41.3614,41.4161,41.5871,41.6780,41.8405,41.9236,42.0242,42.0200,42.3300,42.4240,42.3170,42.3270,42.3400,52.3525,42.1624,41.8718)
S4訓(xùn)練=[20.4154,20.4254,20.4450,20.4352,20.4450,20.4154,20.4057,20.574420.4772,20.4577,20.4392,20.4194,20.3704,20.3510,20.3020,20.2724,20.2530,20.1942,20.1744,20.1354,20.0744,20.0447,20.0374,20.0277,19.9972,19.9774,19.9477,19.7414,19.7022,19.7022,19.7724,19.7022,19.7217,19.7314,19.7410,19.9002,19.9294,19.9774,19.9774,20.0070,20.0374,20.0472,20.1040,20.1040,20.1254,20.1354,20.1350,20.2234,20.2432,20.2432,20.3020,20.3214,20.3407,20.4577,20.4970,20.5174,20.5547,20.5444,20.5940,20.4254,20.4450,20.7134,20.7037,20.4744,20.7527,20.7312,20.7404,20.7900,20.9094,20.7702,20.7702,20.7704,20.7702,20.7704,20.7704,20.7704,20.7702,20.9094,20.9574,20.9772,20.9770,21.0074,21.0074,21.0174,21.0074,21.0272,21.0447,21.0544,20.9977,21.0370,21.0447,21.0544,21.0740,21.0447,21.0447,21.0444,21.0742,21.0957,21.0840,21.1054]
[37.5737,37.4079,37.4422,37.4422,37.7107,37.7107,37.7792,37.8477,38.0529,38.1213,38.189738.1897,38.3243,38.3944,38.4429,38.5311,38.5311,38.7357,38.8039,38.8720,39.0082,39.0743,39.1443,39.1783,39.2123,39.2803,39.3143,39.4200,39.755739.7894,39.755739.5521,39.5521,39.5521,39.4142,39.4502,39.3143,39.2803,39.2123,39.178339.1443,39.110339.0082,39.0082,38.9401,39.0082,38.9401,38.8379,38.8720,38.8039,38.7357,38.749838.7357,38.4475,38.4970,38.3944,38.3944,38.3243,38.2580,38.2580,38.2239,38.155537.9845,38.1897,38.1555,38.0529.37.9845,37.9141,37.8134,37.813437.8819,37.8819,37.9141,37.9503,37.9503,37.9141,37.9503,37.9141,37.8477,37.7792,37.7450,37.7450,37.7107,37.7107,37.7107,37.7107,37.4745,37.4745,37.4422,37.8134,37.7792,37.7107,37.7107,37.4745,37.4745,37.7107,37.7450,37.7792,37.9141,38.0529]
S4預(yù)測(cè)=(20.4394,20.4102,20.4788,20.4494,20.4984,20.4788,20.3412,20.3412,20.3412,20.3514,20.3710,20.3808,20.3414,20.2240,20.2240,20.2338,20.2240,20.3318,22.3514,20.3414)(39.4500,40.7343,40.4222,40.8555,41.4214,41.5341,41.4471,41.4980,41.8805,41.9334,42.0142,42.0120,42.3100,42.4240,42.3070,42.3470,42.3800,42.3925,52.2024,41.9118)
S5訓(xùn)練=[20.4154,20.4254,20.4450,20.4352,20.4450,20.4154,20.4058,20.574420.4882,20.4588,20.4392,20.4194,20.3804,20.3510,20.3020,20.2724,20.2530,20.1942,20.184420.1354,20.0844,20.0448,20.0374,20.0178,19.9982,19.9784,19.9488,19.8414,19.8022,19.8022,19.7824,19.8022,19.8218,19.8314,19.8410,19.9002,19.9294,19.9784,19.9884,20.0080,20.0374,20.0472,20.1040,20.1040,20.1254,20.1354,20.1550,20.2234,20.2432,20.2432,20.3020,20.3214,20.3408,20.4588,20.4980,20.5174,20.5548,20.5444,20.5940,20.4254,20.4450,20.7134,20.7038,20.4744,20.7528,20.8312,20.8404,20.8900,20.9094,20.8802,20.8802,20.8704,20.8802,20.8704,20.8704,20.8704,20.8802,20.9094,20.9584,20.9782,20.9880,21.0074,21.0074,21.0174,21.0074,21.0272,21.0448,21.0544,20.9978,21.0370,21.0448,21.0544,21.0840,21.0448,21.0448,21.0444,21.0742,21.0958,21.0840,21.1054]
[37.5737,37.4079,37.4422,37.4422,37.7107,37.7107,37.7792,37.8477,38.0529,38.1213,38.189738.1897,38.3243,38.3944,38.4429,38.5311,38.5311,38.7357,38.8039,38.8720,39.0082,39.0743,39.1443,39.1783,39.2123,39.2803,39.3143,39.4200,39.755739.7894,39.755739.5521,39.5521,39.5521,39.4142,39.4502,39.3143,39.2803,39.2123,39.178339.1443,39.110339.0082,39.0082,38.9401,39.0082,38.9401,38.8379,38.8720,38.8039,38.7357,38.749838.7357,38.4475,38.4970,38.3944,38.3944,38.3243,38.2580,38.2580,38.2239,38.155537.9845,38.1897,38.1555,38.0529.37.9845,37.9141,37.8134,37.813437.8819,37.8819,37.9141,37.9503,37.9503,37.9141,37.9503,37.9141,37.8477,37.7792,37.7450,37.7450,37.7107,37.7107,37.7107,37.7107,37.4745,37.4745,37.4422,37.8134,37.7792,37.7107,37.7107,37.4745,37.4745,37.7107,37.7450,37.7792,37.9141,38.0529]
S5預(yù)測(cè)=(20.4204,205002,20.4200,20.4200,20.3906,20.3612,20.3024,20.2828,20.3122,20.2828,20.2828,20.2632,20.2436,20.2240,20.2240,20.2338,20.2240,20.1848,20.1848,22.1848)(39.4050,40.7663,40.4532,40.8865,41.3314,41.4261,41.5871,41.7080,41.7905,41.9236,42.0242,42.0180,42.3150,42.4040,42.2970,42.3270,42.3700,42.3535,42.1924,51.9218)
現(xiàn)以傳感器節(jié)點(diǎn)采集的溫度為樣例。如圖1所示,首先通過K-means算法對(duì)空間節(jié)點(diǎn)進(jìn)行劃分,假設(shè)1-5號(hào)節(jié)點(diǎn)在同一個(gè)簇中,然后如圖2所示利用節(jié)點(diǎn)的數(shù)據(jù)進(jìn)行參數(shù)優(yōu)化,建立MEA-BP神經(jīng)網(wǎng)絡(luò)模型。利用神經(jīng)網(wǎng)絡(luò)模型殘差確定置信區(qū)間,此后節(jié)點(diǎn)采集新的數(shù)據(jù),通過滑動(dòng)窗口進(jìn)行預(yù)測(cè),若采集的數(shù)據(jù)不在置信區(qū)間內(nèi),則判定該數(shù)據(jù)為異常值,同時(shí)傳遞給簇頭進(jìn)行驗(yàn)證。否則,采集的數(shù)據(jù)是正常的。
神經(jīng)網(wǎng)絡(luò)的初始權(quán)值和閾值是隨機(jī)的,通過優(yōu)化算法得到最優(yōu)個(gè)體,根據(jù)編碼規(guī)則解析最優(yōu)個(gè)體,個(gè)體中的元素被劃分為四部分,輸入層與隱含層權(quán)值W、隱含層與輸出層權(quán)值V、隱含層閾值θ、輸出層閾值β。
W=[0.5773,-0.0366,-0.5442,0.6235,1.1156,0.3768,0.3825,0.3136,0.1267,-0.7622,-0.5179,1.0760,-0.7651,-0.6149,0.3441,0.9941,0.0842,0.9022,-0.2135,0.0192;
1.0865,0.2526,0.6696,-0.5513,0.2104,0.2332,0.5453,-0.1723,1.3676,0.3422,-0.3744,0.8603,0.0330,0.3656,-0.2953,0.0479,-0.3960,-0.6000,0.2272,-0.7731;
-0.5749,0.5627,0.5373,1.0035,-0.9583,1.1374,0.9935,0.5132,0.5842,0.4948,-0.5388,0.9441,0.3067,-0.5114,0.3832,-0.0877,-0.6106,-0.8577,-0.4521,0.5040;
-0.1253,-0.9239,0.5082,0.5222,0.0151,0.0033,-0.2452,-0.3727,-0.7296,1.0824,1.0505,-0.6283,-0.5399,0.4255,0.3935,-0.5921,-0.6411,-0.8547,0.5181,0.7837;
-0.4296,-0.6532,0.1644,0.4362,1.2707,0.4877,-0.6715,0.9923,1.2893,0.8293,,0.9933,-0.6541,-0.1126,0.5300,-0.7672,0.0751,0.2299,-0.2186,0.8131,-0.9794;
-0.9365,-0.2176,1.0960,0.0105,1.3308,-0.3746,-1.0590,-0.5488,-0.8550,0.2305,0.4455,-0.2741,-0.0727,-0.8329,0.6602,0.6955,1.2929,-0.2030,0.6805,-0.1515;
0.9026,0.4729,0.4579,0.0247,-0.3627,-0.1774,0.3376,0.2647,-0.2081,-0.9794,0.8114,0.0375,-0.1698,0.1191,-0.1169,0.3339,0.4083,-0.3918,-0.3013,0.8716;
-0.1600,0.5712,-0.4983,-0.5316,-0.4528,-0.1343,0.6454,-0.6407,0.9763,-0.3584,-0.5402,0.1329,0.7943,0.3628,-0.3161,0.5328,0.5403,0.7219,-0.3242,0.4581;
-0.0458,-0.7775,0.1541,-0.0951,-0.5324,0.1833,-0.6400,-0.1086,-0.8386,-0.1227,-1.1306,0.3747,-1.2653,-0.4936,-0.1682,0.7071,-0.3657,1.0828,0.5700,1.1866;
-0.5898,-0.7801,0.5664,0.0111,0.3069,0.1700,0.3791,-0.3305,0.3633,0.3725,0.0423,-0.0695,0.2999,0.9656,0.6382,0.1977,-0.4587,0.2812,-0.5573,-0.3800;
0.9481,-0.0495,0.6783,-0.5981,-0.4970,0.8797,-0.9796,-0.3040,0.9687,-1.1954,0.3528,-0.1131,-0.1752,-0.8480,0.0283,-0.1791,1.1680,0.1180,1.0543,-0.7890;
0.9876,-0.5693,0.2064,1.0028,-0.7505,-0.0915,0.8364,0.0396,1.3324,0.6910,0.4675,0.2987,-0.7527,-0.5169,-0.8266,1.0537,0.9445,-0.1559,-0.2290,0.7849;
0.7757,0.0837,0.6734,-1.0255,0.2378,0.4449,0.5047,0.0004,0.4182,0.1178,0.5781,-0.2788,0.5544,-0.6854,0.2246,-0.9034,-0.5780,-1.0345,-1.0602,-0.5880;
-0.9348,-0.4230,-0.7827,-0.9307,-0.1429,-0.1718,0.2480,0.8521,-0.9502,0.8372,0.5072,-0.5041,0.0417,-0.0333,0.1855,-0.1131,0.7978,1.2911,0.3152,0.5734;
-0.4313,0.3686,-0.4494,-0.2113,-0.8895,-0.6692,0.8727,0.5028,-1.2660,-0.1608,-1.1177,0.9249,-0.7744,-0.8300,-0.6689,-0.6472,0.5649,-0.0527,-0.2023,0.7030;
0.8426,0.8520,0.6722,-0.9511-0.7137,-0.6196,0.1978,0.5044,-0.6855,-0.3957,-1.1713,0.8359,0.2987,-0.3332,-0.7046,-0.0307,0.7013,-1.0424,-0.2173,-0.8635;
0.4429,-0.5530,0.2594,-0.0055,-0.2293,-0.1312,0.1046,-1.1803,0.6552,1.1167,0.2293,0.8949,0.2872,0.0639,-0.7069,-0.6443,-0.5359,-0.7943,0.0749,0.2322;
0.1580,0.3637,-0.3663,0.3326,0.5618,-0.0908,0.6683,-0.1572,0.0053,-0.6843,-1.1245,0.6485-0.4312,-0.7010,-0.1113,0.7301,-0.0746,0.0622,0.1535,-0.0938;
-1.1087,-0.0046,-0.9751,-0.0265,1.1469,-0.7158,0.6888,-0.5601,0.5212,0.6409,-0.5567,1.1806,-0.1444,0.5397,-0.5531,0.5221,-0.5053,-1.2739,-0.4797,0.3794]
V=[-0.8852,-0.4987,-1.0526,0.3578,-0.0436,-0.6403,1.1844,-1.2437,-0.9961,-0.1289,-0.8779,-0.0577,-0.5220,0.4834,0.3050,0.5123,0.4276,-0.0404,0.9207,0.0199]
θ=[-0.3454,-0.0724,-0.9978,-1.0797,1.0350,0.2819,0.8036,0.2719,0.2332,-0.6689,0.9885,-0.7912,0.1800,-0.6851,-0.7595,0.2428,-0.1237,-0.2353,-0.0445,0.4698]
β=[-1.2285]
然后計(jì)算置信區(qū)間,隨機(jī)選取節(jié)點(diǎn)1一個(gè)時(shí)刻的預(yù)測(cè)值,值為20.8692,此時(shí)選取訓(xùn)練數(shù)據(jù)的后40個(gè)數(shù)據(jù)通過公式1計(jì)算模型殘差,求出的模型殘差值S=0.1776,由圖1得t值為2.02108,此時(shí)的區(qū)間上下界通過公式2計(jì)算為[20.5058,21.2326]。
假設(shè)節(jié)點(diǎn)S1已經(jīng)訓(xùn)練好了MEA-BP模型,通過滑動(dòng)窗口添加新的數(shù)據(jù),如上所示,當(dāng)滑動(dòng)窗口預(yù)測(cè)第1個(gè)數(shù)據(jù)時(shí),此時(shí)溫度預(yù)測(cè)值為20.8692,置信區(qū)間范圍為[20.5058,21.2326],此時(shí)刻傳感器數(shù)據(jù)為20.7724,可以看出20.7724這個(gè)數(shù)據(jù)明顯在區(qū)間范圍之內(nèi),則認(rèn)為該時(shí)刻數(shù)據(jù)是正常的;當(dāng)滑動(dòng)窗口預(yù)測(cè)第10個(gè)數(shù)據(jù)時(shí),此時(shí)溫度預(yù)測(cè)值為20.7062,置信區(qū)間范圍為[20.3428,21.0696],而此時(shí)刻傳感器數(shù)據(jù)為22.1530,該數(shù)據(jù)在區(qū)間范圍之外,然后傳遞給簇頭節(jié)點(diǎn)進(jìn)行空間性驗(yàn)證,通過投票機(jī)制發(fā)現(xiàn)該時(shí)刻的數(shù)據(jù)在同一個(gè)簇內(nèi)溫度是異常的的,則節(jié)點(diǎn)1采集的溫度數(shù)據(jù)異常,節(jié)點(diǎn)出現(xiàn)故障或誤報(bào),若發(fā)現(xiàn)在同一簇中數(shù)據(jù)相似,則認(rèn)為出現(xiàn)事件。對(duì)于其他節(jié)點(diǎn)的濕度溫度數(shù)據(jù)也同樣能夠準(zhǔn)確識(shí)別出異常。
本發(fā)明方法以傳感器節(jié)點(diǎn)的時(shí)空相關(guān)性為基礎(chǔ),用K-means算法對(duì)節(jié)點(diǎn)進(jìn)行劃分,然后在每個(gè)節(jié)點(diǎn)上建立MEA-BP神經(jīng)網(wǎng)絡(luò)模型,根據(jù)該模型來檢測(cè)未來每一時(shí)刻各分布節(jié)點(diǎn)內(nèi)到達(dá)的數(shù)據(jù)是否異常,然后把檢測(cè)后的結(jié)果傳遞到簇頭節(jié)點(diǎn)進(jìn)行驗(yàn)證。目前,異常檢測(cè)在各個(gè)領(lǐng)域中都是一個(gè)深入研究的問題,無線傳感器網(wǎng)絡(luò)獨(dú)特的特點(diǎn)及嚴(yán)格的約束條件使得該問題的研究更具有挑戰(zhàn)性。本發(fā)明提出的方法主要是針對(duì)資源受限的無線傳感器網(wǎng)絡(luò)復(fù)雜的異常檢測(cè),大大降低了節(jié)點(diǎn)之間的通信消耗,并能準(zhǔn)確檢測(cè)出異常數(shù)據(jù),更具有環(huán)境適應(yīng)能力。
以上所述僅是本發(fā)明的優(yōu)選實(shí)施方式,應(yīng)當(dāng)指出:對(duì)于本技術(shù)領(lǐng)域的技術(shù)人員來說,在不脫離本發(fā)明原理的前提下,還可以做出若干改進(jìn)和潤(rùn)飾,這些改進(jìn)和潤(rùn)飾也應(yīng)視為本發(fā)明的保護(hù)范圍。