• 【智能优化算法】基于蝙蝠优化算法求解多目标优化问题附matlab代码


    1 内容介绍

    蝙蝠算法( BA) 是 Yang 教授于 2010 年基于群体智能提出的启发式搜索算法,是一种搜索全局最优解的有效方法。该算法是一种基于迭代的优化技术,初始化为一组随机解,然后 通过迭代搜寻最优解,且在最优解周围通过随机飞行产生局部新解,加强了局部搜索。与其他算法相比,BA 在准确性和有效性方面远优于其他算法,且没有许多参数要进行调整。

    2 仿真代码

                                       %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function moba_ns_new(inp),%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%if nargin<1,      % Check inputs (otherwise, default values)inp=[100 1000];   % [Pop size, #Iteration] e.g., inp=[100 1000]endnpop   = inp(1);  %% Population sizeGen = inp(2);     %% Number of Iterationsm=2;              %% Number of objectivesndim=30;          %% ndim=dimensions%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Parameter settings  (initial values)                                    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%AL      = 0.9; r       = 0.9; alpha   = 0.9; Gamma   = 0.9;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%            %% Initialize the increment components for bats/locationsdel_bats = zeros(npop,ndim);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%new_bats = zeros(npop,ndim);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Lb=zeros(1,ndim);     % Lower boundsUb=ones(1,ndim);      % Upper boundsminf=0; maxf=1;       % Frequnecy range%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Initialize the populationfor i=1:npop,   x(i,:)=Lb+(Ub-Lb).*rand(1,ndim);    f(i,1:m) = obj_funs(x(i,:), m);end%% Combining x and f into a large matrix for easy storage%% x is an npop x ndim matrix, while f is an (npop x m) matrix.%% So the combined matrix has a size of npop x (ndim+m),%% with the last m columns being the m objective valuesbats=[x f]; end%% Displaying the final Pareto Front as a graphfigure(2)    plot(bats(:,ndim+1), bats(:,ndim+2),'rd');title(strcat(num2str(npop),' Points on the Pareto Front'));xlabel('Objective (f_1)'); ylabel('Objective (f_2)');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Make sure all the bats are within the limitsfunction [ns]=findlimits(ns,Lb,Ub)  % Apply the lower bound  ns_tmp=ns;  I=ns_tmp < Lb;  ns_tmp(I)=Lb(I);    % Apply the upper bounds   J=ns_tmp>Ub;  ns_tmp(J)=Ub(J);  % Update this new move   ns=ns_tmp;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Objective functionsfunction f = obj_funs(x, m)% Zitzler-Deb-Thiele's funciton No 3 (ZDT function 3)% m    = number of objectives% ndim = number of variables/dimensionsndim=length(x);  % ndim=30 for ZDT 3% First objective f1f(1) = x(1);g=1+9/29*sum(x(2:ndim));h=1-sqrt(f(1)/g)-f(1)/g*sin(10*pi*f(1));% Second objective f2f(2) = g*h;%%%%%%%%%%%%%%%%%% end of the definitions of obojectives %%%%%%%%%%%%%%%%%%%% Clean up the populations (both old and new) to give a new population% This cleanup here is similar to the Non-dominated Sorting Genetic% Algorithm (NSGA-II) by K. Deb et al. (2002), which can be applied to % any cleanup of 2*npop solutions to form a set of npop solutions.function new_bats = cleanup_batspop(bats, m, ndim, npop)% The input population to this part has twice (ntwice) of the needed % population size (npop). Thus, selection is done based on ranking and % crowding distances, calculated from the non-dominated sortingntwice= size(bats,1);% Ranking is stored in column KrankKrank=m+ndim+1;% Sort the population of size 2*npop according to their ranks[~,Index] = sort(bats(:,Krank)); sorted_bats=bats(Index,:);% Get the maximum rank among the populationRankMax=max(bats(:,Krank)); %% Main loop for selecting solutions based on ranks and crowding distancesK = 0;  % Initialization for the rank counter % Loop over all ranks in the populationfor i =1:RankMax,      % Obtain the current rank i from sorted solutions    RankSol = max(find(sorted_bats(:, Krank) == i));    % In the new bats/solutions, there can be npop solutions to fill    if RankSol       new_bats(K+1:RankSol,:)=sorted_bats(K+1:RankSol,:);    end     % If the population after addition is large than npop, re-arrangement    % or selection is carried out    if RankSol>=npop        % Sort/Select the solutions with the current rank         candidate_bats = sorted_bats(K + 1 : RankSol, :);        [~,tmp_Rank]=sort(candidate_bats(:,Krank+1),'descend');        % Fill the rest (npop-K) bats/solutions up to npop solutions         for j = 1:(npop-K),             new_bats(K+j,:)=candidate_bats(tmp_Rank(j),:);        end    end    % Record and update the current rank after adding new bats     K = RankSol;end

    3 运行结果

    4 参考文献

    [1]康志龙, 张雪萍, 陈雷,等. 基于多目标蝙蝠优化的高光谱图像解混算法[J]. 光电子.激光, 2018, 29(3):8.

    [2]裴文杰, 汪沨, 谭阳红,等. 基于蝙蝠算法的电力恢复机组选择多目标优化[J]. 计算机工程与应用, 2017.

    博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

    部分理论引用网络文献,若有侵权联系博主删除。

  • 相关阅读:
    【初阶数据结构】——限定性线性表:栈 和 队列详解(C描述)
    ChatGPT Plus暂停注册,用户激增压力太大!
    cs软件ui构建办法
    USART串口协议
    C++基础——内存分区模型
    想要精通算法和SQL的成长之路 - 填充书架
    MAVEN中三种packaging方式
    初步了解华为的MTL(市场到线索)流程的基本概念和来龙去脉
    诊断寻址方式
    解决发邮件错误javax.mail.MessagingException: Could not connect to SMTP host
  • 原文地址:https://blog.csdn.net/qq_59747472/article/details/126058367