1 简介
蚁狮优化算法( Ant Lion Optimizer,ALO) 是 Mirjalili 研究并提出的一种群智能优化算法.算法具有调节参数较少、易于实现等优点,成为近几年进化计算领域的重要算法和研究热点之一,已被成功应用于杠杆结构优化、电力系统的无功优化调度和无人机航线规划等许多问题的优化求解当中.
2 部分代码
%___________________________________________________________________%
% Ant Lion Optimizer (ALO) source codes demo version 1.0 %
% %
% You can simply define your cost in a seperate file and load its handle to fobj
% The initial parameters that you need are:
%__________________________________________
% fobj = @YourCostFunction
% dim = number of your variables
% Max_iteration = maximum number of generations
% SearchAgents_no = number of search agents
% lb=[lb1,lb2,...,lbn] where lbn is the lower bound of variable n
% ub=[ub1,ub2,...,ubn] where ubn is the upper bound of variable n
% If all the variables have equal lower bound you can just
% define lb and ub as two single number numbers
% To run ALO: [Best_score,Best_pos,cg_curve]=ALO(SearchAgents_no,Max_iteration,lb,ub,dim,fobj)
%__________________________________________
clear all
clc
SearchAgents_no=100; % Number of search agents
Function_name='F1'; % Name of the test function that can be from F1 to F23 (Table 1,2,3 in the paper)
Max_iteration=100; % Maximum numbef of iterations
% Load details of the selected benchmark function
[lb,ub,dim,fobj]=Get_Functions_details(Function_name);
[min_value,Best_score,Best_pos,cg_curve]=ALO(SearchAgents_no,Max_iteration,lb,ub,dim,fobj);
figure('Position',[500 500 660 290])
%Draw search space
subplot(1,2,1);
func_plot(Function_name);
title('Test function')
xlabel('x_1');
ylabel('x_2');
zlabel([Function_name,'( x_1 , x_2 )'])
grid off
%Draw objective space
subplot(1,2,2);
semilogy(cg_curve,'Color','r')
title('Convergence curve')
xlabel('Iteration');
ylabel('Best score obtained so far');
axis tight
grid off
box on
legend('ALO')
display(['The best solution obtained by ALO is : ', num2str(Best_pos)]);
display(['The best optimal value of the objective funciton found by ALO is : ', num2str(Best_score)]);
% figure(1)
% plot(min_value);
% xlabel('迭代次数')
% ylabel('适应度值');
img =gcf; %获取当前画图的句柄
print(img, '-dpng', '-r600', './运行结果.png') %即可得到对应格式和期望dpi的图像
3 仿真结果
4 参考文献
[1]陈倩雯. (2019). 基于改进蚁狮优化算法的含风电配电网多目标无功优化. (Doctoral dissertation, 西安理工大学).