• 大小: 3KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-14
  • 语言: Matlab
  • 标签: PSO  

资源简介

CLPSO 算法的matlab代码,基于文章而来,非得凑五十个字吗

资源截图

代码片段和文件信息

%modified by Tang 2007-05-14 at Tongji University

function [gbest_tgbestval_tfitcount]= CLPSO(fhdMax_GenMax_FESParticle_NumberDimensionVRminVRmax)
%[gbestgbestvalfitcount]= CLPSO_new_func(‘f8‘35002000003030-5.125.12)

rand(‘state‘sum(100*clock));

%=============================================================
me=Max_Gen;
ps=Particle_Number;%population size
D=Dimension;
t=0:1/(ps-1):1;t=5.*t;
%Pc=0.0+(0.5-0.0).*(exp(t)-exp(t(1)))./(exp(t(ps))-exp(t(1)));  %Learning proportion Pc  which determines how many dimensions are chosen to learn from other particles‘ pbests.
Pc=0.05+0.45.*(exp(t)-exp(t(1)))./(exp(t(ps))-exp(t(1)));  
% Pc=0.5.*ones(1ps);
dm=3*ones(ps1); %m dimensions are randomly chosen to learn from the gbest. Some of the remaining D-m dimensions are randomly chosen to learn from some randomly chosen particles‘ pbests and the remaining dimensions learn from its pbest
iwt=0.9-(1:me)*(0.7/me);%inertia weight
% iwt=0.729-(1:me)*(0.0/me);
cc=[1.49445 1.49445]; %acceleration constants

if length(VRmin)==1
    VRmin=repmat(VRmin1D);
    VRmax=repmat(VRmax1D);
end
mv=0.2*(VRmax-VRmin);%max velocity
VRmin=repmat(VRminps1);
VRmax=repmat(VRmaxps1);
Vmin=repmat(-mvps1);
Vmax=-Vmin;
pos=VRmin+(VRmax-VRmin).*rand(psD);    %initialize the position value

for i=1:ps;
    e(i1)=feval(fhdpos(i:));    %initialize the fitness value
end

fitcount=ps;
vel=Vmin+2.*Vmax.*rand(psD);     %initialize the velocity of the particles
pbest=pos;     %initialize the pbest (psXD)
pbestval=e;    %initialize the pbest‘s fitness value
[gbestvalgbestid]=min(pbestval);    %initialize the gbest‘s fitness value
gbestval_t(1)=gbestval;    %initialize the pbest‘s fitness value
gbest=pbest(gbestid:);     %initialize the gbest value (1XD)
gbestrep=repmat(gbestps1);
gbest_t(1:)=gbest;     %
stay_num=zeros(ps1); 

    ai=zeros(psD);
    f_pbest=1:ps;f_pbest=repmat(f_pbest‘1D);
    for k=1:ps
        ar=randperm(D);%??????????
        ai(kar(1:dm(k)))=1;
        fi1=ceil(ps*rand(1D));
        fi2=ceil(ps*rand(1D));
        fi=(pbestval(fi1)=pbestval(fi2))‘.*fi2;
        bi=ceil(rand(1D)-1+Pc(k));
        if bi==zeros(1D)
            rc=randperm(D);
            bi(rc(1))=1;
        end
        f_pbest(k:)=bi.*fi+(1-bi).*f_pbest(k:);
    end
    
    stop_num=0;
    i=1;

 while i     i=i+1;
     for k=1:ps;
         if stay_num(k)>=5  %????????????
   %     if round(i/10)==i/10%|stay_num(k)>=5
             stay_num(k)=0;
             ai(k:)=zeros(1D);
             f_pbest(k:)=k.*ones(1D);
             ar=randperm(D);
             ai(kar(1:dm(k)))=1;
             fi1=ceil(ps*rand(1D));
             fi2=ceil(ps*rand(1D));
             fi=(pbestval(fi1)=pbestval(fi2))‘.*fi2;
             bi=ceil(rand(1D)-1+Pc(k));
             if bi==zeros(1D)
             

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       5242  2009-05-23 18:52  CLPSO\CLPSO.m

     文件       1090  2010-11-30 18:30  CLPSO\FitnessFunc.m

     文件       2530  2010-12-06 10:33  CLPSO\main.m

     目录          0  2011-03-15 19:07  CLPSO

----------- ---------  ---------- -----  ----

                 8862                    4


评论

共有 条评论