⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 updatepop.m

📁 Matlab psp code is a good operator
💻 M
字号:
%粒子群速度与位置更新
w=0.95ones(N,N);%更新粒子速度f=20+x.^2-10*cos(2*pi*x)+y.^2-10*cos(2*pi*y), -5.12<=x,y<=5.12
for j=1:N
    for i=1:popsize
     %ws=0.95;we=0.14;w=(ws-we)*(i/popsize)^2+(we-ws)*((2*i)/popsize)+ws;
    %we=0.14;w=(ws-we)*((popsize-i)/popsize)+we;
    %pop(i,3)=w*pop(i,3)+c1*rand*(pop(i,5)-pop(i,1))+c2*rand*(gbest_x-pop(i,1));    %更新速度
   vpop(i,j)=w*vpop(i,j)+c(i,j)*rand*(Tspop(i,j)-pop(i,j));
    %pop(i,4)=w*pop(i,4)+c1*rand*(pop(i,6)-pop(i,2))+c2*rand*(gbest_x-pop(i,2)); 
    if abs(vpop(i,j))>max_velocity
        if vpop(i,j)>0
            vpop(i,j)=max_velocity;
        else
            vpop(i,j)=-max_velocity;
        end
    end
   % if abs(pop(i,4))>max_velocity
    %    if pop(i,4)>0
     %       pop(i,4)=max_velocity;
      %  else
       %     pop(i,4)=-max_velocity;
        %end
    %end
%end

%更新粒子位置
for j=1:N
for i=1:popsize
    pop(i,j)=pop(i,j)+vpop(i,j);
    %pop(i,2)=pop(i,2)+pop(i,4);
end
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -