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

📄 mut.m

📁 matlab遗传算法工具箱
💻 M
字号:
% MUT.m%% This function takes the representation of the current population,% mutates each element with given probability and returns the resulting% population.%% Syntax:	NewChrom = mut(OldChrom,Pm,BaseV)%% Input parameters:%%		OldChrom - A matrix containing the chromosomes of the%			   current population. Each row corresponds to%			   an individuals string representation.%%		Pm	 - Mutation probability (scalar). Default value%			   of Pm = 0.7/Lind, where Lind is the chromosome%			   length is assumed if omitted.%%		BaseV	 - Optional row vector of the same length as the%			   chromosome structure defining the base of the %			   individual elements of the chromosome. Binary%			   representation is assumed if omitted.%% Output parameter:%%		NewChrom - A Matrix containing a mutated version of%			   OldChrom.%% Author: Andrew Chipperfield% Date: 25-Jan-94function NewChrom = mut(OldChrom,Pm,BaseV)% get population size (Nind) and chromosome length (Lind)[Nind, Lind] = size(OldChrom) ;% check input parametersif nargin < 2, Pm = 0.7/Lind ; endif isnan(Pm), Pm = 0.7/Lind; endif (nargin < 3), BaseV = crtbase(Lind);  endif (isnan(BaseV)), BaseV = crtbase(Lind);  endif (isempty(BaseV)), BaseV = crtbase(Lind);  endif (nargin == 3) & (Lind ~= length(BaseV))   error('OldChrom and BaseV are incompatible'), end% create mutation mask matrixBaseM = BaseV(ones(Nind,1),:) ;% perform mutation on chromosome structureNewChrom = rem(OldChrom+(rand(Nind,Lind)<Pm).*ceil(rand(Nind,Lind).*(BaseM-1)),BaseM);

⌨️ 快捷键说明

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