generatem.m

来自「用matlab实现免疫遗传算法求解tsp问题」· M 代码 · 共 21 行

M
21
字号
function MemoryLab=GenerateM(path,ktyqhl,CM,TSPMatrix,MemoryLab)
%生成记忆库
tempktyqhl=ktyqhl;
if(find(0==MemoryLab))
    [rowindex,colindex]=find(0==MemoryLab);
    for i=1:(CM/10)
        [temp,rowindex1]=max(tempktyqhl);
        tempktyqhl(rowindex1)=0;
        MemoryLab(rowindex(i),:)=path(rowindex1,:);
    end
else
    FP=Fitness(MemoryLab,TSPMatrix);
    for i=1:(CM/10)
        [temp,rowindex]=min(FP);
        FP(rowindex)=1;
        [temp,rowindex1]=max(tempktyqhl);
        tempktyqhl(rowindex1)=0;
        MemoryLab(rowindex,:)=path(rowindex1,:);
    end
end

⌨️ 快捷键说明

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