/
multi-objective-functions.jl
100 lines (76 loc) · 2.3 KB
/
multi-objective-functions.jl
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
"""
gen_ref_dirs(dimension, n_paritions)
Generates Das and Dennis's structured reference points. `dimension` could be
the number of objective functions in multi-objective functions.
"""
function gen_ref_dirs(dimension, n_paritions)
return gen_weights(dimension, n_paritions)
end
function gen_weights(a, b)
nobj = a;
H = b;
a = zeros(nobj);
d = H;
w = [];
produce_weight!(a, 1, d, H, nobj, w)
return Array.(w)
end
function produce_weight!(a, i, d, H, nobj, w)
for k=0:d
if i<nobj
a[i] = k;
d2 = d - k;
produce_weight!(a, i+1, d2, H, nobj, w);
else
a[i] = d;
push!(w, a/H)
break;
end
end
end
"""
ideal(points)
Computes the ideal point from a provided array of `Vector`s or a population or row vectors
in a `Matrix`.
"""
function ideal(points::Array{Vector{T}}) where T <: Real
(isempty(points) || isempty(points[1])) && return zeros(0)
ideal = points[1]
for point in points
ideal = min.(ideal, point)
end
return ideal
end
"""
nadir(points)
Computes the nadir point from a provided array of `Vector`s or a population or row vectors
in a `Matrix`.
"""
function nadir(points::Array{Vector{T}}) where T <: Real
(isempty(points) || isempty(points[1])) && return zeros(0)
nadir = points[1]
for point in points
nadir = max.(nadir, point)
end
return nadir
end
function ideal(population::Array{xFgh_indiv})
isempty(population) && (return zeros(0))
mask = sum_violations.(population) .== 0
if count(mask) == 0
@warn "Ideal point was computed using infeasible solutions. Use `ideal(fvals(population))` to ignore feasibility."
return ideal(fval.(population))
end
ideal(fval.(population[mask]))
end
ideal(A::Matrix) = ideal([A[i,:] for i in 1:size(A,1)])
function nadir(population::Array{xFgh_indiv})
isempty(population) && (return zeros(0))
mask = sum_violations.(population) .== 0
if count(mask) == 0
@warn "Nadir point was computed using infeasible solutions. Use `nadir(fvals(population))` to ignore feasibility."
return nadir(fval.(population))
end
nadir(fval.(population[mask]))
end
nadir(A::Matrix) = nadir([A[i,:] for i in 1:size(A,1)])