children.m

来自「多目标遗传算法/用法不用多说、要用的赶快下载吧」· 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,MUTATEind=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 otherwiseend

⌨️ 快捷键说明

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