children.m
来自「一些用matlab编写的经典遗传算法算例。可以用于解决许多优化问题」· M 代码 · 共 34 行
M
34 行
function childs = children(parent,method,pmut)
% CHILDREN - Creates the children from the parentpool
%
% c=children(parent,'method',pmut) The function returns a
% vector with the children created from the supplied matrix of
% parents. The methods allowed is described below, the argument
% 'pmut' is the probability of mutation.
%
% 'uform' - uniform crossover
% 'npoint' - n points crossover a number with the desired
% points. NOT IMPLEMENTED YET
%
% See also PARENTS,UI_MUTATE,MUTATE
ind=1;
switch method
case 'uform'
[m n]=size(parent);
for k=1:m
c1=parent(k,1)+parent(k,2);
c1=morph(c1,parent(k,2),pmut);
childs(ind)=c1;
ind=ind+1;
c2=parent(k,2)+parent(k,1);
c2=morph(c2,parent(k,1),pmut);
childs(ind)=c2;
ind=ind+1;
end
otherwise
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?