• 【多目标优化求解】基于matlab非支配排序灰狼优化(NS-GWO)算法求解多目标优化问题【含Matlab源码 2015期】


    一、灰狼算法简介

    1 前言:
    灰狼优化算法(Grey Wolf Optimizer,GWO)由澳大利亚格里菲斯大学学者 Mirjalili 等人于2014年提出来的一种群智能优化算法。该算法受到了灰狼捕食猎物活动的启发而开发的一种优化搜索方法,它具有较强的收敛性能、参数少、易实现等特点。近年来受到了学者的广泛关注,它己被成功地应用到了车间调度、参数优化、图像分类等领域中。
    2 算法原理:
    灰狼隶属于群居生活的犬科动物,且处于食物链的顶层。灰狼严格遵守着一个社会支配等级关系。如图:
    在这里插入图片描述
    社会等级第一层:狼群中的头狼记为 \alpha,\alpha 狼主要负责对捕食、栖息、作息时间等活动作出决策。由于其它的狼需要服从\alpha 狼的命令,所以 \alpha 狼也被称为支配狼。另外, \alpha 狼不一定是狼群中最强的狼,但就管理能力方面来说, \alpha 狼一定是最好的。

    社会等级第二层:\beta 狼,它服从于 \alpha 狼,并协助 \alpha 狼作出决策。在 \alpha 狼去世或衰老后,\beta 狼将成为 \alpha 狼的最候选者。虽然 \beta 狼服从 \alpha 狼,但 \beta 狼可支配其它社会层级上的狼。

    社会等级第三层:\delta 狼,它服从 \alpha 、\beta 狼,同时支配剩余层级的狼。\delta 狼一般由幼狼、哨兵狼、狩猎狼、老年狼及护理狼组成。

    社会等级第四层:\omega 狼,它通常需要服从其它社会层次上的狼。虽然看上去 \omega 狼在狼群中的作用不大,但是如果没有 \omega 狼的存在,狼群会出现内部问题如自相残杀。

    GWO 优化过程包含了灰狼的社会等级分层、跟踪、包围和攻击猎物等步骤,其步骤具体情况如下所示。

    1)社会等级分层(Social Hierarchy)当设计 GWO 时,首先需构建灰狼社会等级层次模型。计算种群每个个体的适应度,将狼群中适应度最好的三匹灰狼依次标记为 \alpha、\beta 、\delta ,而剩下的灰狼标记为 \omega。也就是说,灰狼群体中的社会等级从高往低排列依次为; \alpha、\beta 、\delta 及 \omega。GWO 的优化过程主要由每代种群中的最好三个解(即 \alpha、\beta 、\delta )来指导完成。

    2)包围猎物( Encircling Prey )灰狼捜索猎物时会逐渐地接近猎物并包围它,该行为的数学模型如下:
    在这里插入图片描述
    式中:t 为当前迭代次数:。表示 hadamard 乘积操作;A 和 C 是协同系数向量;Xp 表示猎物的位置向量; X(t) 表示当前灰狼的位置向量;在整个迭代过程中 a 由2 线性降到 0; r1 和 r2 是 [0,1] 中的随机向量。

    3)狩猎( Hunring)

    灰狼具有识别潜在猎物(最优解)位置的能力,搜索过程主要靠 \alpha、\beta 、\delta 灰狼的指引来完成。但是很多问题的解空间特征是未知的,灰狼是无法确定猎物(最优解)的精确位置。为了模拟灰狼(候选解)的搜索行为,假设 \alpha、\beta 、\delta 具有较强识别潜在猎物位置的能力。因此,在每次迭代过程中,保留当前种群中的最好三只灰狼( \alpha、\beta 、\delta ),然后根据它们的位置信息来更新其它搜索代理(包括 \omega)的位置。该行为的数学模型可表示如下:
    在这里插入图片描述
    式中:X_{{\alpha }}、X{{\beta }}、X{{\delta }} 分别表示当前种群中 \alpha、\beta 、\delta 的位置向量;X表示灰狼的位置向量;D{{\alpha }}、D{{\beta }}、D{_{\delta }} 分别表示当前候选灰狼与最优三条狼之间的距离;当|A|>1时,灰狼之间尽量分散在各区域并搜寻猎物。当|A|<1时,灰狼将集中捜索某个或某些区域的猎物。
    在这里插入图片描述
    从图中可看出,候选解的位置最终落在被 \alpha、\beta 、\delta 定义的随机圆位置内。总的来说, \alpha、\beta 、\delta 需首先预测出猎物(潜
    在最优解)的大致位置,然后其它候选狼在当前最优兰只狼的指引下在猎物附近随机地更新它们的位置。

    4)攻击猎物(Attacking Prey)构建攻击猎物模型的过程中,根据2)中的公式,a值的减少会引起 A 的值也随之波动。换句话说,A 是一个在区间[-a,a](备注:原作者的第一篇论文里这里是[-2a,2a],后面论文里纠正为[-a,a])上的随机向量,其中a在迭代过程中呈线性下降。当 A 在[-1,1]区间上时,则捜索代理(Search Agent)的下一时刻位置可以在当前灰狼与猎物之间的任何位置上。

    5)寻找猎物(Search for Prey)灰狼主要依赖 \alpha、\beta 、\delta 的信息来寻找猎物。它们开始分散地去搜索猎物位置信息,然后集中起来攻击猎物。对于分散模型的建立,通过|A|>1使其捜索代理远离猎物,这种搜索方式使 GWO 能进行全局搜索。GWO 算法中的另一个搜索系数是C。从2)中的公式可知,C向量是在区间范围[0,2]上的随机值构成的向量,此系数为猎物提供了随机权重,以便増加(|C|>1)或减少(|C|<1)。这有助于 GWO 在优化过程中展示出随机搜索行为,以避免算法陷入局部最优。值得注意的是,C并不是线性下降的,C在迭代过程中是随机值,该系数有利于算法跳出局部,特别是算法在迭代的后期显得尤为重要。

    二、部分源代码

     clc
    clear all
    D = 30; % Number of decision variables
    M = 2; % Number of objective functions
    K=M+D;
    LB = ones(1, D).*0; %  LB - A vector of decimal values which indicate the minimum value for each decision variable.
    UB = ones(1, D).*1; % UB - Vector of maximum possible values for decision variables.
    Max_iteration = 100;  % Set the maximum number of generation (GEN)
    SearchAgents_no = 100;      % Set the population size (Search Agent)
    ishow = 10;
    %% Initialize the population
    % Population is initialized with random values which are within the
    % specified range. Each chromosome consists of the decision variables. Also
    % the value of the objective functions, rank and crowding distance
    % information is also added to the chromosome vector but only the elements
    % of the vector which has the decision variables are operated upon to
    % perform the genetic operations like corssover and mutation.
    chromosome = initialize_variables(SearchAgents_no, M, D, LB, UB);
    
    %% Sort the initialized population
    % Sort the population using non-domination-sort. This returns two columns
    % for each individual which are the rank and the crowding distance
    % corresponding to their position in the front they belong. At this stage
    % the rank and the crowding distance for each chromosome is added to the
    % chromosome vector for easy of computation.
    intermediate_chromosome = non_domination_sort_mod(chromosome, M, D);
    
    %% Perform Selection
    % Once the intermediate population is sorted only the best solution is
    % selected based on it rank and crowding distance. Each front is filled in
    % ascending order until the addition of population size is reached. The
    % last front is included in the population based on the individuals with
    % least crowding distance
    % Select NP fittest solutions using non dominated and crowding distance
    % sorting and store in population
    Population = replace_chromosome(intermediate_chromosome, M,D,SearchAgents_no);
    %% Start the evolution process
    % The following are performed in each generation
    % * Select the parents which are fit for reproduction
    % * Perfrom crossover and Mutation operator on the selected parents
    % * Perform Selection from the parents and the offsprings
    % * Replace the unfit individuals with the fit individuals to maintain a
    %   constant population size.
    Pareto = NSGWO(D,M,LB,UB,Population,SearchAgents_no,Max_iteration,ishow);
    save Pareto.txt Pareto -ascii;  % save data for future use
    %% Plot data
    if M == 2
        plot_data2(M,D,Pareto)
    elseif M == 3
        plot_data_TCQ(M,D,Pareto); 
    end
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52

    三、运行结果

    在这里插入图片描述

    四、matlab版本及参考文献

    1 matlab版本
    2014a

    2 参考文献
    [1] 包子阳,余继周,杨杉.智能优化算法及其MATLAB实例(第2版)[M].电子工业出版社,2016.
    [2]张岩,吴水根.MATLAB优化算法源代码[M].清华大学出版社,2017.
    [3]李阳,李维刚,赵云涛,刘翱.基于莱维飞行和随机游动策略的灰狼算法[J].计算机科学,2020,47(8).

    3 备注
    简介此部分摘自互联网,仅供参考,若侵权,联系删除

  • 相关阅读:
    美容店预约小程序搭建流程
    寄存器(内存访问)
    router和route的区别?
    uniapp 接口请求封装
    欧姆龙plc梯形图T_T
    Log4j有哪几种日志级别呢?
    spring boot 一个极简单的 demo 示例
    你不知道的原生js广播频道接口
    MyBatis-Plus实现SQL执行前统一处理添加只读标识等注释
    电容的电路应用
  • 原文地址:https://blog.csdn.net/TIQCmatlab/article/details/126108967