getstgbest.m

来自「硕士论文三个点中的一个」· M 代码 · 共 13 行

M
13
字号
function [o_gBest, o_gBCount]=GetStGBest(i_stPop, i_fitInd)
pSizes=size(i_stPop);
pSize = pSizes(1,1);

o_gBest(1,:)=i_stPop(1,:);%默认排序后适值最高的为全局最优解
o_gBCount = 1;
stPi=2;
gBf=i_stPop(1,i_fitInd);
while (stPi <= pSize ) && (i_stPop(stPi,i_fitInd)==gBf)%只适用于排完序的
    o_gBCount = o_gBCount+1;
    o_gBest(o_gBCount,:)=i_stPop(stPi,:);
    stPi = stPi + 1;
end;

⌨️ 快捷键说明

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