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

📄 cxcrossover.m

📁 基于信息熵的免疫算法是一种修正的免疫算法
💻 M
字号:
function [childpath1,childpath2]=CXCrossover(parentpath1,parentpath2,Pc)
%循环交叉
tempP=rand(1);
if(tempP<Pc)
    col=length(parentpath1);
    A=zeros(1,col);
    i=1;
    A(i)=1;
    k=1;
    childpath1(1)=parentpath1(1);
    [rwoindex,colindex]=find(parentpath1(1)==parentpath2);
    k=colindex;
    while(not(length(find(k==A))))
        childpath1(colindex)=parentpath1(colindex);
        i=i+1;
        A(i)=k;
        [rwoindex,colindex]=find(parentpath1(colindex)==parentpath2);
        k=colindex;        
    end
    for j=1:col
        if(not(length(find(j==A))))
            childpath1(j)=parentpath2(j);
        end
    end
    childpath2=parentpath2;
    for j=1:col
        if(not(length(find(j==A))))
            childpath2(j)=parentpath1(j);
        end
    end
else
    childpath1=parentpath1;
    childpath2=parentpath2;
end



        
        
        

⌨️ 快捷键说明

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