0
点赞
收藏
分享

微信扫一扫

【优化算法】未来搜索优化算法(FSA)【含Matlab源码 1448期】


一、获取代码方式

获取代码方式1:

通过订阅紫极神光博客​付费专栏​,凭支付凭证,​私信博主​,可获得此代码。

获取代码方式2:

完整代码已上传我的资源:​​【优化算法】未来搜索优化算法(FSA)【含Matlab源码 1448期】​​

备注:

订阅紫极神光博客​付费专栏​,可免费获得​1​份代码(​有效期​为订阅日起,三天内有效);

二、部分源代码

%Future search algorithm for爋ptimization
%
%Cite this article
%
clc
clear
n=30; % Population size
iteration=1000; % Maximum number of "iterations"
r_time=30; % Number of runtime
d=1000; % Number of dimensions
% Lower limit/bounds/ a vector
Lb=-100*ones(1,d);
% Upper limit/bounds/ a vector
Ub=100*ones(1,d);

for r=1:r_time;
% Initialize the population/solutions
for i=1:n,
S(i,:)=Lb+(Ub-Lb).*rand(1,d);
for k=1:d
if S(i,k)>Ub(k), S(i,k)=Ub(k); end
if S(i,k)<Lb(k), S(i,k)=Lb(k); end
end
Fitness(i)=Fun(S(i,:));
end
% Find the initial best solution
[fmin,I]=min(Fitness);
best=S(I,:);
Lbe=S;
Lbest=Fitness;
%%main global loop
iter=0; % Iterations?counter
for t=1:iteration,

%%main local loop
for i=1:n,
S(i,:)=S(i,:)+(-S(i,:)+best)*rand+(-S(i,:)+Lbe(i,:))*rand;
for k=1:d
if S(i,k)>Ub(k), S(i,k)=Ub(k); end
if S(i,k)<Lb(k), S(i,k)=Lb(k); end
end

% Evaluate new solutions
Fnew(i)=Fun(S(i,:));
% Update the loacal best solution
if (Fnew(i)<=Lbest(i))
Lbe(i,:)=S(i,:);
Lbest(i)=Fnew(i);
end

% Update the current global best solution
if Fnew(i)<=fmin,
best=S(i,:);
fmin=Fnew(i);
end

end

% loop of the initial update
for i=1:n,
Si(i,:)=best+(best-Lbe(i,:)).*rand;
for k=1:d
if Si(i,k)>Ub(k), Si(i,k)=Ub(k); end
if Si(i,k)<Lb(k), Si(i,k)=Lb(k); end
end
Fitness(i)=Fun(Si(i,:));
% Update the loacal best solution
if ( Fitness(i)<=Fnew(i))
S(i,:)=Si(i,:);
Lbe(i,:)=Si(i);
end
end
[fmini,I]=min(Fitness);
besti=Si(I,:);
if fmini<=fmin,
best=besti;
fmin=fmini;
end
iter=iter+1;
fgbest(iter)=fmin;
iter_counter(iter)=iter;
end
% Output/display for each runtime
disp(['Number of Iterations: ',num2str(iter)]);
disp(['Best =',num2str(best),' fmin=',num2str(fmin)]);
gbest_r(r,:)=fgbest;
best_r(r,:)=best;
gbest(r)=min(fgbest);
end

[gbestscore,I]=min(gbest);
bestposition=best_r(I,:);
semilogy(gbest_r(I,:),'-r');

disp(['Number of runtime: ',num2str(r)]);
disp(['Best =',num2str(bestposition),' fmin=',num2str(gbestscore)]);

三、运行结果

【优化算法】未来搜索优化算法(FSA)【含Matlab源码 1448期】_搜索

四、matlab版本及参考文献

1 matlab版本

2014a

2 参考文献

[1] 包子阳,余继周,杨杉.智能优化算法及其MATLAB实例(第2版)[M].电子工业出版社,2016.

[2]张岩,吴水根.MATLAB优化算法源代码[M].清华大学出版社,2017.



举报

相关推荐

0 条评论