pymoo 0.6.1.3__cp312-cp312-win_amd64.whl → 0.6.1.5__cp312-cp312-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pymoo might be problematic. Click here for more details.
- pymoo/algorithms/moo/age.py +13 -7
- pymoo/algorithms/moo/age2.py +49 -19
- pymoo/algorithms/moo/ctaea.py +2 -2
- pymoo/algorithms/moo/kgb.py +9 -9
- pymoo/algorithms/moo/nsga3.py +2 -2
- pymoo/algorithms/moo/pinsga2.py +370 -0
- pymoo/algorithms/moo/rnsga3.py +2 -2
- pymoo/algorithms/soo/nonconvex/es.py +3 -2
- pymoo/config.py +1 -1
- pymoo/core/algorithm.py +1 -1
- pymoo/core/individual.py +8 -7
- pymoo/core/replacement.py +5 -5
- pymoo/core/survival.py +1 -1
- pymoo/core/variable.py +9 -9
- pymoo/cython/calc_perpendicular_distance.cp312-win_amd64.pyd +0 -0
- pymoo/cython/calc_perpendicular_distance.cpp +27479 -0
- pymoo/cython/calc_perpendicular_distance.pyx +67 -0
- pymoo/cython/decomposition.cp312-win_amd64.pyd +0 -0
- pymoo/cython/decomposition.cpp +28889 -0
- pymoo/cython/decomposition.pyx +165 -0
- pymoo/cython/hv.cp312-win_amd64.pyd +0 -0
- pymoo/cython/hv.cpp +27571 -0
- pymoo/cython/hv.pyx +18 -0
- pymoo/cython/info.cp312-win_amd64.pyd +0 -0
- pymoo/cython/info.cpp +6653 -0
- pymoo/cython/info.pyx +5 -0
- pymoo/cython/mnn.cp312-win_amd64.pyd +0 -0
- pymoo/cython/mnn.cpp +30129 -0
- pymoo/cython/mnn.pyx +273 -0
- pymoo/cython/non_dominated_sorting.cp312-win_amd64.pyd +0 -0
- pymoo/cython/non_dominated_sorting.cpp +35268 -0
- pymoo/cython/non_dominated_sorting.pyx +645 -0
- pymoo/cython/pruning_cd.cp312-win_amd64.pyd +0 -0
- pymoo/cython/pruning_cd.cpp +29289 -0
- pymoo/cython/pruning_cd.pyx +197 -0
- pymoo/cython/stochastic_ranking.cp312-win_amd64.pyd +0 -0
- pymoo/cython/stochastic_ranking.cpp +27884 -0
- pymoo/cython/stochastic_ranking.pyx +49 -0
- pymoo/cython/vendor/hypervolume.cpp +1621 -0
- pymoo/docs.py +1 -1
- pymoo/operators/crossover/ox.py +1 -1
- pymoo/operators/selection/rnd.py +2 -2
- pymoo/operators/selection/tournament.py +5 -5
- pymoo/optimize.py +2 -2
- pymoo/problems/dynamic/df.py +4 -4
- pymoo/problems/single/traveling_salesman.py +1 -1
- pymoo/util/misc.py +2 -2
- pymoo/util/mnn.py +2 -2
- pymoo/util/nds/fast_non_dominated_sort.py +5 -3
- pymoo/util/nds/non_dominated_sorting.py +2 -2
- pymoo/util/normalization.py +5 -8
- pymoo/util/ref_dirs/energy.py +4 -2
- pymoo/util/ref_dirs/reduction.py +1 -1
- pymoo/util/reference_direction.py +3 -2
- pymoo/util/value_functions.py +719 -0
- pymoo/util/vf_dominator.py +99 -0
- pymoo/version.py +1 -1
- pymoo/visualization/heatmap.py +3 -3
- pymoo/visualization/pcp.py +1 -1
- pymoo/visualization/radar.py +1 -1
- {pymoo-0.6.1.3.dist-info → pymoo-0.6.1.5.dist-info}/METADATA +12 -13
- {pymoo-0.6.1.3.dist-info → pymoo-0.6.1.5.dist-info}/RECORD +65 -45
- {pymoo-0.6.1.3.dist-info → pymoo-0.6.1.5.dist-info}/WHEEL +1 -1
- {pymoo-0.6.1.3.dist-info → pymoo-0.6.1.5.dist-info/licenses}/LICENSE +0 -0
- {pymoo-0.6.1.3.dist-info → pymoo-0.6.1.5.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# distutils: language = c++
|
|
2
|
+
# cython: language_level=2, boundscheck=False, wraparound=False, cdivision=True
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
from pymoo.cython.utils cimport c_get_drop, c_get_argmin, c_get_argmax, c_normalize_array
|
|
7
|
+
|
|
8
|
+
from libcpp cimport bool
|
|
9
|
+
from libcpp.vector cimport vector
|
|
10
|
+
from libcpp.set cimport set as cpp_set
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
cdef extern from "math.h":
|
|
14
|
+
double HUGE_VAL
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# Python definition
|
|
18
|
+
def calc_pcd(double[:, :] X, int n_remove=0):
|
|
19
|
+
|
|
20
|
+
cdef:
|
|
21
|
+
int N, M, n
|
|
22
|
+
cpp_set[int] extremes
|
|
23
|
+
vector[int] extremes_min, extremes_max
|
|
24
|
+
int[:, :] I
|
|
25
|
+
|
|
26
|
+
N = X.shape[0]
|
|
27
|
+
M = X.shape[1]
|
|
28
|
+
|
|
29
|
+
if n_remove <= (N - M):
|
|
30
|
+
if n_remove < 0:
|
|
31
|
+
n_remove = 0
|
|
32
|
+
else:
|
|
33
|
+
pass
|
|
34
|
+
else:
|
|
35
|
+
n_remove = N - M
|
|
36
|
+
|
|
37
|
+
extremes_min = c_get_argmin(X)
|
|
38
|
+
extremes_max = c_get_argmax(X)
|
|
39
|
+
|
|
40
|
+
extremes = cpp_set[int]()
|
|
41
|
+
|
|
42
|
+
for n in extremes_min:
|
|
43
|
+
extremes.insert(n)
|
|
44
|
+
|
|
45
|
+
for n in extremes_max:
|
|
46
|
+
extremes.insert(n)
|
|
47
|
+
|
|
48
|
+
_I = np.argsort(X, axis=0, kind='mergesort').astype(np.intc)
|
|
49
|
+
I = _I[:, :]
|
|
50
|
+
|
|
51
|
+
X = c_normalize_array(X, extremes_max, extremes_min)
|
|
52
|
+
|
|
53
|
+
return c_calc_pcd(X, I, n_remove, N, M, extremes)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# Returns crowding metrics with recursive elimination
|
|
57
|
+
cdef c_calc_pcd(double[:, :] X, int[:, :] I, int n_remove, int N, int M, cpp_set[int] extremes):
|
|
58
|
+
|
|
59
|
+
cdef:
|
|
60
|
+
int n, n_removed, k
|
|
61
|
+
cpp_set[int] calc_items
|
|
62
|
+
cpp_set[int] H
|
|
63
|
+
double[:, :] D
|
|
64
|
+
double[:] d
|
|
65
|
+
|
|
66
|
+
# Define items to calculate distances
|
|
67
|
+
calc_items = cpp_set[int]()
|
|
68
|
+
for n in range(N):
|
|
69
|
+
calc_items.insert(n)
|
|
70
|
+
for n in extremes:
|
|
71
|
+
calc_items.erase(n)
|
|
72
|
+
|
|
73
|
+
# Define remaining items to evaluate
|
|
74
|
+
H = cpp_set[int]()
|
|
75
|
+
for n in range(N):
|
|
76
|
+
H.insert(n)
|
|
77
|
+
|
|
78
|
+
# Initialize
|
|
79
|
+
n_removed = 0
|
|
80
|
+
|
|
81
|
+
# Initialize neighbors and distances
|
|
82
|
+
_D = np.full((N, M), HUGE_VAL, dtype=np.double)
|
|
83
|
+
dd = np.full((N,), HUGE_VAL, dtype=np.double)
|
|
84
|
+
|
|
85
|
+
D = _D[:, :]
|
|
86
|
+
d = dd[:]
|
|
87
|
+
|
|
88
|
+
# Fill in neighbors and distance matrix
|
|
89
|
+
c_calc_pcd_iter(
|
|
90
|
+
X,
|
|
91
|
+
I,
|
|
92
|
+
D,
|
|
93
|
+
N, M,
|
|
94
|
+
calc_items,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
# Obtain distance metrics
|
|
98
|
+
c_calc_d(d, D, calc_items, M)
|
|
99
|
+
|
|
100
|
+
# While n_remove not acheived
|
|
101
|
+
while n_removed < (n_remove - 1):
|
|
102
|
+
|
|
103
|
+
# Obtain element to drop
|
|
104
|
+
k = c_get_drop(d, H)
|
|
105
|
+
H.erase(k)
|
|
106
|
+
|
|
107
|
+
# Update index
|
|
108
|
+
n_removed = n_removed + 1
|
|
109
|
+
|
|
110
|
+
# Get items to be recalculated
|
|
111
|
+
calc_items = c_get_calc_items(I, k, M, N)
|
|
112
|
+
for n in extremes:
|
|
113
|
+
calc_items.erase(n)
|
|
114
|
+
|
|
115
|
+
# Fill in neighbors and distance matrix
|
|
116
|
+
c_calc_pcd_iter(
|
|
117
|
+
X,
|
|
118
|
+
I,
|
|
119
|
+
D,
|
|
120
|
+
N, M,
|
|
121
|
+
calc_items,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
# Obtain distance metrics
|
|
125
|
+
c_calc_d(d, D, calc_items, M)
|
|
126
|
+
|
|
127
|
+
return dd
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
# Iterate
|
|
131
|
+
cdef c_calc_pcd_iter(
|
|
132
|
+
double[:, :] X,
|
|
133
|
+
int[:, :] I,
|
|
134
|
+
double[:, :] D,
|
|
135
|
+
int N, int M,
|
|
136
|
+
cpp_set[int] calc_items,
|
|
137
|
+
):
|
|
138
|
+
|
|
139
|
+
cdef:
|
|
140
|
+
int i, m, n, l, u
|
|
141
|
+
|
|
142
|
+
# Iterate over items to calculate
|
|
143
|
+
for i in calc_items:
|
|
144
|
+
|
|
145
|
+
# Iterate over elements in X
|
|
146
|
+
for m in range(M):
|
|
147
|
+
|
|
148
|
+
for n in range(N):
|
|
149
|
+
|
|
150
|
+
if i == I[n, m]:
|
|
151
|
+
|
|
152
|
+
l = I[n - 1, m]
|
|
153
|
+
u = I[n + 1, m]
|
|
154
|
+
|
|
155
|
+
D[i, m] = (X[u, m] - X[l, m]) / M
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
# Calculate crowding metric
|
|
159
|
+
cdef c_calc_d(double[:] d, double[:, :] D, cpp_set[int] calc_items, int M):
|
|
160
|
+
|
|
161
|
+
cdef:
|
|
162
|
+
int i, m
|
|
163
|
+
|
|
164
|
+
for i in calc_items:
|
|
165
|
+
|
|
166
|
+
d[i] = 0
|
|
167
|
+
for m in range(M):
|
|
168
|
+
d[i] = d[i] + D[i, m]
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
# Returns indexes of items to be recalculated after removal
|
|
172
|
+
cdef cpp_set[int] c_get_calc_items(
|
|
173
|
+
int[:, :] I,
|
|
174
|
+
int k, int M, int N
|
|
175
|
+
):
|
|
176
|
+
|
|
177
|
+
cdef:
|
|
178
|
+
int n, m
|
|
179
|
+
cpp_set[int] calc_items
|
|
180
|
+
|
|
181
|
+
calc_items = cpp_set[int]()
|
|
182
|
+
|
|
183
|
+
# Iterate over all elements in I
|
|
184
|
+
for m in range(M):
|
|
185
|
+
|
|
186
|
+
for n in range(N):
|
|
187
|
+
|
|
188
|
+
if I[n, m] == k:
|
|
189
|
+
|
|
190
|
+
# Add to set of items to be recalculated
|
|
191
|
+
calc_items.insert(I[n - 1, m])
|
|
192
|
+
calc_items.insert(I[n + 1, m])
|
|
193
|
+
|
|
194
|
+
# Remove element from sorted array
|
|
195
|
+
I[n:-1, m] = I[n + 1:, m]
|
|
196
|
+
|
|
197
|
+
return calc_items
|
|
Binary file
|