【单目标优化算法】孔雀优化算法(Matlab代码实现)

💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

📋📋📋本文目录如下:🎁🎁🎁

目录

💥1 概述

📚2 运行结果

🎉3 参考文献

🌈4 Matlab代码及详细文章


💥1 概述

  • 受孔雀群智能行为的启发,POA的设计包括有效和高效的探索性和剥削性搜索算子,以在全球探索和局部开发之间提供适当的权衡,以避免局部最优,例如孔雀独特的旋转舞蹈操作,孔雀和孔雀幼崽在不同搜索阶段的自适应搜索行为,以及不同搜索阶段的相互作用 孔雀;
  • 代表当前最优解的五只孔雀也会通过旋转跳动机制在附近的搜索空间中搜索,而不是静止不动。孔雀独特的旋转跳舞机制包含两种不同的旋转模式,即原位旋转和围绕食物源盘旋。首先采用当前最优解仍会进行就近搜索的机制,这在以前的算法中从未考虑过,有利于跳出局部最优;
  • 孔雀幼崽和孔雀幼崽在整个搜索过程中都倾向于采用适应性搜索和接近机制,动态调整其不同阶段的行为,从而实现局部开发与全球探索之间的适当平衡。

📚2 运行结果

部分代码:

%  Peafowl Optimization Algorithm (POA)
function [BestSolution, ConvergenceCurve, Dim]=POA(NumAgents, MaxIterations, BenchmarkFunFlag)
    % --------------------------Return Parameters--------------------------
    % BestSolution:      The best solution
    % ConvergenceCurve:  Convergence curve
    % Dim:               The dimensionality of prloblem
    % --------------------------Input Parameters---------------------------
    % NumAgents:         The number of search individuals
    % MaxIterations:     The number of maximum iterations
    % BenchmarkFunFlag:  Objective function (1-23)
    % ---------------------------------------------------------------------
    
    ConvergenceCurve=zeros(1,MaxIterations);
        
    NumPeacock=5; % the number of leader (Peacock)
    NumPeahen=round((NumAgents-NumPeacock)*0.3); % the number of peahen
    NumPeacockCub=NumAgents-NumPeacock-NumPeahen; % the number of peacock cub

    [LowerBound, UpperBound, Dim]=BenchmarkFunctionRange(BenchmarkFunFlag);
    LowerBound=LowerBound*ones(1,Dim);
    UpperBound=UpperBound*ones(1,Dim);

    SearchRadius0=(UpperBound-LowerBound)*0.2; % initial dance radius of peacock

    % initialization
    empty_peacock.Position=[];
    empty_peacock.Fitness=[];

    PeacockPopulation0=repmat(empty_peacock,[NumAgents,1]);
    Peahen=repmat(empty_peacock,[NumPeahen,1]);
    PeacockCub=repmat(empty_peacock,[NumPeacockCub,1]);

    for k=1:NumAgents
        PeacockPopulation0(k).Position=LowerBound+(UpperBound-LowerBound).*rand(1,Dim);
        PeacockPopulation0(k).Fitness=BenchmarkFunction(PeacockPopulation0(k).Position, BenchmarkFunFlag, Dim);
    end

    PeacockPopulation=PeacockPopulation0;
    [~,index]=sort([PeacockPopulation.Fitness]);
    PeacockPopulation=PeacockPopulation(index);

    ConvergenceCurve(1)=PeacockPopulation(1).Fitness;

    % main loop
    for it=2:MaxIterations

        SearchRadius=SearchRadius0-(SearchRadius0-0)*(it/MaxIterations)^0.01;
        alpha=0.9-(0.9-0.4)*(it/MaxIterations)^2;
        delta=0.1+(1-0.1)*(it/MaxIterations)^0.5;
        step=0.1+(1-0.1)*(it/MaxIterations);

        Peacock=PeacockPopulation(1:NumPeacock);
        if rand<1
            X_random=2*rand(1,Dim)-1;
            Peacock(1).Position=Peacock(1).Position+1*SearchRadius.*X_random/(eps+norm(X_random));
        end
        if rand<0.9
            X_random=2*rand(1,Dim)-1;
            Peacock(2).Position=Peacock(2).Position+1.5*SearchRadius.*X_random/(eps+norm(X_random));
        end
        if rand<0.8
            X_random=2*rand(1,Dim)-1;
            Peacock(3).Position=Peacock(3).Position+2*SearchRadius.*X_random/(eps+norm(X_random));
        end
        if rand<0.6
            X_random=2*rand(1,Dim)-1;
            Peacock(4).Position=Peacock(4).Position+3*SearchRadius.*X_random/(eps+norm(X_random));
        end
        if rand<0.3
            X_random=2*rand(1,Dim)-1;
            Peacock(5).Position=Peacock(5).Position+5*SearchRadius.*X_random/(eps+norm(X_random));
        end
        for k=1:NumPeacock
            flag4ub=Peacock(k).Position>UpperBound;
            flag4lb=Peacock(k).Position<LowerBound;
            Peacock(k).Position=~(flag4ub+flag4lb).*Peacock(k).Position+flag4ub.*UpperBound+flag4lb.*LowerBound;
            Peacock(k).Fitness=BenchmarkFunction(Peacock(k).Position, BenchmarkFunFlag, Dim);
            if Peacock(k).Fitness < PeacockPopulation(k).Fitness
                PeacockPopulation(k)=Peacock(k);
            end
        end

        for k=1:NumPeahen
            r1=rand();
            if r1 <= 1 && r1 >=0.6
                Peahen(k).Position=PeacockPopulation(NumPeacock+k).Position+3*step*(PeacockPopulation(1).Position-PeacockPopulation(NumPeacock+k).Position);
            end
            if r1 < 0.6 && r1 >=0.4
                Peahen(k).Position=PeacockPopulation(NumPeacock+k).Position+3*step*(PeacockPopulation(2).Position-PeacockPopulation(NumPeacock+k).Position);
            end
            if r1 < 0.4 && r1 >=0.2
                Peahen(k).Position=PeacockPopulation(NumPeacock+k).Position+3*step*(PeacockPopulation(3).Position-PeacockPopulation(NumPeacock+k).Position);
            end
            if r1 < 0.2 && r1 >=0.1
                Peahen(k).Position=PeacockPopulation(NumPeacock+k).Position+3*step*(PeacockPopulation(4).Position-PeacockPopulation(NumPeacock+k).Position);
            end
            if r1 < 0.1 && r1 >=0
                Peahen(k).Position=PeacockPopulation(NumPeacock+k).Position+3*step*(PeacockPopulation(5).Position-PeacockPopulation(NumPeacock+k).Position);
            end
            flag4ub=Peahen(k).Position>UpperBound;
            flag4lb=Peahen(k).Position<LowerBound;
            Peahen(k).Position=~(flag4ub+flag4lb).*Peahen(k).Position+flag4ub.*UpperBound+flag4lb.*LowerBound;
            Peahen(k).Fitness=BenchmarkFunction(Peahen(k).Position, BenchmarkFunFlag, Dim);
            if Peahen(k).Fitness < PeacockPopulation(NumPeacock+k).Fitness
                PeacockPopulation(NumPeacock+k)=Peahen(k);
            end
        end

        for k=1:NumPeacockCub
            PeacockCub(k)=PeacockPopulation(NumPeacock+NumPeahen+k);
            
            r2=rand;
            if r2>0.8 && r2<=1
                SelectedPeacock=PeacockPopulation(1);
            elseif r2>0.6 && r2<=0.8
                SelectedPeacock=PeacockPopulation(2);
            elseif r2>0.4 && r2<=0.6
                SelectedPeacock=PeacockPopulation(3);
            elseif r2>0.2 && r2<=0.4
                SelectedPeacock=PeacockPopulation(4);
            else 
                SelectedPeacock=PeacockPopulation(5);
            end
            
            PeacockCub(k).Position=PeacockCub(k).Position+alpha*Levy(Dim).*( PeacockPopulation(1).Position - PeacockCub(k).Position )+delta*( SelectedPeacock.Position - PeacockCub(k).Position );
            
            flag4ub=PeacockCub(k).Position>UpperBound;
            flag4lb=PeacockCub(k).Position<LowerBound;
            PeacockCub(k).Position=~(flag4ub+flag4lb).*PeacockCub(k,:).Position+flag4ub.*UpperBound+flag4lb.*LowerBound;
            PeacockCub(k).Fitness=BenchmarkFunction(PeacockCub(k).Position, BenchmarkFunFlag, Dim);
            if PeacockCub(k).Fitness < PeacockPopulation(NumPeacock+NumPeahen+k).Fitness
                PeacockPopulation(NumPeacock+NumPeahen+k)=PeacockCub(k,:);
            end
        end

        Peacock=PeacockPopulation(1:NumPeacock);
        
        Xrandom=2*rand(1,Dim)-1;
        Direction1=Peacock(1,:).Position-Peacock(2,:).Position;
        Direction2=Xrandom-(Xrandom*Direction1')/(Direction1*Direction1'+eps)*Direction1;
        Direction2=Direction2/norm(Direction2+eps)*norm(Direction1);
        Peacock(2,:).Position=Peacock(2,:).Position+step*Direction1+rand*Direction2;
        
        Xrandom=2*rand(1,Dim)-1;
        Direction1=Peacock(1,:).Position-Peacock(3,:).Position;
        Direction2=Xrandom-(Xrandom*Direction1')/(Direction1*Direction1'+eps)*Direction1;
        Direction2=Direction2/norm(Direction2+eps)*norm(Direction1);
        Peacock(3,:).Position=Peacock(3,:).Position+step*Direction1+rand*Direction2;
        
        Xrandom=2*rand(1,Dim)-1;
        Direction1=Peacock(1,:).Position-Peacock(4,:).Position;
        Direction2=Xrandom-(Xrandom*Direction1')/(Direction1*Direction1'+eps)*Direction1;
        Direction2=Direction2/norm(Direction2+eps)*norm(Direction1);
        Peacock(4,:).Position=Peacock(4,:).Position+step*Direction1+rand*Direction2;
        
        Xrandom=2*rand(1,Dim)-1;
        Direction1=Peacock(1,:).Position-Peacock(5,:).Position;
        Direction2=Xrandom-(Xrandom*Direction1')/(Direction1*Direction1'+eps)*Direction1;
        Direction2=Direction2/norm(Direction2+eps)*norm(Direction1);
        Peacock(5,:).Position=Peacock(5,:).Position+step*Direction1+rand*Direction2;
        
        for k=1:NumPeacock
            flag4ub=Peacock(k).Position>UpperBound;
            flag4lb=Peacock(k).Position<LowerBound;
            Peacock(k).Position=~(flag4ub+flag4lb).*Peacock(k).Position+flag4ub.*UpperBound+flag4lb.*LowerBound;
            Peacock(k).Fitness=BenchmarkFunction(Peacock(k).Position, BenchmarkFunFlag, Dim);
            if Peacock(k).Fitness < PeacockPopulation(k).Fitness
                PeacockPopulation(k)=Peacock(k);
            end
        end

        [~,index]=sort([PeacockPopulation.Fitness]);
        PeacockPopulation=PeacockPopulation(index);

        ConvergenceCurve(1,it)=PeacockPopulation(1).Fitness;

    end
    BestSolution=PeacockPopulation(1);
end

🎉3 参考文献

部分理论来源于网络,如有侵权请联系删除。

[1] Jingbo Wang, Bo Yang, Yijun Chen, Kaidi Zeng, Hao Zhang, Hongchun Shu, Yingtong Chen,
 Novel phasianidae inspired peafowl (Pavo muticus/cristatus) optimization algorithm: Design, evaluation, and SOFC models parameter estimation,
 Sustainable Energy Technologies and Assessments
 https://doi.org/10.1016/j.seta.2021.101825

🌈4 Matlab代码及详细文章

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值