-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathcheck_dominance.m
49 lines (47 loc) · 1.16 KB
/
check_dominance.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
function [ val ] = check_dominance(vec1, vec2)
% This procedure checks the dominance of two vectors,
% where the vectors are in the form [obj,cv]
% The non-domnination check will work like this --
% 1 if vec1 dominates vec2
% -1 if vec2 dominates vec1
% 0 if both vec1 and vec2 are non-dominated
%
% Please note: Vectorization on this function may not be too
% efficient as it operates on only two vectors, and couple of
% variables.
% split the obj and cv values
obj1 = vec1(1:end-1);
cv1 = vec1(end);
obj2 = vec2(1:end-1);
cv2 = vec2(end);
if(cv1 < 0 && cv2 < 0)
if(cv1 > cv2)
val = 1 ;
return ;
elseif(cv1 < cv2)
val = -1 ;
return ;
else
val = 0;
return ;
end
else
if(cv1 < 0 && cv2 == 0)
val = -1 ;
return ;
elseif(cv1 == 0 && cv2 < 0)
val = 1 ;
return ;
else
if(any(obj1 < obj2) && ~(any(obj1 > obj2)))
val = 1 ;
elseif(~(any(obj1 < obj2)) && any(obj1 > obj2))
val = -1 ;
else
val = 0 ;
return ;
end
end
end
% end of check_dominance
end