📄 evaluateindividuals.m
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% File: evaluateIndividuals.m
%
% Description: Evaluate the fitness of the individual in the population.
% The example implemented is the m-k deceptive trap function.
%
% @param ranges is the a vector containing the cardinality of each of the
% alphabet. For example if all variables are binary then ranges(1:ell) = 2.
%
% @param population is the population of candidate solutions
%
% @return fitness is the fitness of all the individuals
%
% Author: Kumara Sastry
%
% Date: March 2007
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function fitness = evaluateIndividuals(ranges, population)
ell = size(ranges,2);
n = size(population,1);
% Building block size
k = 4;
% Signal difference
d = 0.25;
% Deceptive trap function
bbFitness = [1-d (1-d)*(1-1/3) (1-d)*(1-2/3) 0 1];
% Loose linkage
%bbMap = reshape(reshape(1:ell,ell/k,k)',1,ell);
% Tight linkage (uncomment the line below)
bbMap = 1:ell;
reshapedPop = reshape(population(:,bbMap),n,k,ell/k);
unitation = sum(reshapedPop,2);
fitness = sum(bbFitness(unitation+1),3);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -