selectionuniform.m
来自「遗传算法工具包」· M 代码 · 共 23 行
M
23 行
function parents = selectionuniform(expectation,nParents,options)
%SELECTIONUNIFORM Choose parents at random.
% PARENTS = SELECTIONUNIFORM(EXPECTATION,NPARENTS,OPTIONS) chooses
% PARENTS randomly using the EXPECTATION and number of parents NPARENTS.
%
% Parent selection is NOT a function of performance. This selection function
% is useful for debugging your own custom selection, or for comparison. It is
% not useful for actual evolution of high performing individuals.
%
% Example:
% Create an options structure using SELECTIONUNIFORM as the selection
% function.
% options = gaoptimset('SelectionFcn', @selectionuniform);
% Copyright 2004 The MathWorks, Inc.
% $Revision: 1.7 $ $Date: 2004/01/16 16:51:30 $
% nParents random numbers
parents = rand(1,nParents);
% integers on the interval [1, populationSize]
parents = ceil(parents * length(expectation));
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?