固定检测器数据与浮动车数据的融合算法

%%%%%%%%%%%%%%%%%%%5 
clc                  %清空命令窗口
clear                %从工作空间(计算机内存)中删除变量
tic, %开始计时
% 首先进行遗传算法
[P,T,R,S1,S2,S,Q] = nninit_test;   %BP网络初始化
aa=ones(S,1)*[-1 1];
popu=30;
initPpp=initializega(popu,aa,'gabpEval_test');
gen=80; % 遗传代数
% 遗传计算
[x endPop bPop trace]=ga(aa,'gabpEval_test',[],initPpp,[1e-6 1 1],'maxGenTerm',gen,...
  'normGeomSelect',[0.09],['arithXover'],[2],'nonUnifMutation',[2 gen 3]);
% x The best found Lets take a look at the performance of the ga during the
% run
subplot(2,1,1)
plot(trace(:,1),1./trace(:,3),'r-') %r-是红色 表示各个进化代中所有个体的平均适应度函数值
hold on
plot(trace(:,1),1./trace(:,2),'b-') %b-是蓝色 表示各个进化代中的最佳适应度函数值
xlabel('Generation');
ylabel('Sum-Squared Error');
subplot(2,1,2)
plot(trace(:,1),trace(:,3),'r-')    %r-是红色 表示各个进化代中所有个体的平均适应度函数值
hold on
plot(trace(:,1),trace(:,2),'b-')    %b-是蓝色 表示各个进化代中的最佳适应度函数值
xlabel('Generation');
ylabel('Fittness');
% 下面进行 wnn 算法
figure(2)
% 将遗传算法的结果分解为wnn网络所对应的权值、阈值
[W1, shift_b1, W2, scale_a1, P, T, A1, A2, SE, val]=gadecod_test(x);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55555

tic;
%初始化网络                       
IN=R;       
HN=S1;      
ON=S2;
N=300;
derros=zeros(1,(N+2));
studyspace=zeros(1,(N+2));
%初始参数
studyspace(1,2)=0.002;
amlf=1.001;
betat=0.999;
kkk=1.04;
mc=0.01;


v(:,:,2)=W1;
w=zeros(1,HN,N+2);
%W2(:,:,1)=rand(1,S1);
w(:,:,2)=W2;
a=zeros(1,HN,N+2);
a(:,:,2)=shift_b1';
b=zeros(1,HN,N+2);
b(:,:,2)=scale_a1';
%cshab;
mse=zeros(1,N+2);
ee=zeros(1,N+2);

%数据进行训练
for n=3:(N+2)

wdel=zeros(1,HN);
vdel=zeros(HN,IN); 
adel=zeros(1,HN);
bdel=zeros(1,HN);
wincrease=zeros(1,HN);
vincrease=zeros(HN,IN);
aincrease=zeros(1,HN);
bincrease=zeros(1,HN);
m=1;
while m=kkk*derros(n-1)
studyspace(1,n)=betat*studyspace(1,n-1);
end
for j=1:HN
wincrease(1,j)=-studyspace(1,n)*wdel(1,j)+mc*(w(1,j,n-1)-w(1,j,n-2));
w(1,j,n)=w(1,j,n-1)+wincrease(1,j);
for i=1:IN
vincrease(j,i)=-studyspace(1,n)*vdel(j,i)+mc*(v(j,i,n-1)-v(j,i,n-2));
v(j,i,n)=v(j,i,n-1)+vincrease(j,i);
end
aincrease(1,j)=-studyspace(1,n)*adel(1,j)+mc*(a(1,j,n-1)-a(1,j,n-2));
a(1,j,n)=a(1,j,n-1)+aincrease(1,j); 
bincrease(1,j)=-studyspace(1,n)*bdel(1,j)+mc*(b(1,j,n-1)-b(1,j,n-2));
b(1,j,n)=b(1,j,n-1)+bincrease(1,j);
end
end
%网络误差曲线
toc
plot(MSE(4:N+2)/Q);    title('GA优化后的误差')

%%%%%%%%5

figure(3)

plot(T,'r')   %title('目标信号')

hold on 
plot(y,'g*'); title('GA优化后Wnn的输出')

 

你可能感兴趣的:(总结)