adaptbest3.m

来自「该程序是一整数版的PSO程序。该程序对于整数版PSO的各种应用可作为模板程序。」· M 代码 · 共 15 行

M
15
字号
% 更新个体、群体的最优位置和适应值
function [pbestx,pbesty,gbestx,gbesty]=adaptbest3(popsize,x,y,pbestx,pbesty,gbestx,gbesty)
%
%
%
for popindex=1:popsize
    if y(popindex)<pbesty(popindex)
       pbestx(popindex,:)=x(popindex,:);
       pbesty(popindex)=y(popindex);
    end
    if y(popindex)<gbesty
       gbestx=x(popindex,:);
       gbesty=y(popindex);
     end
 end

⌨️ 快捷键说明

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