onepointcrox.m

来自「simple GASVM for LS-SVM」· M 代码 · 共 28 行

M
28
字号
function [newVa,newVb]=onePointCrox(Va,Vb)%--------------------------------------------------------------------------------%Step1. ∕﹚crossover pointstartXorPoint=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(Va))   xorLength=mod(floor(rand(1)*10),length(Va));   endXorPoint=startXorPoint+xorLength;end%--------------------------------------------------------------------------%Step 2. 秈︽crossoverfirstParent=Va;secondParent=Vb;%---subString1=Va(startXorPoint:endXorPoint);%---subString2=Vb(startXorPoint:endXorPoint);%---firstParent(startXorPoint:endXorPoint)=subString2;%---secondParent(startXorPoint:endXorPoint)=subString1;%--------------------------------------------------------------------------newVa=firstParent;newVb=secondParent;

⌨️ 快捷键说明

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