【优化求解】基于精英反向学习带扰动因子的混沌蚁狮算法(EOPCALO)求解单目标优化问题附matlab代码

发布时间:2026/7/25 16:47:56
【优化求解】基于精英反向学习带扰动因子的混沌蚁狮算法(EOPCALO)求解单目标优化问题附matlab代码 1 简介针对蚁狮算法易陷入局部最优、收敛速度慢的缺点本文提出了基于精英反向学习带扰动因子的混沌蚁狮算法。该算法首先通过对蚂蚁的随机游走公式引入扰动因子有效提高了寻优精度避免算法陷入局部最优有效平衡了全局最优搜索与局部最优搜索; 对蚁狮的精英个体进行反向学习生成精英反向解增加了种群多样性; 通过比较当前最优解与精英反向解选出优异个体作为新的全局最优解; 最后在蚂蚁受轮盘赌选择蚁狮、精英蚁狮影响的随机游走公式中引入 Logistic 混沌映射有效提高了算法的全局搜索能力和寻优精度。通过 7 个经典测试函数实验对比就目前改进的蚁狮算法而言本文提出的算法能有效提高寻优的精度与收敛速度、高效解决函数优化问题。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)function [min_value,Elite_antlion_fitness,Elite_antlion_position,Convergence_curve]ALO(N,Max_iter,lb,ub,dim,fobj)% Initialize the positions of antlions and antsantlion_positioninitialization(N,dim,ub,lb);ant_positioninitialization(N,dim,ub,lb);% Initialize variables to save the position of elite, sorted antlions,% convergence curve, antlions fitness, and ants fitnessSorted_antlionszeros(N,dim);Elite_antlion_positionzeros(1,dim);Elite_antlion_fitnessinf;Convergence_curvezeros(1,Max_iter);antlions_fitnesszeros(1,N);ants_fitnesszeros(1,N);% Calculate the fitness of initial antlions and sort themfor i1:size(antlion_position,1)antlions_fitness(1,i)fobj(antlion_position(i,:));end[sorted_antlion_fitness,sorted_indexes]sort(antlions_fitness);for newindex1:NSorted_antlions(newindex,:)antlion_position(sorted_indexes(newindex),:);endElite_antlion_positionSorted_antlions(1,:);Elite_antlion_fitnesssorted_antlion_fitness(1);% Main loop start from the second iteration since the first iteration% was dedicated to calculating the fitness of antlionsCurrent_iter2;while Current_iterMax_iter1% This for loop simulate random walksfor i1:size(ant_position,1)% Select ant lions based on their fitness (the better anlion the higher chance of catching ant)Rolette_indexRouletteWheelSelection(1./sorted_antlion_fitness);if Rolette_index-1Rolette_index1;end% RA is the random walk around the selected antlion by rolette wheelRARandom_walk_around_antlion(dim,Max_iter,lb,ub, Sorted_antlions(Rolette_index,:),Current_iter);% RA is the random walk around the elite (best antlion so far)[RE]Random_walk_around_antlion(dim,Max_iter,lb,ub, Elite_antlion_position(1,:),Current_iter);ant_position(i,:) (RA(Current_iter,:)RE(Current_iter,:))/2; % Equation (2.13) in the paperendfor i1:size(ant_position,1)% Boundar checking (bring back the antlions of ants inside search% space if they go beyoud the boundariesFlag4ubant_position(i,:)ub;Flag4lbant_position(i,:)lb;ant_position(i,:)(ant_position(i,:).*(~(Flag4ubFlag4lb)))ub.*Flag4ublb.*Flag4lb;ants_fitness(1,i)fobj(ant_position(i,:));end% Update antlion positions and fitnesses based of the ants (if an ant% becomes fitter than an antlion we assume it was cought by the antlion% and the antlion update goes to its position to build the trap)double_population[Sorted_antlions;ant_position];double_fitness[sorted_antlion_fitness ants_fitness];[double_fitness_sorted I]sort(double_fitness);double_sorted_populationdouble_population(I,:);antlions_fitnessdouble_fitness_sorted(1:N);Sorted_antlionsdouble_sorted_population(1:N,:);% Update the position of elite if any antlinons becomes fitter than itif antlions_fitness(1)Elite_antlion_fitnessElite_antlion_positionSorted_antlions(1,:);Elite_antlion_fitnessantlions_fitness(1);end% Keep the elite in the populationSorted_antlions(1,:)Elite_antlion_position;antlions_fitness(1)Elite_antlion_fitness;% Update the convergence curveConvergence_curve(Current_iter)Elite_antlion_fitness;% Display the iteration and best optimum obtained so farif mod(Current_iter,1)0display([At iteration , num2str(Current_iter), the elite fitness is , num2str(Elite_antlion_fitness)]);endmin_value(Current_iter)Elite_antlion_fitness;Current_iterCurrent_iter1;end3 仿真结果4 参考文献[1]王茜,何庆,林杰,杨荣莹.精英反向学习带扰动因子的混沌蚁狮算法[J].智能计算机与应用,2020,10(08):51-57.博主简介擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真相关matlab代码问题可私信交流。部分理论引用网络文献若有侵权联系博主删除。