mutate.m

来自「利用GA算法实现软件测试的测试用例选取」· M 代码 · 共 17 行

M
17
字号
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 + =
减小字号Ctrl + -
显示快捷键?