0
点赞
收藏
分享

微信扫一扫

【优化算法】先导粘菌算法(LSMA)【含Matlab源码 1436期】


一、获取代码方式

获取代码方式1:

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

获取代码方式2:

完整代码已上传我的资源:​​【优化算法】先导粘菌算法(LSMA)【含Matlab源码 1436期】​​

备注:

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

二、部分源代码

% Leader Slime Mould Algorithm (LSMA) source Code Version 1.0
%
% Developed in MATLAB R2018b

%_____________________________________________________________________________________________________


clearvars
close all
clc

disp('The LSMA is tracking the problem');

N=30; % Number of slime mould
Function_name='F12' % Name of the test function that can be from F1 to F23
MaxIT=500; % Maximum number of iterations

[lb,ub,dim,fobj]=Get_Functions_details(Function_name); % Function details

Times=31; %Number of independent times you want to run the AOSMA
display(['Number of independent runs: ', num2str(Times)]);

for i=1:Times
[Destination_fitness(i),bestPositions(i,:),Convergence_curve(i,:)]=LSMA(N,MaxIT,lb,ub,dim,fobj);
display(['The optimal fitness of LSMA is: ', num2str(Destination_fitness(i))]);
end

[bestfitness,index]=min(Destination_fitness);
disp('--------Best Fitness, Average Fitness, Standard Deviation and Best Solution--------');
display(['The best fitness of LSMA is: ', num2str(bestfitness)]);
display(['The average fitness of LSMA is: ', num2str(mean(Destination_fitness))]);
display(['The standard deviation fitness of LSMA is: ', num2str(std(Destination_fitness))]);
display(['The best location of LSMA is: ', num2str(bestPositions(index,:))]);

semilogy(Convergence_curve(index,:),'LineWidth',3);
xlabel('Iterations');
ylabel('Best fitness obtained so far');
legend('LSMA');
box on;
axis tight;
grid off;

%% Benchmark Test functions
function [lb,ub,dim,fobj] = Get_Functions_details(F)
switch F
case 'F1'
fobj = @F1;
lb=-100;
ub=100;
dim=30;

case 'F2'
fobj = @F2;
lb=-10;
ub=10;
dim=30;

case 'F3'
fobj = @F3;
lb=-100;
ub=100;
dim=30;

case 'F4'
fobj = @F4;
lb=-100;
ub=100;
dim=30;

case 'F5'
fobj = @F5;
lb=-30;
ub=30;
dim=30;

case 'F6'
fobj = @F6;
lb=-100;
ub=100;
dim=30;

case 'F7'
fobj = @F7;
lb=-1.28;
ub=1.28;
dim=30;

case 'F8'
fobj = @F8;
lb=-500;
ub=500;
dim=30;

case 'F9'
fobj = @F9;
lb=-5.12;
ub=5.12;
dim=30;

case 'F10'
fobj = @F10;
lb=-32;
ub=32;
dim=30;

case 'F11'
fobj = @F11;
lb=-600;
ub=600;
dim=30;

case 'F12'
fobj = @F12;
lb=-50;
ub=50;
dim=30;

case 'F13'
fobj = @F13;
lb=-50;
ub=50;
dim=30;

case 'F14'
fobj = @F14;
lb=-65.536;
ub=65.536;
dim=2;

case 'F15'
fobj = @F15;
lb=-5;
ub=5;
dim=4;

case 'F16'
fobj = @F16;
lb=-5;
ub=5;
dim=2;

case 'F17'
fobj = @F17;
lb=[-5,0];
ub=[10,15];
dim=2;

三、运行结果

【优化算法】先导粘菌算法(LSMA)【含Matlab源码 1436期】_matlab

四、matlab版本及参考文献

1 matlab版本

2014a

2 参考文献

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

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



举报

相关推荐

0 条评论