💥1 概述

蜿蝠算法是2010年杨教授基于群体智能提出的启发式搜索算法,是一种搜索全局最优解的有效方法。该算法基于迭代优化,初始化为一组随机解,然后迭代搜寻最优解,且在最优解周围通过随机飞行产生局部新解,加强局部搜索速度。该算法具有实现简单、参数少等特点。

该算法主要用于目标函数寻优,基于蝙蝠种群利用产生的声波搜索猎物和控制飞行方向的特征来实现函数的寻优。以一只蝙蝠作为基本单元,且每只蝙蝠都有一个适应值来对函数解空间进行优化。每只蝙蝠可以调整自身发射声波的响度、频率等对空间进行搜索,使整个种群的活动逐步由无序变为有序。但蝙蝠算法在寻优末段容易陷入局部的极值,本文引入变速度权重因子修正系数(和粒子群参数调整的自适应过程相似),尽可能避免局部极值的困境,从而达到全局寻优的效果。

多目标蝙蝠优化算法(Matlab代码实现)_matlab

📚2 运行结果

多目标蝙蝠优化算法(Matlab代码实现)_matlab_02

部分代码:

function [best,fmin,N_iter]=bat_algorithm(para)
% Default parameters
if nargin<1, para=[10 0.25 0.5]; end
n=para(1); % Population size, typically 10 to 25
A=para(2); % Loudness (constant or decreasing)
r=para(3); % Pulse rate (constant or decreasing)
% This frequency range determines the scalings
Qmin=0; % Frequency minimum
Qmax=2; % Frequency maximum
% Iteration parameters
%% In order to obtain better/more accurate results, N_iter
%% should be increased to N_iter=2000 or more if necessary.
N_iter=1000; % Total number of function evaluations
% Dimension of the search variables
d=3;
% Initial arrays
Q=zeros(n,1); % Frequency
v=zeros(n,d); % Velocities
% Initialize the population/solutions
for i=1:n,
Sol(i,:)=randn(1,d);
Fitness(i)=Fun(Sol(i,:));
end
% Find the current best
[fmin,I]=min(Fitness);
best=Sol(I,:);% ====================================================== %
% Note: As this is a demo, here we did not implement the %
% reduction of loudness and increase of emission rates. %
% Interested readers can do some parametric studies %
% and also implementation various changes of A and r etc %
% ====================================================== %% Start the iterations -- Bat Algorithm
for i_ter=1:N_iter,
% Loop over all bats/solutions
for i=1:n,
Q(i)=Qmin+(Qmin-Qmax)*rand;
v(i,:)=v(i,:)+(Sol(i,:)-best)*Q(i);
S(i,:)=Sol(i,:)+v(i,:);
% Pulse rate
if rand>r
S(i,:)=best+0.01*randn(1,d);
end % Evaluate new solutions
Fnew=Fun(S(i,:));
% If the solution improves or not too loudness
if (Fnew<=Fitness(i)) & (rand<A) ,
Sol(i,:)=S(i,:);
Fitness(i)=Fnew;
end % Update the current best
if Fnew<=fmin,
best=S(i,:);
fmin=Fnew;
end
end

🎉3 参考文献

1) Xin-She Yang, Bat algorithm for multi-objective optimization, Int. J. Bio-Inspired Computation, Vol.3, No.5, 267-274 (2011).

2) Xin-She Yang, Xingshi He, Bat Algorithm: Literature Review and Applications, Int. J. Bio-Inspired Computation,Vol. 5, No. 4, pp. 141-149 (2013).

​🌈​​4 Matlab代码实现