本文主要是介绍时序预测 | MATLAB实现GWO-ELM灰狼优化算法优化极限学习机时间序列预测,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
时序预测 | MATLAB实现GWO-ELM灰狼优化算法优化极限学习机时间序列预测
目录
- 时序预测 | MATLAB实现GWO-ELM灰狼优化算法优化极限学习机时间序列预测
- 效果一览
- 基本介绍
- 程序设计
- 参考资料
效果一览
基本介绍
1.MATLAB实现GWO-ELM灰狼优化算法优化极限学习机时间序列预测;
2.单变量时间序列预测;
3.运行环境Matlab2018及以上,运行主程序main即可,其余为函数文件无需运行,所有程序放在一个文件夹,data为数据集;
4.SSA-ELM麻雀算法优化极限学习机权值和偏置,命令窗口输出RMSE、MAE、R2、MAPE等评价指标。
程序设计
- 完整程序和数据下载方式1(资源处直接下载):MATLAB实现GWO-ELM灰狼优化算法优化极限学习机时间序列预测
- 完整程序和数据下载方式2(订阅《ELM极限学习机》专栏,同时可阅读《ELM极限学习机》专栏收录的所有内容,数据订阅后私信我获取):MATLAB实现GWO-ELM灰狼优化算法优化极限学习机时间序列预测
- 完整程序和数据下载方式3(订阅《智能学习》专栏,同时获取《智能学习》专栏收录程序5份,数据订阅后私信我获取):MATLAB实现GWO-ELM灰狼优化算法优化极限学习机时间序列预测
% Grey Wolf Optimizer
function [Best_pos,Best_score,curve]=GWO(SearchAgents_no,Max_iter,lb,ub,dim,fobj)% initialize alpha, beta, and delta_pos
Best_pos=zeros(1,dim);
Best_score=inf; %change this to -inf for maximization problemsBeta_pos=zeros(1,dim);
Beta_score=inf; %change this to -inf for maximization problemsDelta_pos=zeros(1,dim);
Delta_score=inf; %change this to -inf for maximization problems%Initialize the positions of search agents
Positions=initialization(SearchAgents_no,dim,ub,lb);curve=zeros(1,Max_iter);l=0;% Loop counter% Main loop
while l<Max_iterfor i=1:size(Positions,1) % Return back the search agents that go beyond the boundaries of the search spaceFlag4ub=Positions(i,:)>ub;Flag4lb=Positions(i,:)<lb;Positions(i,:)=(Positions(i,:).*(~(Flag4ub+Flag4lb)))+ub.*Flag4ub+lb.*Flag4lb; % Calculate objective function for each search agentfitness=fobj(Positions(i,:));% Update Alpha, Beta, and Deltaif fitness<Best_score Best_score=fitness; % Update alphaBest_pos=Positions(i,:);endif fitness>Best_score && fitness<Beta_score Beta_score=fitness; % Update betaBeta_pos=Positions(i,:);endif fitness>Best_score && fitness>Beta_score && fitness<Delta_score Delta_score=fitness; % Update deltaDelta_pos=Positions(i,:);endenda=2-l*((2)/Max_iter); % a decreases linearly fron 2 to 0% Update the Position of search agents including omegasfor i=1:size(Positions,1)for j=1:size(Positions,2) r1=rand(); % r1 is a random number in [0,1]r2=rand(); % r2 is a random number in [0,1]A1=2*a*r1-a; % Equation (3.3)C1=2*r2; % Equation (3.4)D_alpha=abs(C1*Best_pos(j)-Positions(i,j)); % Equation (3.5)-part 1X1=Best_pos(j)-A1*D_alpha; % Equation (3.6)-part 1r1=rand();r2=rand();A2=2*a*r1-a; % Equation (3.3)C2=2*r2; % Equation (3.4)D_beta=abs(C2*Beta_pos(j)-Positions(i,j)); % Equation (3.5)-part 2X2=Beta_pos(j)-A2*D_beta; % Equation (3.6)-part 2 r1=rand();r2=rand(); A3=2*a*r1-a; % Equation (3.3)C3=2*r2; % Equation (3.4)D_delta=abs(C3*Delta_pos(j)-Positions(i,j)); % Equation (3.5)-part 3X3=Delta_pos(j)-A3*D_delta; % Equation (3.5)-part 3 Positions(i,j)=(X1+X2+X3)/3;% Equation (3.7)endendl=l+1; curve(l)=Best_score;
end
参考资料
[1] https://blog.csdn.net/kjm13182345320/article/details/129215161
[2] https://blog.csdn.net/kjm13182345320/article/details/128105718
这篇关于时序预测 | MATLAB实现GWO-ELM灰狼优化算法优化极限学习机时间序列预测的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!