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
disp(['第',num2str(t),'次迭代'])
%% 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
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
5 NGO-DBN分类 - 2.zip (21个子文件)
getObjValue.m 1KB
Toolbox
tanh_opt.m 87B
initialization.m 456B
nnapplygrads.m 763B
dbntrain.m 286B
softmax.m 151B
rbmtrain.m 1KB
nnsetup.m 2KB
nnff.m 2KB
nnpredict.m 172B
rbmdown.m 119B
sigm.m 63B
nnbp.m 2KB
sigmrnd.m 98B
dbnunfoldtonn.m 653B
rbmup.m 123B
dbnsetup.m 600B
nntrain.m 2KB
main.m 2KB
数据集.xlsx 73KB
NGO.m 2KB
共 21 条
- 1
资源评论
智能算法及其模型预测
- 粉丝: 1834
- 资源: 788
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功