binarymutation.m

来自「18个遗传算法程序matlab源码」· M 代码 · 共 17 行

M
17
字号
function [parent] = binaryMutate(parent,bounds,Ops)% Binary mutation changes each of the bits of the parent% based on the probability of mutation%% function [newSol] = binaryMutate(parent,bounds,Ops)% parent  - the first parent ( [solution string function value] )% bounds  - the bounds matrix for the solution space% Ops     - Options for binaryMutation [gen prob_of_mutation]pm=Ops(2);numVar = size(parent,2)-1; 		% Get the number of variables % Pick a variable to mutate randomly from 1-number of varsrN=rand(1,numVar)<pm;parent=[abs(parent(1:numVar) - rN) parent(numVar+1)];  

⌨️ 快捷键说明

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