1 简介
工业过程常含有显著的非线性,时变等复杂特性,传统的核极限学习机有时无法充分利用数据信息,所建软测量模型预测性能较差.为了提高核极限学习机的泛化能力和预测精度,提出一种遗传算法结合核极限学习机软测量建模方法.通过遗传优化极限学习机的惩罚系数和核宽,得到一组最优超参数;最后将该方法应用于脱丁烷塔过程软测量建模中.仿真结果表明,优化后的核极限学习机模型预测精度有明显的提高,验证了所提方法不仅是可行的,而且具有良好的预测精度和泛化性能.
2 部分代码
%清空运行空间
clc;
clear;
close all;
wmax=0.9;
wmin=0;%速度的上限及下限
itmax=50;%迭代代数
%速度更新参数
c1=2;
c2=2;
for iter=1:itmax
W(iter)=wmax-((wmax-wmin)/itmax)*iter;
end;
a=-1;
b=2;
N=200;
D=2;
m=0.1;
n=3;
tcl=0.05;
f='x.*sin(4*pi.*x)-y.*sin(4*pi.*y+pi+1)';
[x,y]=meshgrid(a:tcl:b,a:tcl:b);
vxp=x;
vyp=y;
vzp=eval(f);
x=[];
vmfit=[];
x=a+(b-a)*rand(N,D,1);
V=wmin+(wmax-wmin)*rand(N,D,1);
for i=1:N
F(i,1,1)=x(i,1,1)*sin(4*pi*x(i,1,1))-x(i,2,1)*sin(4*pi*x(i,2,1)+pi+1);
end;
media=mean(F(:,1,1));
vmfit=[vmfit media];
[C,I]=max(abs(F(:,1,1)));
B(1,1,1)=C;
gbest(1,1,1)=x(I,1,1);
gbest(1,2,1)=x(I,1,1);
for p=1:N
for r=1:D
G(p,r,1)=gbest(1,r,1);
end
end
Fbest(1,1,1)=G(1,1,1)*sin(4*pi.*G(1,1,1))-G(1,2,1)*sin(4*pi.*G(1,2,1)+pi+1);
for i=1:N
pbest(i,:,1)=x(i,:,1);
pbest
end
Fb(1,1,1)=gbest(1,1,1)*sin(4*pi.*gbest(1,1,1))-gbest(1,2,1)*sin(4*pi.*gbest(1,2,1)+pi+1);
for j=2:itmax
V(:,:,j)=W(j-1)*V(:,:,j-1)+c1*rand*(pbest(:,:,j-1)-x(:,:,j-1))+c2*rand*(G(:,:,j-1)-x(:,:,j-1))
x(:,:,j)=x(:,:,j-1)+V(:,:,j);
for xx=1:N
for yy=1:D
if x(xx,yy,j)<a
x(xx,yy,j)=a;
end;
if x(xx,yy,j)>b
x(xx,yy,j)=b;
end;
end;
end;
for i=1:N
F(i,1,j)=x(i,1,j)*sin(4*pi.*x(i,1,j))-x(i,2,j)*sin(4*pi.*x(i,2,j)+pi+1);
end;
media=mean(F(:,1,j));
vmfit=[vmfit media];
[C,I]=max(abs(F(:,:,j)));
B(1,1,j)=C;
gbest(1,1,j)=x(I,1,j);
gbest(1,2,j)=x(I,2,j);
Fb(1,1,j)=gbest(1,1,j)*sin(4*pi.*gbest(1,1,j))-gbest(1,2,j)*sin(4*pi.*gbest(1,2,j)+pi+1);
[C,I]=max(Fb(1,1,:));
if C>Fb(1,1,j)
gbest(1,1,j)=gbest(1,1,I);
gbest(1,2,j)=gbest(1,2,I);
end;
for p=1:N
for r=1:D
G(p,r,j)=gbest(1,r,j);
end;
end;
Fbest(1,1,j)=G(1,1,j)*sin(4*pi.*G(1,1,j))-G(1,2,j)*sin(4*pi.*G(1,2,j)+pi+1);
for i=1:N
[C,I]=max(F(i,1,:));
if F(i,1,j)>=C
pbest(i,:,j)=x(i,:,j);
else
pbest(i,:,j)=x(i,:,I);
end;
end;
end
gbest(1,:,itmax)
Fbest(1,1,itmax)
%Random deployment algorithm
sx=a+(b-a)*rand(N,D,1);
sy=a+(b-a)*rand(N,D,1);
sz=a+(b-a)*rand(N,D,1);
%
%Gradient direction algorithm
figure(1);
mesh(vxp,vyp,vzp);
hold on;
plot3(x(:,1,1),x(:,2,1),F(:,1,1),'k*')
title('Gradient direction algorithm hydrophone distribution');
%Left view
%view(-90,0)
xlabel('Simulated underwater area width(kilometre)');
ylabel('Simulated underwater area length(kilometre)');
zlabel('Simulated water depth(kilometre)');
grid on;
figure(2)
mesh(vxp,vyp,vzp);
hold on;
plot3(sx,sy,sz,'k*','MarkerSize',5)
title('Random deployment algorithm hydrophone distribution');
%Left view
%view(-90,0)
xlabel('Simulated underwater area width(kilometre)');
ylabel('Simulated underwater area length(kilometre)');
zlabel('Simulated water depth(kilometre)');
grid on;
figure(3);
i_draw4=1:itmax;
Fbest1(i_draw4)=Fbest(1,1,i_draw4);
i_draw4=i_draw4';
plot(i_draw4,Fbest1);
hold on;
plot(vmfit,'r');
hold off;
title('Optimal, average function value change trend');
xlabel('Generations');
ylabel('J(\theta)');
grid on;
3 仿真结果
4 参考文献
[1]马晨佩, 李明辉, 巩强令, & 杨白月. (2021). 基于麻雀搜索算法优化支持向量机的滚动轴承故障诊断. 科学技术与工程, 21(10), 5.
[2]盛晓晨, 史旭东, 熊伟丽. 改进粒子群优化的极限学习机软测量建模方法[J]. 计算机应用研究, 2020, 37(6):5.
[3]范君. 基于粒子群算法优化混合核极限学习机的构造煤厚度预测研究与应用. Diss. 中国矿业大学.
部分理论引用网络文献,若有侵权联系博主删除。