?? asexual_reproduction.asv
字號:
clear;clc;GAInitial;fi(1,BOAT_NUM) = 0;sumFitnessAfter30(1,MAX_GEN) = 0;averageFitnessAfter30(1,MAX_GEN) = 0;for q = 1:Run_Time GenerateBoat; for k = 1:MAX_GEN As_Tournament_Best; As_Mutation; As_Tournament_Worst; %% if max1 > min1 % replace the worst boat for the best boat for i = 1:ROWER boat(min,i) = boat(max,i); end % else % for i = 1:ROWER % boat(max,i) = boat(min,i); % end % end %% choose the best fitness of the boat for n = 1:BOAT_NUM fi(1,n) = Fitness(n,ROWER,boat); end % averageFitness(1,q) = sum(fi) / BOAT_NUM; sumFitnessEachGeneration(1,k) = sum(fi); end for n = 1:MAX_GEN sumFitnessAfter30(1,n) = sumFitnessEachGeneration(1,n) + sumFitnessAfter30(1,n); endendfor n = 1:MAX_GEN averageFitnessAfter30(1,n) = sumFitnessAfter30(1,n) / 30;end% a = 1:Run_Time;% plot(a,maxFitness);% xlabel('running times');% ylabel('the best fitness');b = 1:MAX_GEN;figure,plot(b,averageFitnessAfter30);xlabel('generation');ylabel('the average fitness'); % fprintf('This is the Individual Fitness you choose: %d\n',Fitness_Value); % show the graph of every running time's fitness % a=1:Run_Time;% plot(a,For_Showing_Fitness);% calculate the average fitnessclear a;clear i;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -