?? mainasexualproduction.asv
字號:
function [boat,sumFitnessEachGeneration] = MainAsexualProduction(boat, BOAT_NUM, ROWER, Pm,MAX_GEN)
fi(1,BOAT_NUM) = 0;
for Generation = 1:MAX_GEN
A = round(rand*BOAT_NUM)+1;
B = round(rand*2*radius)+1;
C = round(rand*2*radius)+1;
D = round(rand*2*radius)+1;
% Select a parent according to fitness
fA = ComputeFitness(boat(A,:));
fB = ComputeFitness(boat(B,:));
fC = ComputeFitness(boat(C,:));
fD = ComputeFitness(boat(D,:));
if fC > fD
replacement = D;
else replacement = C;
end
if fA > fB
boat(replacement,:) = AsexuallyProduce(boat(A,:), Pm);
else
boat(replacement,:) = AsexuallyProduce(boat(B,:), Pm);
end
for n = 1:BOAT_NUM
fi(1,n) = ComputeFitness(boat(n,:));
end
% averageFitness(1,q) = sum(fi) / BOAT_NUM;
sumFitnessEachGeneration(1,Generation) = sum(fi);
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -