-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfind_leader.m
67 lines (53 loc) · 2.17 KB
/
find_leader.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
function opt = find_leader(opt)
%insert Non-dominated points as a leader
cls = opt.archiveCluster(opt.ParetoIndex,:);
opt.LeaderIndex = cell(1, opt.numdir);
%======================================================================
%first put Non-dominate front into cluster, if multiple points, choose
%the one with minimum ASF w.r.t that direction
%======================================================================
for i=1:opt.numdir
temp = opt.ParetoIndex(cls == i);%all solutions of class "i"
if~isempty(temp)
asfval = opt.archiveASF(temp);
[~,index] = min(asfval);
opt.LeaderIndex{i} = temp(index);
else
opt.LeaderIndex{i} = [];
end
end
%======================================================================
%find leaders for empty directions, ASF should not matter
%======================================================================
D = zeros(size(opt.archiveObj,1),opt.numdir);%matrix of orthogonal distances
for j=1:opt.numdir
w = opt.dirs(j,:);
w_org = zeros(1,opt.M);
for i=1:opt.M
w_org(i) = opt.min_val(i)+ w(i)*(opt.max_val(i)-opt.min_val(i));
end
for i=1:size(opt.archiveObj,1)
p = opt.archiveObj(i,:);
a = opt.min_val;
b = w_org;
ab = b-a;
ap = p-a;
p_cos_theta = dot(ab,ap)/norm(ab);
D(i,j) = sqrt(norm(ap)^2- p_cos_theta^2);
end
end
opt.D = D;
for i=1:opt.numdir
if isempty(opt.LeaderIndex{i})%if some cluster is empty
trust_index = find(opt.D(:,i)<=opt.TrustDistObj);
if ~isempty(trust_index)%any solution within trust region
asfval = opt.archiveASF(trust_index);
[~,index] = min(asfval);
opt.LeaderIndex{i} = trust_index(index);
else
[~, I] = min(opt.D(:,i));
opt.LeaderIndex{i} = I;%closest to the line
end
end
end
end