⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mutate.m

📁 一种标准的遗传算法实例
💻 M
字号:
function [new,nmut] = mutate(pop,pm)
% MUTATE perform mutation on population of chromsomes
% new = mutate(pop,pm)
% author:	Ron Shaffer
% version:	1.0
% date:		1/23/96

% 
% set constants
%
[popsize,ndim] = size(pop);
nmut = 0;
%
% loop through population testing whether to mutate
%
for i = 1:popsize
	for j = 1:ndim
		test = rand;
		if test < pm
			pop(i,j) = abs(pop(i,j)-1);
			nmut = nmut + 1;
		end
	end
end
%
% return new population
%
new = pop;

		

⌨️ 快捷键说明

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