回归预测 | Matlab基于SO-GRU蛇群算法优化门控循环单元的数据多输入单输出回归预测
效果一览
基本介绍
1.Matlab基于SO-GRU蛇群算法优化门控循环单元的数据多输入单输出回归预测(完整源码和数据)
2.优化参数为:学习率,隐含层节点,正则化参数。
3.多特征输入单输出的回归预测。程序内注释详细,直接替换数据就可以用。
4.程序语言为matlab,程序可出预测效果图,迭代优化图,相关分析图,运行环境matlab2020b及以上。评价指标包括:R2、MAE、MSE、RMSE和MAPE等。
5.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。
文章来源:https://www.toymoban.com/news/detail-786124.html
程序设计
- 完整源码和数据获取方式(资源处下载):Matlab基于SO-GRU蛇群算法优化门控循环单元的数据多输入单输出回归预测。
function [fval,Xfood,gbest_t] = SO(N,T,lb,ub,dim,fobj)
%initial
vec_flag=[1,-1];
Threshold=0.25;
Thresold2= 0.6;
C1=0.5;
C2=.05;
C3=2;
X=initialization(N,dim,ub,lb);
for i=1:N
fitness(i)=feval(fobj,X(i,:));
end
[GYbest, gbest] = min(fitness);
Xfood = X(gbest,:);
%Diving the swarm into two equal groups males and females
Nm=round(N/2);%eq.(2&3)
Nf=N-Nm;
Xm=X(1:Nm,:);
Xf=X(Nm+1:N,:);
fitness_m=fitness(1:Nm);
fitness_f=fitness(Nm+1:N);
[fitnessBest_m, gbest1] = min(fitness_m);
Xbest_m = Xm(gbest1,:);
[fitnessBest_f, gbest2] = min(fitness_f);
Xbest_f = Xf(gbest2,:);
for t = 1:T
disp([' ',num2str(t),' ε '])
Temp=exp(-((t)/T)); %eq.(4)
Q=C1*exp(((t-T)/(T)));%eq.(5)
if Q>1 Q=1; end
% Exploration Phase (no Food)
if Q<Threshold
for i=1:Nm
for j=1:1:dim
rand_leader_index = floor(Nm*rand()+1);
X_randm = Xm(rand_leader_index, :);
flag_index = floor(2*rand()+1);
Flag=vec_flag(flag_index);
Am=exp(-fitness_m(rand_leader_index)/(fitness_m(i)+eps));%eq.(7)
Xnewm(i,j)=X_randm(j)+Flag*C2*Am*((ub(j)-lb(j))*rand+lb(j));%eq.(6)
end
end
for i=1:Nf
for j=1:1:dim
rand_leader_index = floor(Nf*rand()+1);
X_randf = Xf(rand_leader_index, :);
flag_index = floor(2*rand()+1);
Flag=vec_flag(flag_index);
Af=exp(-fitness_f(rand_leader_index)/(fitness_f(i)+eps));%eq.(9)
Xnewf(i,j)=X_randf(j)+Flag*C2*Af*((ub(j)-lb(j))*rand+lb(j));%eq.(8)
end
end
else %Exploitation Phase (Food Exists)
if Temp>Thresold2 %hot
for i=1:Nm
flag_index = floor(2*rand()+1);
Flag=vec_flag(flag_index);
for j=1:1:dim
Xnewm(i,j)=Xfood(j)+C3*Flag*Temp*rand*(Xfood(j)-Xm(i,j));%eq.(10)
end
end
for i=1:Nf
flag_index = floor(2*rand()+1);
Flag=vec_flag(flag_index);
for j=1:1:dim
Xnewf(i,j)=Xfood(j)+Flag*C3*Temp*rand*(Xfood(j)-Xf(i,j));%eq.(10)
end
end
else %cold
if rand>0.6 %fight
for i=1:Nm
for j=1:1:dim
FM=exp(-(fitnessBest_f)/(fitness_m(i)+eps));%eq.(13)
Xnewm(i,j)=Xm(i,j) +C3*FM*rand*(Q*Xbest_f(j)-Xm(i,j));%eq.(11)
end
end
for i=1:Nf
for j=1:1:dim
FF=exp(-(fitnessBest_m)/(fitness_f(i)+eps));%eq.(14)
Xnewf(i,j)=Xf(i,j)+C3*FF*rand*(Q*Xbest_m(j)-Xf(i,j));%eq.(12)
end
end
else%mating
for i=1:Nm
for j=1:1:dim
Mm=exp(-fitness_f(i)/(fitness_m(i)+eps));%eq.(17)
Xnewm(i,j)=Xm(i,j) +C3*rand*Mm*(Q*Xf(i,j)-Xm(i,j));%eq.(15
end
end
for i=1:Nf
for j=1:1:dim
Mf=exp(-fitness_m(i)/(fitness_f(i)+eps));%eq.(18)
Xnewf(i,j)=Xf(i,j) +C3*rand*Mf*(Q*Xm(i,j)-Xf(i,j));%eq.(16)
end
end
参考资料
[1] https://blog.csdn.net/kjm13182345320/article/details/129215161
[2] https://blog.csdn.net/kjm13182345320/article/details/128105718文章来源地址https://www.toymoban.com/news/detail-786124.html
到了这里,关于回归预测 | Matlab基于SO-GRU蛇群算法优化门控循环单元的数据多输入单输出回归预测的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!