91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2KB
    文件類型: .m
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-06-14
  • 語言: Matlab
  • 標簽: PMX??MATLAB??

資源簡介

PMX算法,部分匹配交叉算法.

資源截圖

代碼片段和文件信息

function?[newVanewVb]=PMX(VaVb)?
????startXorPoint=mod(ceil(rand(1)*10)length(Va)?);?
????if?startXorPoint==0?
????????startXorPoint=startXorPoint+1;?
????end????
????xorLength=mod(floor(rand(1)*10)length(Va));?
????endXorPoint=startXorPoint+xorLength;?
????while(endXorPoint>length(Vb)?)?
????????xorLength=mod(floor(rand(1)*10)length(Va));?
????????endXorPoint=startXorPoint+xorLength;?
????end????
????tempa=Va(startXorPoint:endXorPoint);?
????tempb=Vb(startXorPoint:endXorPoint);?
????%找出映射關系
????for?ix=1:length(tempa)?
????????aMappingb(ix1:2)=[Va(startXorPoint+ix-1)Vb(startXorPoint+ix-1)];
????end
????for?ix=1:length(tempa)?
????????bMappinga(ix1:2)=[Vb(startXorPoint+ix-1)Va(startXorPoint+ix-1)];
????end
????%交換子串
????Va(startXorPoint:endXorPoint)=tempb;?
????Vb(startXorPoint:endXorPoint)=tempa;?
????
????%對Va進行沖突檢測
????indexVa?=?1;
????while(indexVa????????singleGene?=??Va(indexVa);
????????while(?ismember(singleGenetempb)?==?1?)
????????????conflictIndex?=?find(tempb==singleGene);
????????????singleGene?=?bMappinga(conflictIndex2);
????????end
????????V

評論

共有 條評論