?? osimplepointxover.sci
字號:
function [c1,c2]= OSimplePointXover(p1,p2,bounds,Ops)
// function [c1,c2] = singlePtXover(p1,p2,bounds,Ops)
// p1 - the first parent ( [solution string function value] )
// p2 - the second parent ( [solution string function value] )
// bounds - the bounds matrix for the solution space
// Ops - Options matrix for simple crossover [gen #SimpXovers].
rng = (bounds(:,2)-bounds(:,1))'; // The variable ranges'
numArranges = rng + 1; // Number of each arrages
cumArranges = cumsum([0 numArranges]);
xZomeLength = sum(numArranges)+1; // Length of string is numVar + fit
c1=p1;
c2=p2;
for i= 1:size(numArranges,2)
sz=numArranges(i);
pfrom=(cumArranges(i)+1);
pto=cumArranges(i+1);
cut = round(rand(1)*(sz-1)+0.5); // Generate random cut point U(1,n-1)
part1 = p1(pfrom:pto);
part2 = p2(pfrom:pto);
pm1=part1;
pm2=part2;
for i=pfrom:pfrom+cut-1
pm1(find(pm1=p2(i)))=-1;
pm2(find(pm2=p1(i)))=-1;
end
c1((cut+pfrom):pto)=p2(pfrom+find(pm2>0)-1);
c2((cut+pfrom):pto)=p1(pfrom+find(pm1>0)-1);
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -