一种新的群智能算法—黏菌算法

介绍一种新的群智能算法—黏菌算法

近些年群智能算法由于其效率较高,使用方便的优点引起了广大科研者的关注与兴趣。最近看文献,温州大学的李世民(现在去复旦读研究生了)提出了一种新的群智能优化算法----黏菌算法(Slime mould algorithm)[1]。在此附上代码

算法(Matlab实现)

SMA.m

% Max_iter: maximum iterations, N: populatoin size, Convergence_curve: Convergence curve
% To run SMA: [Destination_fitness,bestPositions,Convergence_curve]=SMA(N,Max_iter,lb,ub,dim,fobj)
function [Destination_fitness,bestPositions,Convergence_curve]=SMA(N,Max_iter,lb,ub,dim,fobj)
disp('SMA is now tackling your problem')% initialize position
bestPositions=zeros(1,dim);
Destination_fitness=inf;%change this to -inf for maximization problems
AllFitness = inf*ones(N,1);%record the fitness of all slime mold
weight = ones(N,dim);%fitness weight of each slime mold
%Initialize the set of random solutions
X=initialization(N,dim,ub,lb);
Convergence_curve=zeros(1,Max_iter);
it=1;  %Number of iterations
lb=ones(1,dim).*lb; % lower boundary
ub=ones(1,dim).*ub; % upper boundary
z=0.03; % parameter% Main loop
while  it <= Max_iter%sort the fitnessfor i=1:N% Check if solutions go outside the search space and bring them backFlag4ub=X(i,:)>ub;Flag4lb=X(i,:)<lb;X(i,:)=(X(i,:).*(~(Flag4ub+Flag4lb)))+ub.*Flag4ub+lb.*Flag4lb;AllFitness(i) = fobj(X(i,:));end[SmellOrder,SmellIndex] = sort(AllFitness);  %Eq.(2.6)worstFitness = SmellOrder(N);bestFitness = SmellOrder(1);S=bestFitness-worstFitness+eps;  % plus eps to avoid denominator zero%calculate the fitness weight of each slime moldfor i=1:Nfor j=1:dimif i<=(N/2)  %Eq.(2.5)weight(SmellIndex(i),j) = 1+rand()*log10((bestFitness-SmellOrder(i))/(S)+1);elseweight(SmellIndex(i),j) = 1-rand()*log10((bestFitness-SmellOrder(i))/(S)+1);endendend%update the best fitness value and best positionif bestFitness < Destination_fitnessbestPositions=X(SmellIndex(1),:);Destination_fitness = bestFitness;enda = atanh(-(it/Max_iter)+1);   %Eq.(2.4)b = 1-it/Max_iter;% Update the Position of search agentsfor i=1:Nif rand<z     %Eq.(2.7)X(i,:) = (ub-lb)*rand+lb;elsep =tanh(abs(AllFitness(i)-Destination_fitness));  %Eq.(2.2)vb = unifrnd(-a,a,1,dim);  %Eq.(2.3)vc = unifrnd(-b,b,1,dim);for j=1:dimr = rand();A = randi([1,N]);  % two positions randomly selected from populationB = randi([1,N]);if r<p    %Eq.(2.1)X(i,j) = bestPositions(j)+ vb(j)*(weight(i,j)*X(A,j)-X(B,j));elseX(i,j) = vc(j)*X(i,j);endendendendConvergence_curve(it)=Destination_fitness;it=it+1;
endend

Main.m

// An highlighted block
clear all
close all
clcN=30; % Number of search agentsFunction_name='F1'; % Name of the test function, range from F1-F13T=500; % Maximum number of iterationsdimSize = 30;   %dimension size% Load details of the selected benchmark function
[lb,ub,dim,fobj]=Get_Functions_SMA(Function_name,dimSize);[Destination_fitness,bestPositions,Convergence_curve]=SMA(N,T,lb,ub,dim,fobj);%Draw objective space
figure,
hold on
semilogy(Convergence_curve,'Color','b','LineWidth',4);
title('Convergence curve')
xlabel('Iteration');
ylabel('Best fitness obtained so far');
axis tight
grid off
box on
legend('SMA')display(['The best location of SMA is: ', num2str(bestPositions)]);
display(['The best fitness of SMA is: ', num2str(Destination_fitness)]);

Initialization.m

% This function initialize the first population of search agents
function Positions=initialization(SearchAgents_no,dim,ub,lb)Boundary_no= size(ub,2); % numnber of boundaries% If the boundaries of all variables are equal and user enter a signle
% number for both ub and lb
if Boundary_no==1Positions=rand(SearchAgents_no,dim).*(ub-lb)+lb;
end% If each variable has a different lb and ub
if Boundary_no>1for i=1:dimub_i=ub(i);lb_i=lb(i);Positions(:,i)=rand(SearchAgents_no,1).*(ub_i-lb_i)+lb_i;end
end

