forked from White-Chen/DNSGA-II
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDNSGA_II_B.m
48 lines (47 loc) · 1.88 KB
/
DNSGA_II_B.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function DNSGA_II_B()
global pop colors itrCounter TestProblem step window dynamic CostFunction nVar VarMin VarMax numOfObj;
% Original algorithm NSGA-II was developed by researchers in Kanpur Genetic
% Algorithm Labarotary and kindly visit their website for more information
% http://www.iitk.ac.in/kangal/
colors = {'bo','go','ro','co','mo','ko','bv','gv','rv','cv','mv','kv','bs','gs','rs','cs','ms','ks'};
step = 10;
window = 20;
itrCounter = 1;
TestProblem = 37;
pop = 100;
pool = round(pop/2);
tour = 2;
mu = 10;
mum = 20;
mumrate = 0.2;
maxIt = round(step*window);
[numOfObj, nVar, VarMin, VarMax] = objective_description_function();
chromosome = [];
chromosome = initialize_variables(chromosome, 1);
chromosome = non_domination_sort_mod(chromosome, numOfObj, nVar);
%%%%%%%%%%
for itrCounter = 1 : maxIt
parent_chromosome = tournament_selection(chromosome, pool, tour);
offspring_chromosome = ...
genetic_operator(parent_chromosome, ...
numOfObj, nVar, mu, mum, VarMin, VarMax, itrCounter);
[main_pop,temp] = size(chromosome);
[offspring_pop,temp] = size(offspring_chromosome);
clear temp
intermediate_chromosome(1:main_pop,:) = chromosome;
intermediate_chromosome(main_pop + 1 : main_pop + offspring_pop,1 : numOfObj+nVar) = ...
offspring_chromosome;
intermediate_chromosome = ...
non_domination_sort_mod(intermediate_chromosome, numOfObj, nVar);
chromosome = replace_chromosome(intermediate_chromosome, numOfObj, nVar, pop);
if ~mod(itrCounter,10)
disp([num2str(itrCounter),' generations completed, chromesome number ',num2str(size(chromosome,1))])
end
population2pic(chromosome);
if mod(itrCounter,window) == 0 && dynamic == 1
chromosome = mutate(chromosome,mumrate,mum);
chromosome = non_domination_sort_mod(chromosome, numOfObj, nVar);
end
end
population2pic(chromosome,chromosome);
%% Visualize