mutation.m
来自「使用遗传算法解决TSP问题的MATLAB源代码。」· 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 + -
显示快捷键?