-
Notifications
You must be signed in to change notification settings - Fork 2
/
CrowdingDistance.m
29 lines (27 loc) · 1.32 KB
/
CrowdingDistance.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
function CrowdDis = CrowdingDistance(PopObj,FrontNo)
% Calculate the crowding distance of each solution front by front
%------------------------------- Copyright --------------------------------
% Copyright (c) 2018-2019 BIMK Group. You are free to use the PlatEMO for
% research purposes. All publications which use this platform or any code
% in the platform should acknowledge the use of "PlatEMO" and reference "Ye
% Tian, Ran Cheng, Xingyi Zhang, and Yaochu Jin, PlatEMO: A MATLAB platform
% for evolutionary multi-objective optimization [educational forum], IEEE
% Computational Intelligence Magazine, 2017, 12(4): 73-87".
%--------------------------------------------------------------------------
[N,M] = size(PopObj);
CrowdDis = zeros(1,N);
Fronts = setdiff(unique(FrontNo),inf);
for f = 1 : length(Fronts)
Front = find(FrontNo==Fronts(f));
Fmax = max(PopObj(Front,:),[],1);
Fmin = min(PopObj(Front,:),[],1);
for i = 1 : M
[~,Rank] = sortrows(PopObj(Front,i));
CrowdDis(Front(Rank(1))) = inf;
CrowdDis(Front(Rank(end))) = inf;
for j = 2 : length(Front)-1
CrowdDis(Front(Rank(j))) = CrowdDis(Front(Rank(j)))+(PopObj(Front(Rank(j+1)),i)-PopObj(Front(Rank(j-1)),i))/(Fmax(i)-Fmin(i));
end
end
end
end