?? mutate.m
字號:
function [new_gen,mutated] = mutate(old_gen,Pm)%MUTATE Changes a gene of the OLD_GEN with probability Pm.% [NEW_GEN,MUTATED] = MUTATE(OLD_GEN,Pm) performs random% mutation on the population OLD_POP. Each gene of each% individual of the population can mutate independently% with probability Pm. Genes are assumed possess boolean% alleles. MUTATED contains the indices of the mutated genes.%% Copyright (c) 1993 by the MathWorks, Inc.% Andrew Potvin 1-10-93.mutated = find(rand(size(old_gen))<Pm);new_gen = old_gen;new_gen(mutated) = 1-old_gen(mutated);% end mutate
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -