⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 crossover.m

📁 基于信息熵的免疫算法是一种修正的免疫算法
💻 M
字号:
function [childpath1,childpath2]=Crossover(parentpath1,parentpath2,Pc)
%部分影射交叉PMX
[row,col]=size(parentpath1);
tempP=rand(1);
childpath1=parentpath1;
childpath2=parentpath2;
if(tempP<Pc)
    point=randperm(col-1);
    point1=min(point(1),point(2));
    point2=max(point(1),point(2));
    for j=point1+1:point2
        [rowindex,colindex]=find(parentpath1(j)==parentpath2);
        childpath1(j)=parentpath1(colindex);
        childpath1(colindex)=parentpath1(j);
        [rowindex,colindex]=find(parentpath2(j)==parentpath1);
        childpath2(j)=parentpath2(colindex);
        childpath2(colindex)=parentpath2(j);
        parentpath1=childpath1;
        parentpath2=childpath2;
    end
end

⌨️ 快捷键说明

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