mutate.m

来自「收集的GA的一些源程序」· M 代码 · 共 19 行

M
19
字号
function out=mutate(in,pmutate);
%
% Mutate the incoming chromasome
% with a probability of mutating
% each string of pmutate.
%
% This file takes only one member
% of the overall population.
%

[D L]=size(in);

for i = 1:L
	if rand(1)<pmutate
		in(1,i)=abs(in(1,i)-1);
	end
end
out=in;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?