1 简介
工业过程常含有显著的非线性,时变等复杂特性,传统的核极限学习机有时无法充分利用数据信息,所建软测量模型预测性能较差.为了提高核极限学习机的泛化能力和预测精度,提出一种哈里斯鹰算法结合核极限学习机软测量建模方法.通过哈里斯鹰优化极限学习机的惩罚系数和核宽,得到一组最优超参数;最后将该方法应用于脱丁烷塔过程软测量建模中.仿真结果表明,优化后的核极限学习机模型预测精度有明显的提高,验证了所提方法不仅是可行的,而且具有良好的预测精度和泛化性能.
2 部分代码
%%
function [Rabbit_Energy,Rabbit_Location,CNVG] = NCHHO_IoV(N,T,lb,ub,dim,fobj)
% initialize the location and Energy of the rabbit
Rabbit_Location=zeros(1,dim);
Rabbit_Energy=0;
%Initialize the locations of Harris' hawks
X=initialization(N,dim,ub,lb);
CNVG=zeros(1,T);
t=0; % Loop counter
while t<T
for i=1:size(X,1)
% Check boundries
FU=X(i,:)>ub;FL=X(i,:)<lb;X(i,:)=(X(i,:).*(~(FU+FL)))+ub.*FU+lb.*FL;
% fitness of locations
fitness=fobj(X(i,:));
% Update the location of Rabbit
if fitness>Rabbit_Energy
Rabbit_Energy=fitness;
Rabbit_Location=X(i,:);
end
end
E1=abs(2*(1-(t/T))-2); % factor to show the decreaing energy of rabbit
a1 = 4; % Initial chaotic map parameter configuration
teta = 0.7; % Initial chaotic map parameter configuration
% Update the location of Harris' hawks
for i=1:size(X,1)
for ii=1:4
Cm(1,ii) = abs((a1/4)*sin(pi*teta));
teta = Cm(1,ii);
end
E0=2*rand()-1; %-1<E0<1
Escaping_Energy=E1*(E0); % escaping energy of rabbit
if abs(Escaping_Energy)>=1
%% Exploration:
% Harris' hawks perch randomly based on 2 strategy:
q=rand();
rand_Hawk_index = floor(N*rand()+1);
X_rand = X(rand_Hawk_index, :);
if q<0.5
% perch based on other family members
X(i,:)=X_rand-Cm(1,1)*abs(X_rand-2*Cm(1,2)*X(i,:));
elseif q>=0.5
% perch on a random tall tree (random site inside group's home range)
X(i,:)=(Rabbit_Location(1,:)-mean(X))-Cm(1,3)*((ub-lb)*Cm(1,4)+lb);
end
elseif abs(Escaping_Energy)<1
%% Exploitation:
% Attacking the rabbit using 4 strategies regarding the behavior of the rabbit
%% phase 1: surprise pounce (seven kills)
% surprise pounce (seven kills): multiple, short rapid dives by different hawks
r=rand(); % probablity of each event
if r>=0.5 && abs(Escaping_Energy)<0.5 % Hard besiege
X(i,:)=(Rabbit_Location)-Escaping_Energy*abs(Rabbit_Location-X(i,:));
end
if r>=0.5 && abs(Escaping_Energy)>=0.5 % Soft besiege
Jump_strength=2*(1-rand()); % random jump strength of the rabbit
X(i,:)=(Rabbit_Location-X(i,:))-Escaping_Energy*abs(Jump_strength*Rabbit_Location-X(i,:));
end
%% phase 2: performing team rapid dives (leapfrog movements)
if r<0.5 && abs(Escaping_Energy)>=0.5 % Soft besiege % rabbit try to escape by many zigzag deceptive motions
w1=2*exp(-(8*t/T)^2); % Non-linear control Parameter
Jump_strength=2*(1-rand());
X1=w1*Rabbit_Location-Escaping_Energy*abs(Jump_strength*Rabbit_Location-X(i,:));
if fobj(X1)>fobj(X(i,:)) % improved move?
X(i,:)=X1;
else % hawks perform levy-based short rapid dives around the rabbit
X2=w1*Rabbit_Location-Escaping_Energy*abs(Jump_strength*Rabbit_Location-X(i,:))+rand(1,dim).*Levy(dim);
if (fobj(X2)>fobj(X(i,:))) % improved move?
X(i,:)=X2;
end
end
end
if r<0.5 && abs(Escaping_Energy)<0.5 % Hard besiege % rabbit try to escape by many zigzag deceptive motions
% hawks try to decrease their average location with the rabbit
w1=2*exp(-(8*t/T)^2);
Jump_strength=2*(1-rand());
X1=w1*Rabbit_Location-Escaping_Energy*abs(Jump_strength*Rabbit_Location-mean(X));
if fobj(X1)>fobj(X(i,:)) % improved move?
X(i,:)=X1;
else % Perform levy-based short rapid dives around the rabbit
X2=w1*Rabbit_Location-Escaping_Energy*abs(Jump_strength*Rabbit_Location-mean(X))+rand(1,dim).*Levy(dim);
if (fobj(X2)>fobj(X(i,:))) % improved move?
X(i,:)=X2;
end
end
end
%%
end
end
t=t+1;
CNVG(t)=Rabbit_Energy;
end
end
% ___________________________________
function o=Levy(d)
beta=1.5;
sigma=(gamma(1+beta)*sin(pi*beta/2)/(gamma((1+beta)/2)*beta*2^((beta-1)/2)))^(1/beta);
u=randn(1,d)*sigma;v=randn(1,d);step=u./abs(v).^(1/beta);
o=step;
end
3 仿真结果
4 参考文献
[1]彭甜等. "基于改进哈里斯鹰算法优化ELM的风速预测方法及系统.".
部分理论引用网络文献,若有侵权联系博主删除。
5 完整MATLAB代码与数据下载地址
见博客主页头条