1 简介
针对变压器故障的特征,结合变压器油中气体分析法以及三比值法.提出了基于蝗虫算法改进极限学习机的故障诊断方法.由于输入层与隐含层的权值和阈值是随机产生.传统的极限学习机可能会使隐含层节点过多,训练过程中容易产生过拟合现象.该方法运用蝗虫算法对极限学习机的输入层与隐含层的权值与阈值进行优化,从而提高模型的稳定性和预测精度.将诊断结果与传统的基于极限学习机故障诊断进行对比,结果表明,基于蝗虫算法改进极限学习机变压器故障诊断的精度更高.
基于 GOA 优化 ELM 的变压器故障诊断的具体步骤为:
1)确定 ELM 的拓扑结构。即输入层神经元个数,隐含层神经元个数以及输出层神经元个数;
2)对 ELM 中输入层到隐含层的权值以及阈值进行编码,得到初始种群;
3)解码得到权值和阈值,将权值和阈值带入到ELM 的训练网络中,使用训练样本进行训练;
4)训练完成后,使用测试样本进行测试,将测试样本的期望值和预测值的误差平方和作为适应度函数;
5)对种群进行选择,交叉,变异,得到新的种群,如果满足条件,则得出了误差平方和最小的网络权值和阈值,如果不满足条件,则返回步骤 2);
6)将优化后的权值和阈值带入到训练网络中,计算隐含层输出矩阵 H, 并求解矩阵 H 的 MoorePenrose 广义逆 H+;
7)计算输出层权值β赞=H+T;
8)将测试样本带入到模型中进行预测。
2 部分代码
% clc; clear; close all; flag=1; end max_iter=100; N=200; ArchiveMaxSize=100; Archive_X=zeros(100,dim); Archive_F=ones(100,obj_no)*inf; Archive_member_no=0; %Initialize the positions of artificial whales GrassHopperPositions=initialization(N,dim,ub,lb); TargetPosition=zeros(dim,1); TargetFitness=inf*ones(1,obj_no); cMax=1; cMin=0.00004; %calculate the fitness of initial grasshoppers for iter=1:max_iter for i=1:N Flag4ub=GrassHopperPositions(:,i)>ub'; Flag4lb=GrassHopperPositions(:,i)<lb'; GrassHopperPositions(:,i)=(GrassHopperPositions(:,i).*(~(Flag4ub+Flag4lb)))+ub'.*Flag4ub+lb'.*Flag4lb; GrassHopperFitness(i,:)=ObjectiveFunction(GrassHopperPositions(:,i)'); if dominates(GrassHopperFitness(i,:),TargetFitness) TargetFitness=GrassHopperFitness(i,:); TargetPosition=GrassHopperPositions(:,i); end end [Archive_X, Archive_F, Archive_member_no]=UpdateArchive(Archive_X, Archive_F, GrassHopperPositions, GrassHopperFitness, Archive_member_no); if Archive_member_no>ArchiveMaxSize Archive_mem_ranks=RankingProcess(Archive_F, ArchiveMaxSize, obj_no); [Archive_X, Archive_F, Archive_mem_ranks, Archive_member_no]=HandleFullArchive(Archive_X, Archive_F, Archive_member_no, Archive_mem_ranks, ArchiveMaxSize); else Archive_mem_ranks=RankingProcess(Archive_F, ArchiveMaxSize, obj_no); end Archive_mem_ranks=RankingProcess(Archive_F, ArchiveMaxSize, obj_no); index=RouletteWheelSelection(1./Archive_mem_ranks); if index==-1 index=1; end TargetFitness=Archive_F(index,:); TargetPosition=Archive_X(index,:)'; c=cMax-iter*((cMax-cMin)/max_iter); % Eq. (3.8) in the paper for i=1:N temp= GrassHopperPositions; for k=1:2:dim S_i=zeros(2,1); for j=1:N if i~=j Dist=distance(temp(k:k+1,j), temp(k:k+1,i)); r_ij_vec=(temp(k:k+1,j)-temp(k:k+1,i))/(Dist+eps); xj_xi=2+rem(Dist,2); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Eq. (3.2) in the paper s_ij=((ub(k:k+1)' - lb(k:k+1)') .*c/2)*S_func(xj_xi).*r_ij_vec; S_i=S_i+s_ij; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% end end S_i_total(k:k+1, :) = S_i; end X_new=c*S_i_total'+(TargetPosition)'; % Eq. (3.7) in the paper GrassHopperPositions_temp(i,:)=X_new'; end % GrassHopperPositions GrassHopperPositions=GrassHopperPositions_temp'; display(['At the iteration ', num2str(iter), ' there are ', num2str(Archive_member_no), ' non-dominated solutions in the archive']); end if (flag==1) TargetPosition = TargetPosition(1:dim-1); end figure Draw_ZDT1(); hold on plot(Archive_F(:,1),Archive_F(:,2),'ro','MarkerSize',8,'markerfacecolor','k');
3 仿真结果
4 参考文献
[1]郑嘉利, & 王哲. (2019). 一种基于蝗虫算法和极限学习机的RFID室内定位方法. CN109598320A.