-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchoosebyASF.m
54 lines (42 loc) · 1.48 KB
/
choosebyASF.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
function index = choosebyASF(opt, popObj, popCV)
asfAll = cell(1, opt.numdir);
asfCVAll = cell(1, opt.numdir);
min_val = min(popObj);
max_val = max(popObj);
if min(abs(max_val-min_val))>1e-6
normalized_obj = (popObj-repmat(min_val,size(popObj,1),1))./(repmat(max_val,size(popObj,1),1)-repmat(min_val,size(popObj,1),1));
else
normalized_obj = popObj;
end
for i=1:size(opt.dirs,1)
w = opt.dirs(i,:);
asf = calculate_Asf(normalized_obj, w);
asfAll{i} = asf;
end
%opt.archiveASFCVAll = opt.archiveASFAll;
feasbile_index = popCV<=0;
infeasible_index = find(popCV>0);%infeasible indices
asfCVAll = asfAll;
for i=1:size(opt.dirs,1)
if opt.C>0
feasibleASF = asfAll{i}(feasbile_index,:);
if ~isempty(feasibleASF)
fmax = max(feasibleASF);%maximum feasible ASF
else
fmax = 0;
end
if ~isempty(infeasible_index)
asfCVAll{i}(infeasible_index) = fmax + popCV(infeasible_index);
end
end
end
index = zeros(1, opt.numdir);
for i=1:size(opt.dirs,1)
[~, index(i)] = min(asfCVAll{i});
end
%index = unique(index);
%pop = pop(index, :);
end
function asf = calculate_Asf(obj, dir)
asf = max( (obj-repmat(dir, size(obj,1),1)),[],2);
end