-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUpdateArchive.m
More file actions
34 lines (32 loc) · 997 Bytes
/
UpdateArchive.m
File metadata and controls
34 lines (32 loc) · 997 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
33
34
function Archive = UpdateArchive(AllPop,N)
% 如果没有可行解,则Archive为空
Feasible = AllPop(sum(max(0,AllPop.cons),2)==0);
if ~isempty(Feasible)
% 更新Archive
[FrontNo,~] = NDSort([AllPop.objs,sum(max(0,AllPop.cons),2)],inf);
AllPop = AllPop(FrontNo==1);
InFeasible = AllPop(sum(max(0,AllPop.cons),2)~=0);
[Front,~] = NDSort(-InFeasible.objs,1);
Next = Front == 1;
Archive = InFeasible(Next);
if length(Archive)>N
Del = Truncation(Archive.objs,sum(Next)-N);
Archive(Del) = [];
end
else
Archive = [];
end
end
function Del = Truncation(PopObj,K)
% Select part of the solutions by truncation
%% Truncation
Distance = pdist2(PopObj,PopObj);
Distance(logical(eye(length(Distance)))) = inf;
Del = false(1,size(PopObj,1));
while sum(Del) < K
Remain = find(~Del);
Temp = sort(Distance(Remain,Remain),2);
[~,Rank] = sortrows(Temp);
Del(Remain(Rank(1))) = true;
end
end