nsga2.m
来自「对多目标优化算法NSGA-II算法的改进」· M 代码 · 共 32 行
M
32 行
function nsga2()
clc;
POPSIZE = 10;
GEN = 2;
M = 2;
V = 6;
pop = initialize_variable(POPSIZE);
pop = non_domination_sort_mod(pop,POPSIZE);
for i = 1 : GEN
pool = round(POPSIZE/2);
tour = 2;
parent_pop = tournament_selection(pop,pool,tour);
pc = 0.9;
pm = 0.1;
muc = 20;
mum = 20;
child_pop = genetic_operator(parent_pop,pc,pm,muc,mum);
[pop_popsize temp] = size(pop);
[child_pop_popsize temp] = size(child_pop);
combination_pop(1 : pop_popsize,:) = pop;
combination_pop(pop_popsize + 1 : pop_popsize + child_pop_popsize,1 : M + V) = child_pop;
combination_pop = non_domination_sort_mod(combination_pop,POPSIZE);
pop = replacement(combination_pop,POPSIZE)
if (~mod(i,10))
fprintf('%d\n',i);
end
end
save solution.txt pop -ASCII
plot(pop(:,V + 1),pop(:,V + 2),'*');
title('NSGA II');
xlabel('f1(x)');
ylabel('f2(x)');
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?