fitscalingrank.m

来自「遗传算法工具包」· M 代码 · 共 21 行

M
21
字号
function expectation = fitscalingrank(scores,nParents)
% FITSCALINGRANK Rank based fitness scaling.
%   EXPECTATION = FITSCALINGRANK(SCORES,NPARENTS) calculates the
%   EXPECTATION using the SCORES and number of parents NPARENTS.
%   This relationship can be linear or nonlinear.
%
%   Example:
%   Create an options structure using FITSCALINGRANK as 
%   the fitness scaling function
%     options = gaoptimset('FitnessScalingFcn',@fitscalingrank);

%   Copyright 2004 The MathWorks, Inc. 
%   $Revision: 1.7 $  $Date: 2004/01/16 16:51:41 $

[unused,i] = sort(scores);

expectation = zeros(size(scores));
expectation(i) = 1 ./ ((1:length(scores))  .^ 0.5);

expectation = nParents * expectation ./ sum(expectation);

⌨️ 快捷键说明

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