-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCrowdingDistance.m
More file actions
32 lines (23 loc) · 800 Bytes
/
CrowdingDistance.m
File metadata and controls
32 lines (23 loc) · 800 Bytes
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
function pop=CrowdingDistance(pop,F)
%Number of the rank of F set
nF = numel(F);
for i = 1 : nF
Results = [pop(F{i}).Cost];
nObjective = size(Results, 1);
nIndividual = numel(F{i});
dist = zeros(nIndividual, nObjective);
for j = 1:nObjective
[SortResult, Index] = sort(Results(j, :));
%Set Fmin = inf
dist(Index(1), j) = inf;
%Set Fmax = inf
dist(Index(end), j) = inf;
for k = 2 : nIndividual - 1
dist(Index(k), j) = abs(SortResult(k+1) - SortResult(k-1))/abs(SortResult(end)-SortResult(1));
end
end
for j = 1:nIndividual
pop(F{i}(j)).CrowdingDistance = sum(dist(j, :));
end
end
end