mutation.m

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

M
14
字号
function path=Mutation(path,Pm)
%位对调变异
[row,col]=size(path);
childpath=path;
for i=1:row
    point=randperm(col);
    tempP=rand(1);
    if(tempP<Pm)
        childpath(i,point(1))=path(i,point(2));
        childpath(i,point(2))=path(i,point(1));
    end
end
path=childpath;
        

⌨️ 快捷键说明

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