【改进鲸鱼优化算法】增强型鲸鱼优化算法(Matlab代码实现)
个人主页:研学社的博客欢迎来到本博客
博主优势: 博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。r/>
座右铭:行百里者,半于九十。 1 概述
鲸鱼优化算法 (WOA) 是一个突出的问题解决器,广泛用于解决特征选择等 NP 难题。然而,它及其大多数变体都受到人口多样性低和搜索策略不佳的影响。为了减轻 WOA 的这些核心缺点,特别是为了处理功能选择问题,非常需要引入有效的策略。因此,本文致力于提出一种基于池化机制和2019种有效搜索策略的增强型鲸鱼优化算法E-WOA,分别是迁徙、优先选择和富集包围猎物。评估 E-WOA 的性能并与众所周知的 WOA 变体进行比较,以解决全局优化问题。获得的结果证明,E-WOA的性能优于WOA的变体。
2 运行结果
部分代码:
function = E_WOA(SearchAgents_no,Max_iterproblem_size,lb,ub)
% Initialize the positions of search agents
Positions = initialization(SearchAgents_no,problem_size,ub,lb);
for j = 1:SearchAgents_no
Fitness(j,1)= Function(Positions(j,:));
end
% Set the best position for leader
= sort(Fitness, 'ascend');
X_best = Positions(sorted_index(1),:);
Score_best = temp_fit(1);
% ==================================================== %
P_rate =20; % The portion rate
Pool.Kappa = 1.5 * SearchAgents_no; % The maximum pool size
Pool.position = zeros(0, problem_size);% The solutions stored in the pool
Idx0 = (SearchAgents_no - (Pool.Kappa * 0.3)+1);
X_worst = Positions(sorted_index(Idx0: end),:);
Pool = Pooling_Mechanism(Pool,problem_size,X_worst, X_best);
Convergence = zeros(1,Max_iter);
t = 1;
% Main loop
while t <= Max_iter
a2 = -1+t*((-1)/Max_iter);
% Randomly select a P portion of the humpback whales
P_portion = randperm(SearchAgents_no,P_rate);
Pop_Pool = Pool.position;
= RandIndex(size(Pop_Pool,1),SearchAgents_no);
%% Probability rate
p = rand(SearchAgents_no, 1);
%% Cauchy distribution
A = 0.5 + 0.1 * tan(pi * (rand(SearchAgents_no, 1) - 0.5));
Idx = find(A <= 0);
while ~ isempty(Idx)
A(Idx) = 0.5 + 0.1 * tan(pi * (rand(length(Idx), 1) - 0.5));
Idx = find(A <= 0);
end
A = min(A, 1);
for i = 1:size(Positions,1)
if (i ~= P_portion)
C = 2*rand; % Eq. (6) in the paper
b = 1;
for j=1:size(Positions,2)
l=(a2-1)*rand+1;
if p(i) < 0.5
if A(i) < 0.5 % Enriched encircling prey search strategy
rand_leader_index = floor(size(Pop_Pool,1)*rand()+1); % Randomly selected from the matrix Pool
P_rnd3 = Pop_Pool(rand_leader_index, j);
D_prim = abs(C * X_best(j) - P_rnd3);% Eq. (17)
X(i,j) =X_best(j)- A(i)*D_prim; % Eq. (16)
elseif A(i)>= 0.5 % Preferential selecting search strategy
X(i,j) = Positions(i,j) + A(i)*( C* Pop_Pool(P_rnd1(i),j)- Pop_Pool(P_rnd2(i),j)) ; % Eq. (15)
end
elseif p(i)>=0.5 % Spiral bubble-net attacking
D_prim =abs(X_best(j)- Positions(i,j)); % Eq. (10)
X(i,j)=D_prim * exp(b.*l).*cos(2*pi*l)+ X_best(j);% Eq. (9)
end
end
end
end
%% Migrating search strategy
best_max = max(X_best);
best_min = min(X_best);
P_portion = P_portion&#39;;
X_rnd=rand(size(P_portion,1),problem_size).* (ub - lb) + lb;% Eq.(13)
X_brnd =rand(size(P_portion,1),problem_size).*(best_max - best_min)+ best_min; % Eq.(14)
X(P_portion, :)= X_rnd -X_brnd; % Eq.(12)
%% Computing the fitness of whales
for i = 1: size(Positions,1)
X(i,:) = boundConstraint(X(i,:), Positions(i,:), lb,ub);
Fit(i,1) = Function(X(i,:));
if Fit(i,1) < Score_best
Score_best =Fit(i,1);
X_best =X(i,:);
end
end
I = (Fitness > Fit);
Ind = find(I == 1);
X_worst = Positions(Ind, :);
% Definition 1. (Pooling mechanism)
Pool = Pooling_Mechanism(Pool, problem_size, X_worst, X_best);
% Updating the position of whales
Fitness(Ind) = Fit(Ind) ;
Positions(Ind, :) = X(Ind, :);
Convergence(t) = Score_best;
t = t + 1;
end
end
3 参考文献
部分理论来源于网络,如有侵权请联系删除。
Enhanced whale optimization algorithm for medical feature selection: A COVID-19 case study - ScienceDirect
4 Matlab代码实现
页:
[1]