function [Score,Best_pos,NGO_curve]=NGO(Search_Agents,Max_iterations,lb,ub,dim,fobj)
dimensions=dim;
Upperbound=ub;
Lowerbound=lb;
X0=initialization(Search_Agents,dim,ub,lb);
X = X0;
X_new=[];
fit=[];
fit_new=[];
NGO_curve=zeros(1,Max_iterations);
%%
for i =1:Search_Agents
L=X(i,:);
fit(i)=fobj(L); % Fitness evaluation (Explained at the top of the page. )
end
for t=1:Max_iterations % algorithm iteration
%% update: BEST proposed solution
[best , blocation]=min(fit);
if t==1
xbest=X(blocation,:); % Optimal location
fbest=best; % The optimization objective function
elseif best<fbest
fbest=best;
xbest=X(blocation,:);
end
%% UPDATE Northern goshawks based on PHASE1 and PHASE2
for i=1:Search_Agents
%% Phase 1: Exploration
I=round(1+rand);
k=randperm(Search_Agents,1);
P=X(k,:); % Eq. (3)
F_P=fit(k);
if fit(i)> F_P
X_new(i,:)=X(i,:)+rand(1,dimensions) .* (P-I.*X(i,:)); % Eq. (4)
else
X_new(i,:)=X(i,:)+rand(1,dimensions) .* (X(i,:)-P); % Eq. (4)
end
X_new(i,:) = max(X_new(i,:),Lowerbound);X_new(i,:) = min(X_new(i,:),Upperbound);
% update position based on Eq (5)
L=X_new(i,:);
fit_new(i)=fobj(L);
if(fit_new(i)<fit(i))
X(i,:) = X_new(i,:);
fit(i) = fit_new(i);
end
%% END PHASE 1
%% PHASE 2 Exploitation
R=0.02*(1-t/Max_iterations);% Eq.(6)
X_new(i,:)= X(i,:)+ (-R+2*R*rand(1,dimensions)).*X(i,:);% Eq.(7)
X_new(i,:) = max(X_new(i,:),Lowerbound);X_new(i,:) = min(X_new(i,:),Upperbound);
% update position based on Eq (8)
L=X_new(i,:);
fit_new(i)=fobj(L);
if(fit_new(i)<fit(i))
X(i,:) = X_new(i,:);
fit(i) = fit_new(i);
end
%% END PHASE 2
end% end for i=1:N
%%
%% SAVE BEST SCORE
best_so_far(t)=fbest; % save best solution so far
average(t) = mean (fit);
Score=fbest;
Best_pos=xbest;
NGO_curve(t)=Score;
end
%%
end
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
3 NGO_LSTM - 2.zip (9个子文件)
R2.m 180B
file2.mat 6KB
initialization.m 567B
main.m 1KB
eva2.m 186B
eva1.m 203B
LSTM_MIN.m 1KB
NGO.m 2KB
data.xlsx 36KB
共 9 条
- 1
资源评论
智能算法及其模型预测
- 粉丝: 1834
- 资源: 788
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功