tournament_selection.m
来自「对多目标优化算法NSGA-II算法的改进」· M 代码 · 共 25 行
M
25 行
function f = tournament_selection(pop,pool_size,tour_size)
[popsize variables] = size(pop);
rank = variables - 1;
crowding_distance = variables;
for i = 1 : pool_size
for j = 1 : tour_size
candidate(j) = round((popsize - 1)*rand) + 1;
if (j > 1)
while (~isempty(find(candidate(1 : j - 1) == candidate(j))))
candidate(j) = round((popsize - 1)*rand) + 1;
end
end
end
for j = 1 : tour_size
rank_objectives(j) = pop(candidate(j),rank);
crowding_distance_objectives(j) = pop(candidate(j),crowding_distance);
end
min_candidate = find(rank_objectives == min(rank_objectives));
if (length(min_candidate) > 1)
max_candidate = find(crowding_distance_objectives(min_candidate) == max(crowding_distance_objectives(min_candidate)));
f(i,:) = pop(candidate(min_candidate(max_candidate(1))),:);
else
f(i,:) = pop(candidate(min_candidate(1)),:);
end
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?