-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassign_fitness.m
90 lines (63 loc) · 1.81 KB
/
assign_fitness.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
function [fitness_ranking]=assign_fitness(pre_fitness_log)
x=[];
x=size(pre_fitness_log);
pre_fitness_log_size=x(1);
%disp(pre_fitness_log_size);
rank=[];
rank=zeros(1,pre_fitness_log_size);
fitness_ranking=[];
fitness_ranking=zeros(pre_fitness_log_size,pre_fitness_log_size);
N=zeros(1,pre_fitness_log_size);
S=zeros(pre_fitness_log_size,pre_fitness_log_size);
for i=1:1:pre_fitness_log_size
for j=1:1:pre_fitness_log_size
if i~=j
x=dominates(i,j,pre_fitness_log); % checks if i dominates j
z=dominates(j,i,pre_fitness_log);
if x==1 % i dominates j
y=[];
y=find(S(i,:)==0);
S(i,y(1))=j;
elseif z==1
N(i)=N(i)+1;
end
end
end
if N(i)==0
rank(i)=1;
x=[];
x=find(fitness_ranking(1,:)==0);
fitness_ranking(1,x(1))=i;
end
end
%{
disp(fitness_ranking(1,:));
disp(' ');
disp(S);
disp(N);
%}
i=1;
temp=[];
Q=zeros(1,pre_fitness_log_size);
while (~isempty(find(fitness_ranking(i,:)==0)) && i<pre_fitness_log_size)
a=find(fitness_ranking(i,:)==0);
temp=zeros(1,pre_fitness_log_size);
for j=1:1:a(1)-1
e=fitness_ranking(i,j);
b=find(S(e,:)==0);
for k=1:1:b(1)-1
c=S(e,k);
N(c)=N(c)-1;
if N(c)==0
rank(c)=i+1;
d=find(Q==0);
Q(d(1))=c;
end
end
end
i=i+1;
fitness_ranking(i,:)=Q;
Q=zeros(1,pre_fitness_log_size);
end
%disp(rank);
%disp(fitness_ranking);