路漫漫将求索分享 http://blog.sciencenet.cn/u/iching

博文

FECO Algorithm

已有 2207 次阅读 2019-1-26 11:19 |系统分类:论文交流

% Five-elements Cycle Optimization Algorithm for benchmark functions
% By Mandan Liu, East China University of Science and Technology, Shanghai, China
% Email: liumandan@ecust.edu.cn
% Nov. 2017

function BasicFECO

rand('state',sum(100*clock));
L=5;           %L is the number of element in one cycle;
q=20;          %q is the number of cycles;
Ps=1.0;        %Ps is the scale factor;
Pm=0.9;        %Pm is the pre-given probability;

cN=30;         %cN is the dimension of function;
maxiter=1500;  %maxiter is maximum iteration;
xlo=-32;       %xlo is the lower limit of x;
xhi=32;        %xhi is the high limit of x;

fmother=ones(1,L);
fgrandmother=-ones(1,L);
fson=-ones(1,L);
fgrandson=-ones(1,L);

for k=1:q
    for j=1:L
        x((k-1)*L+j,:,1)=rand(1,cN)*(xhi-xlo)+xlo;
        Mfive((k-1)*L+j,1,1)=fm(x((k-1)*L+j,:,1));
    end
end

[Mminno xno]=min(Mfive(:,1,1));
Mmaxminfive(1)=Mminno;
xmaxmin(1,:)=x(xno,:,1);
Mmeanfive(1)=mean(Mfive(:,1,1));
bestF=Mmaxminfive(1);
bestx=xmaxmin(1,:);
display(['The ' num2str(1) ' iteration, bestF is ' num2str(bestF)]);

for i=2:maxiter    
    for k=1:q
        Ffive((k-1)*L+1,1,i)=fmother(1)*log(Mfive((k-1)*L+L,1,i-1)/Mfive((k-1)*L+1,1,i-1))+fgrandmother(1)*log(Mfive((k-1)*L+L-1,1,i-1)/Mfive((k-1)*L+1,1,i-1))+fson(1)*log(Mfive((k-1)*L+1,1,i-1)/Mfive((k-1)*L+2,1,i-1))+fgrandson(1)*log(Mfive((k-1)*L+1,1,i-1)/Mfive((k-1)*L+3,1,i-1));
        Ffive((k-1)*L+2,1,i)=fmother(2)*log(Mfive((k-1)*L+1,1,i-1)/Mfive((k-1)*L+2,1,i-1))+fgrandmother(2)*log(Mfive((k-1)*L+L,1,i-1)/Mfive((k-1)*L+2,1,i-1))+fson(2)*log(Mfive((k-1)*L+2,1,i-1)/Mfive((k-1)*L+3,1,i-1))+fgrandson(2)*log(Mfive((k-1)*L+2,1,i-1)/Mfive((k-1)*L+4,1,i-1));
        for j=3:L-2
            Ffive((k-1)*L+j,1,i)=fmother(j)*log(Mfive((k-1)*L+j-1,1,i-1)/Mfive((k-1)*L+j,1,i-1))+fgrandmother(j)*log(Mfive((k-1)*L+j-2,1,i-1)/Mfive((k-1)*L+j,1,i-1))+fson(j)*log(Mfive((k-1)*L+j,1,i-1)/Mfive((k-1)*L+j+1,1,i-1))+fgrandson(j)*log(Mfive((k-1)*L+j,1,i-1)/Mfive((k-1)*L+j+2,1,i-1));
        end
        Ffive((k-1)*L+L-1,1,i)=fmother(L-1)*log(Mfive((k-1)*L+L-2,1,i-1)/Mfive((k-1)*L+L-1,1,i-1))+fgrandmother(L-1)*log(Mfive((k-1)*L+L-3,1,i-1)/Mfive((k-1)*L+L-1,1,i-1))+fson(L-1)*log(Mfive((k-1)*L+L-1,1,i-1)/Mfive((k-1)*L+L,1,i-1))+fgrandson(L-1)*log(Mfive((k-1)*L+L-1,1,i-1)/Mfive((k-1)*L+1,1,i-1));
        Ffive((k-1)*L+L,1,i)=fmother(L)*log(Mfive((k-1)*L+L-1,1,i-1)/Mfive((k-1)*L+L,1,i-1))+fgrandmother(L)*log(Mfive((k-1)*L+L-2,1,i-1)/Mfive((k-1)*L+L,1,i-1))+fson(L)*log(Mfive((k-1)*L+L,1,i-1)/Mfive((k-1)*L+1,1,i-1))+fgrandson(L)*log(Mfive((k-1)*L+L,1,i-1)/Mfive((k-1)*L+2,1,i-1));
    
        [maxFfive kno]=max(Ffive((k-1)*L+1:k*L,1,i));        
        for j=1:L
            x((k-1)*L+j,:,i)=x((k-1)*L+j,:,i-1);
            if Ffive((k-1)*L+j,1,i)<0 || Ffive((k-1)*L+j,1,i)==0
                for a=1:cN
                    if rand<Pm                 
                        x((k-1)*L+j,a,i)=x((k-1)*L+kno,a,i-1)+(rand*2-1)*Ps*(x((k-1)*L+kno,a,i-1)-x((k-1)*L+j,a,i-1));
                        x((k-1)*L+j,a,i)=max(xlo,min(xhi,x((k-1)*L+j,a,i)));
                    else
                        x((k-1)*L+j,a,i)=bestx(a)+(rand*2-1)*Ps*(x((k-1)*L+kno,a,i-1)-bestx(a));
                        x((k-1)*L+j,a,i)=max(xlo,min(xhi,x((k-1)*L+j,a,i)));
                    end                  
                end             
            end
            Mfive((k-1)*L+j,1,i)=fm(x((k-1)*L+j,:,i));                   
        end    
    end
        
    [Mminno xno]=min(Mfive(:,1,i));
    Mmaxminfive(i)=Mminno;
    xmaxmin(i,:)=x(xno,:,i);
    Mmeanfive(i)=mean(Mfive(:,1,i));
    
    if Mmaxminfive(i)<bestF
        bestF=Mmaxminfive(i);
        bestx=xmaxmin(i,:);           
    end
    display(['The ' num2str(i) ' iteration, bestF is ' num2str(bestF)]);
end
end

function z=fm(x)
r=size(x,2);
zhe1=0;
zhe2=0;
for i=1:r
    zhe1=zhe1+x(i)^2;
    zhe2=zhe2+cos(2*pi*x(i));
end
z=-20*exp(-0.2*sqrt(zhe1/r))-exp(zhe2/r)+20+exp(1); %Ackley's Function -32~+32/0
end

https://blog.sciencenet.cn/blog-3560-1159164.html

上一篇:五行环优化算法
收藏 IP: 101.87.223.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-27 00:41

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部