資源描述:
《蟻群算法的改進(jìn)神經(jīng)網(wǎng)絡(luò)程序》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在應(yīng)用文檔-天天文庫。
1、%蟻群算法的改進(jìn)神經(jīng)網(wǎng)絡(luò)程序%這是某個(gè)碩士論文中附帶的程序,經(jīng)過試用,完全不能用。%蟻群算法優(yōu)化神經(jīng)網(wǎng)絡(luò)%參數(shù)值%ant_amount,螞蟻總數(shù)%quanzhi_amount,權(quán)值總數(shù)%xuanzhi_amount,可選值總數(shù)%k,螞蟻k%i,權(quán)值j%j,選值j%tao,信息素矩陣%zeng_tao,信息素增量%NC,最大迭代%rou,信息揮發(fā)度;%Q,信息總量:為螞蟻循環(huán)一周時(shí)釋放在所經(jīng)過的路徑上的信息素總量%zuixiaowucha,最小誤差%shijiwucha實(shí)際誤差%conter迭代次數(shù)%sum
2、_tao,tao和%p,信息素概率%4個(gè)矩陣:%iwb(i,j),權(quán)值矩陣(i*j)%tao(i,j),信息素矩陣(i*j)%mayi_xuanzhi(k,i),每只螞蟻選的權(quán)值矩陣(k*i)%mayi_xuanwei(k*i),每只螞蟻選的權(quán)值位置矩陣(k*i)%網(wǎng)絡(luò)主程序Clear;yangben_yuanshi=[7.81117011292.8;45168330823.1;58103251516;56144164361.8;82161406798.9;101519.550;18135208590;1
3、29181244440;12239890;1642444971038.3;16237470920;15125574297;4941.612425.115.7;217.696.34.726.73;6526.141.610.157.8;642251.720.795.1;297.5214.85.55.4;6.37.873.036.9711.1;4136.84.640.48.15;23.414.39.717.123.44;15.22.44.54.827.2;454315172102;6515054450;470.
4、72117618.9;22126.34.67.4;130.448.893.416.3123.4;19854.3107.16.4148.8;521.1107177.19.2144.7;217.54051.84.967.5;637.4171.86.2;5478.67.45.4;15027633.690;16210920111183;592870915;20136.132.3647.2];%訓(xùn)練樣本初值fori=1:35%訓(xùn)練樣本歸一化yangben_guiyi(i,:)=0.1+0.8*(yangben_yu
5、anshi(i,:)-min(yangben_yuanshi(i,:)))/(max(yangben_yuanshi(i,:))-min(yangben_yuanshi(i,:)));endyangben_shuchu=[10000;10000;10000;10000;10000;10000;10000;10000;10000;10000;10000;10000;01000;01000;01000;01000;00100;00100;00100;00100;00100;00010;00010;00010;
6、00010;00001;00001;00001;00001;00001;00001;00001;00001;00001;00001];%訓(xùn)練樣本故障輸出值yangben_guiyi=yangben_guiyi';yangben_shuchu=yangben_shuchu';net=newff(minmax(yangben_guiyi),[11,5],{'tansig','logsig'},'traingd');%生成原始神經(jīng)網(wǎng)絡(luò)XX=yangben_guiyi;YY=yangben_shuchu;P=XX
7、;T=YY;R=size(P,1);S2=size(T,1);S1=11;%隱含層節(jié)點(diǎn)數(shù)S=R*S1+S1*S2+S1+S2;%蟻群算法編碼長度%start初始化ant_amount=40;%螞蟻總數(shù)quanzhi_amount=S;%權(quán)值總數(shù)xuanzhi_amount=30;%可選值總數(shù)rand('state',0);tao=rand(quanzhi_amount,xuanzhi_amount);%tao,信息素矩陣NC=1000;%最大迭代次數(shù)rou=0.7;%信息持久性Q=30;%信息總量p=ze
8、ros(xuanzhi_amount,1);%p,信息素概率zuixiaowucha=0.001;%最小誤差counter=1;%迭代計(jì)數(shù)shijiwucha=0.1;%實(shí)際誤差iwb=rand(S,xuanzhi_amount)*(-20)+10;%權(quán)值矩陣mayi_xuanzhi=zeros(ant_amount,quanzhi_amount);%每只螞蟻選的權(quán)值矩陣(k*i)初始化mayi_xuanwei=zeros(a