Get_Functions_SMA.m

function [lb,ub,dim,fobj] = Get_Functions_SMA(F,DimValue)switch Fcase 'F1'fobj = @F1;lb=-100;ub=100;dim=DimValue;case 'F2'fobj = @F2;lb=-10;ub=10;dim=DimValue;case 'F3'fobj = @F3;lb=-100;ub=100;dim=DimValue;case 'F4'fobj = @F4;lb=-100;ub=100;dim=DimValue;case 'F5'fobj = @F5;lb=-30;ub=30;dim=DimValue;case 'F6'fobj = @F6;lb=-100;ub=100;dim=DimValue;case 'F7'fobj = @F7;lb=-1.28;ub=1.28;dim=DimValue;case 'F8'fobj = @F8;lb=-500;ub=500;dim=DimValue;case 'F9'fobj = @F9;lb=-5.12;ub=5.12;dim=DimValue;case 'F10'fobj = @F10;lb=-32;ub=32;dim=DimValue;case 'F11'fobj = @F11;lb=-600;ub=600;dim=DimValue;case 'F12'fobj = @F12;lb=-50;ub=50;dim=DimValue;case 'F13'fobj = @F13;lb=-50;ub=50;dim=DimValue;
endend% F1function o = F1(x)
o=sum(x.^2);
end% F2function o = F2(x)
o=sum(abs(x))+prod(abs(x));
end% F3function o = F3(x)
dim=size(x,2);
o=0;
for i=1:dimo=o+sum(x(1:i))^2;
end
end% F4function o = F4(x)
o=max(abs(x));
end% F5function o = F5(x)
dim=size(x,2);
o=sum(100*(x(2:dim)-(x(1:dim-1).^2)).^2+(x(1:dim-1)-1).^2);
end% F6function o = F6(x)
o=sum(abs((x+.5)).^2);
end% F7function o = F7(x)
dim=size(x,2);
o=sum([1:dim].*(x.^4))+rand;
end% F8function o = F8(x)
o=sum(-x.*sin(sqrt(abs(x))));
end% F9function o = F9(x)
dim=size(x,2);
o=sum(x.^2-10*cos(2*pi.*x))+10*dim;
end% F10function o = F10(x)
dim=size(x,2);
o=-20*exp(-.2*sqrt(sum(x.^2)/dim))-exp(sum(cos(2*pi.*x))/dim)+20+exp(1);
end% F11function o = F11(x)
dim=size(x,2);
o=sum(x.^2)/4000-prod(cos(x./sqrt([1:dim])))+1;
end% F12function o = F12(x)
dim=size(x,2);
o=(pi/dim)*(10*((sin(pi*(1+(x(1)+1)/4)))^2)+sum((((x(1:dim-1)+1)./4).^2).*...
(1+10.*((sin(pi.*(1+(x(2:dim)+1)./4)))).^2))+((x(dim)+1)/4)^2)+sum(Ufun(x,10,100,4));
end% F13function o = F13(x)
dim=size(x,2);
o=.1*((sin(3*pi*x(1)))^2+sum((x(1:dim-1)-1).^2.*(1+(sin(3.*pi.*x(2:dim))).^2))+...
((x(dim)-1)^2)*(1+(sin(2*pi*x(dim)))^2))+sum(Ufun(x,5,100,4));
endfunction o=Ufun(x,a,k,m)
o=k.*((x-a).^m).*(x>a)+k.*((-x-a).^m).*(x<(-a));
end

参考文献
[1]: Li, S., Chen, H., Wang, M., Heidari, A. A., & Mirjalili, S. (2020). Slime mould algorithm: A new method for stochastic optimization. Future Generation Computer Systems.
[2]: http://www.aliasgharheidari.com/SMA.html
[3]:https://www.researchgate.net/publication/340527543_Matlab_code_of_Slime_Mould_Algorithm_SMA

