?? mutation_2genetic.m
字號:
function mutation_population=mutation_genetic(crossover_population,p_mutation)
population_count=length(crossover_population);
rand_count=round(population_count*p_mutation);
rand_indiv=ceil(rand(1,rand_count)*population_count);
for n=1:rand_count
temp=crossover_population(:,rand_indiv(n));
if rand<0.5
rand_position=1;
else
rand_position=2;
end
rand_number=round(rand()*360);
crossover_population(rand_position,rand_indiv(n))=rand_number;
end
mutation_population=crossover_population;
% population_count=length(crossover_population);
% rand_count=round(population_count*p_mutation);
% rand_indiv=ceil(rand(1,rand_count)*population_count);
% for n=1:rand_count
% temp=num2str(crossover_population(rand_indiv(n)));
% rand_position=ceil(rand()*length(temp));
% rand_number=round(rand()*9);
% temp(rand_position)=rand_number;
% temp_result=str2num(temp);
% if temp_result>360
% temp_result=360;
% crossover_population(rand_indiv(n))=temp_result;
% end
% end
% mutation_population=crossover_population;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -