1 简介
蚁狮算法( ALO) 通过对随机解的探索,逐渐寻找近似最优解。与粒子群等优化算法不同的是,在 ALO 算法中有两类种群个体,即蚂蚁和蚁狮。ALO 算法的寻优过程模拟蚁狮捕食的六个基本步骤: 蚂蚁的随机移动、蚁狮建立陷阱、蚂蚁落入陷阱、蚂蚁滑向蚁狮、蚁狮捕捉蚂蚁和重建陷阱。ALO 算法的基本步骤和数学模型如下:
多目标蚁狮算法( Multi - objective ant lion optimizer, MOALO) 是用基本蚁狮算法求解
多目标问题。在单目标优化问题中,只需选择适应度函数最优的个体。而在多目标优化中,需要计算多个适应度函数的值,并通过 Pareto 支配关系选择最优解,放入外部存档中。
2 部分代码
%_________________________________________________________________________%
% Multi-Objective Ant Lion Optimizer (MALO) source codes demo %
% version 1.0 %
% %
% %
%_________________________________________________________________________%
clc;
clear;
close all;
% Change these details with respect to your problem%%%%%%%%%%%%%%
ObjectiveFunction=@ZDT1;
dim=5;
lb=0;
ub=1;
obj_no=2;
if size(ub,2)==1
ub=ones(1,dim)*ub;
lb=ones(1,dim)*lb;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Initial parameters of the MODA algorithm
max_iter=100;
N=100;
ArchiveMaxSize=100;
Archive_X=zeros(100,dim);
Archive_F=ones(100,obj_no)*inf;
Archive_member_no=0;
r=(ub-lb)/2;
V_max=(ub(1)-lb(1))/10;
Elite_fitness=inf*ones(1,obj_no);
Elite_position=zeros(dim,1);
Ant_Position=initialization(N,dim,ub,lb);
fitness=zeros(N,2);
V=initialization(N,dim,ub,lb);
iter=0;
position_history=zeros(N,max_iter,dim);
for iter=1:max_iter
for i=1:N %Calculate all the objective values first
Particles_F(i,:)=ObjectiveFunction(Ant_Position(:,i)');
if dominates(Particles_F(i,:),Elite_fitness)
Elite_fitness=Particles_F(i,:);
Elite_position=Ant_Position(:,i);
end
end
[Archive_X, Archive_F, Archive_member_no]=UpdateArchive(Archive_X, Archive_F, Ant_Position, Particles_F, Archive_member_no);
if Archive_member_no>ArchiveMaxSize
Archive_mem_ranks=RankingProcess(Archive_F, ArchiveMaxSize, obj_no);
[Archive_X, Archive_F, Archive_mem_ranks, Archive_member_no]=HandleFullArchive(Archive_X, Archive_F, Archive_member_no, Archive_mem_ranks, ArchiveMaxSize);
else
Archive_mem_ranks=RankingProcess(Archive_F, ArchiveMaxSize, obj_no);
end
Archive_mem_ranks=RankingProcess(Archive_F, ArchiveMaxSize, obj_no);
% Chose the archive member in the least population area as arrtactor
% to improve coverage
index=RouletteWheelSelection(1./Archive_mem_ranks);
if index==-1
index=1;
end
Elite_fitness=Archive_F(index,:);
Elite_position=Archive_X(index,:)';
Random_antlion_fitness=Archive_F(1,:);
Random_antlion_position=Archive_X(1,:)';
for i=1:N
index=0;
neighbours_no=0;
RA=Random_walk_around_antlion(dim,max_iter,lb,ub, Random_antlion_position',iter);
[RE]=Random_walk_around_antlion(dim,max_iter,lb,ub, Elite_position',iter);
Ant_Position(:,i)=(RE(iter,:)'+RA(iter,:)')/2;
Flag4ub=Ant_Position(:,i)>ub';
Flag4lb=Ant_Position(:,i)<lb';
Ant_Position(:,i)=(Ant_Position(:,i).*(~(Flag4ub+Flag4lb)))+ub'.*Flag4ub+lb'.*Flag4lb;
end
display(['At the iteration ', num2str(iter), ' there are ', num2str(Archive_member_no), ' non-dominated solutions in the archive']);
end
figure
Draw_ZDT1();
hold on
plot(Archive_F(:,1),Archive_F(:,2),'ko','MarkerSize',8,'markerfacecolor','k');
legend('True PF','Obtained PF');
title('MALO');
set(gcf, 'pos', [403 466 230 200])
3 仿真结果
4 参考文献
[1]陈倩雯. 基于改进蚁狮优化算法的含风电配电网多目标无功优化[D]. 西安理工大学, 2019.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。