介绍一种新的群智能算法---黏菌算法相关推荐

  1. 2018-3-23论文一种新的群智能算法--狼群算法(框架结构+感想一点点)

    一.文章的总体的结构 中文摘要:  总体的说提出了一种算法,并应用与15个基准函数---得出结论 英文摘要: 0     引言------ 各个群智能算法的列举+解释群智能算法的好处,本质 1     ...

  2. 基于黏菌算法的函数寻优算法

    文章目录 一.理论基础 1.黏菌算法 (1)接近食物 (2)包裹食物 (3)获取食物 2.SMA算法伪代码 二.仿真实验与分析 三.参考文献 一.理论基础 1.黏菌算法 黏菌算法(Slime Moul ...

  3. 蝙蝠算法c语言,一种新颖的群智能算法:飞蛾扑火优化算法

    李志明+莫愿斌+张森 摘要 飞蛾扑火优化(MFO)算法是一种新颖的群智能优化算法,该算法的主要灵感来源于飞蛾在自然界中被称为横向定位的飞行方式.作为一种新提出的仿生群智能优化算法,分析了飞蛾扑火优化算 ...

  4. 基于群智能的路径规划算法(三)------遗传算法

       本系列文章主要记录学习基于群智能的路径规划算法过程中的一些关键知识点,并按照理解对其进行描述和进行相关思考.    主要学习资料是来自 小黎的Ally 的 <第2期课程-基于群智能的三维路 ...

  5. 基于群智能的路径规划算法(四)------人工蜂群算法

       本系列文章主要记录学习基于群智能的路径规划算法过程中的一些关键知识点,并按照理解对其进行描述和进行相关思考.    主要学习资料是来自 小黎的Ally 的 <第2期课程-基于群智能的三维路 ...

  6. c语言gga字符串校验和代码,一种新的Java智能卡上字节码校验算法.pdf

    您所在位置:网站首页 > 海量文档 &nbsp>&nbsp计算机&nbsp>&nbspJava 一种新的Java智能卡上字节码校验算法.pdf4页 本 ...

  7. 黏菌算法(Slime Mould Algorithm,SMA)

    文章目录 1 算法思想 2 算法步骤 3 求函数最值(Python实现) 4 算法进阶 直接改进SMA 融合别的智能优化算法来改进SMA SMA及其改进的应用 1 算法思想 黏菌算法由李世民等人发表于 ...

  8. 改进交叉算子的自适应人工蜂群黏菌算法-附代码

    改进交叉算子的自适应人工蜂群黏菌算法 文章目录 改进交叉算子的自适应人工蜂群黏菌算法 1.黏菌算法 2.改进黏菌算法 2.1 自适应可调节反馈因子 2.2 算数交叉算子 2.3 改进的人工蜂群搜索策略 ...

  9. 精英反向与二次插值改进的黏菌算法-附代码

    精英反向与二次插值改进的黏菌算法 文章目录 精英反向与二次插值改进的黏菌算法 1.黏菌算法 2.改进黏菌算法 2.1 精英反向学习机制 2.2 二次插值方法 3.实验结果 4.参考文献 5.Matla ...

最新文章

  1. cout 数组_C语言学习笔记(十)二维数组内存预设
  2. 细节定成败!汕头网络推广提醒你在做网站内容收录时需注意什么?
  3. Winter is coming,明星公司也裁员了...
  4. sqlite 常用命令
  5. HG8240电信光猫禁用TR069之修改配置法
  6. 工作3年,还不懂单点登录系统?看看这8幅漫画~
  7. Linux宝库快讯 | OpenStack中国日更名OpenInfra中国日
  8. 判断闰年的c语言程序_身为程序员还记得C语言经典算法(附带答案)吗?
  9. python动态演示数据gdp_荐爬取世界各国历年的GDP数据
  10. 软件质量保证管理办法
  11. 全志v3s学习笔记(6)——Bsp内核编译与烧录
  12. xheditor html5,Flask项目集成富文本编辑器XHEditor
  13. excel填充序列_分分钟搞定10万个序号自动填充,拒绝加班,你还在手动输入吗?...
  14. 一元三次方程求解matlab_为什么一元n次代数方程必有n个根?
  15. 苯酚吸附专用树脂 污水中的苯酚怎么去除
  16. Python小爬虫实例
  17. 计算机中的ins是什么功能,insert键的功能是什么
  18. 微软同步工具 for linux,使用SyncToy 同步Windows数据到linux
  19. 【论文笔记_自蒸馏_2021】GROUND-TRUTH TARGETS DAMPEN REGULARIZATION IMPOSED BY SELF-DISTILLATION
  20. k8s节点资源耗尽处理

热门文章

  1. 端口隔离和VLAN内ARP代理
  2. mpp与mysql集群_MPPDB集群高可用设计
  3. 最流行的三个开源DEM离散元…
  4. 案例分享-智慧景区智能管控系统
  5. 赣州seo教您如何利用文章页来做长尾关键词优化?
  6. SCARA四轴机器人丝杆花键_SCARA机器人专用滚珠丝杆花键
  7. k重特征值必有k个线性无关的_大学线性代数必过复习资料
  8. python定义一个空数组_python数组 1_python 数组最后一个元素_python定义一个空数组 - 云+社区 - 腾讯云...
  9. mysql中xml字段提取_从Mysql XML转储中提取数据xml.dom.minidom
  10. 鼠标滑轮一滚动Excel就停止工作