📄 nsga2.m
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -