pymoo 0.6.1.3__cp310-cp310-macosx_10_9_universal2.whl → 0.6.1.5__cp310-cp310-macosx_10_9_universal2.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.

Files changed (57) hide show
  1. pymoo/algorithms/moo/age.py +13 -7
  2. pymoo/algorithms/moo/age2.py +49 -19
  3. pymoo/algorithms/moo/ctaea.py +2 -2
  4. pymoo/algorithms/moo/kgb.py +9 -9
  5. pymoo/algorithms/moo/nsga3.py +2 -2
  6. pymoo/algorithms/moo/pinsga2.py +370 -0
  7. pymoo/algorithms/moo/rnsga3.py +2 -2
  8. pymoo/algorithms/soo/nonconvex/es.py +3 -2
  9. pymoo/config.py +1 -1
  10. pymoo/core/algorithm.py +1 -1
  11. pymoo/core/individual.py +8 -7
  12. pymoo/core/replacement.py +5 -5
  13. pymoo/core/survival.py +1 -1
  14. pymoo/core/variable.py +9 -9
  15. pymoo/cython/calc_perpendicular_distance.cpython-310-darwin.so +0 -0
  16. pymoo/cython/calc_perpendicular_distance.pyx +67 -0
  17. pymoo/cython/decomposition.cpython-310-darwin.so +0 -0
  18. pymoo/cython/decomposition.pyx +165 -0
  19. pymoo/cython/hv.cpython-310-darwin.so +0 -0
  20. pymoo/cython/hv.pyx +18 -0
  21. pymoo/cython/info.cpython-310-darwin.so +0 -0
  22. pymoo/cython/info.pyx +5 -0
  23. pymoo/cython/mnn.cpython-310-darwin.so +0 -0
  24. pymoo/cython/mnn.pyx +273 -0
  25. pymoo/cython/non_dominated_sorting.cpython-310-darwin.so +0 -0
  26. pymoo/cython/non_dominated_sorting.pyx +645 -0
  27. pymoo/cython/pruning_cd.cpython-310-darwin.so +0 -0
  28. pymoo/cython/pruning_cd.pyx +197 -0
  29. pymoo/cython/stochastic_ranking.cpython-310-darwin.so +0 -0
  30. pymoo/cython/stochastic_ranking.pyx +49 -0
  31. pymoo/cython/vendor/hypervolume.cpp +1621 -0
  32. pymoo/docs.py +1 -1
  33. pymoo/operators/crossover/ox.py +1 -1
  34. pymoo/operators/selection/rnd.py +2 -2
  35. pymoo/operators/selection/tournament.py +5 -5
  36. pymoo/optimize.py +2 -2
  37. pymoo/problems/dynamic/df.py +4 -4
  38. pymoo/problems/single/traveling_salesman.py +1 -1
  39. pymoo/util/misc.py +2 -2
  40. pymoo/util/mnn.py +2 -2
  41. pymoo/util/nds/fast_non_dominated_sort.py +5 -3
  42. pymoo/util/nds/non_dominated_sorting.py +2 -2
  43. pymoo/util/normalization.py +5 -8
  44. pymoo/util/ref_dirs/energy.py +4 -2
  45. pymoo/util/ref_dirs/reduction.py +1 -1
  46. pymoo/util/reference_direction.py +3 -2
  47. pymoo/util/value_functions.py +719 -0
  48. pymoo/util/vf_dominator.py +99 -0
  49. pymoo/version.py +1 -1
  50. pymoo/visualization/heatmap.py +3 -3
  51. pymoo/visualization/pcp.py +1 -1
  52. pymoo/visualization/radar.py +1 -1
  53. {pymoo-0.6.1.3.dist-info → pymoo-0.6.1.5.dist-info}/METADATA +12 -13
  54. {pymoo-0.6.1.3.dist-info → pymoo-0.6.1.5.dist-info}/RECORD +328 -316
  55. {pymoo-0.6.1.3.dist-info → pymoo-0.6.1.5.dist-info}/WHEEL +2 -1
  56. {pymoo-0.6.1.3.dist-info → pymoo-0.6.1.5.dist-info/licenses}/LICENSE +0 -0
  57. {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
@@ -0,0 +1,49 @@
1
+ # distutils: language = c++
2
+ # cython: language_level=2, boundscheck=False, wraparound=False, cdivision=True
3
+
4
+
5
+ import numpy as np
6
+
7
+
8
+ def stochastic_ranking(double[:] f, double[:] phi, double pr, long[:] I=None):
9
+ if I is None:
10
+ I = np.arange(len(f))
11
+ return np.array(c_stochastic_ranking(f, phi, pr, I))
12
+
13
+
14
+
15
+ def c_stochastic_ranking(double[:] f, double[:] phi, double pr, long[:] I):
16
+ cdef int _lambda, i, j, at_least_one_swap
17
+ cdef double u
18
+
19
+ _lambda = len(f)
20
+
21
+ for i in range(_lambda):
22
+
23
+ at_least_one_swap = 0
24
+
25
+ for j in range(_lambda - 1):
26
+
27
+ u = np.random.random()
28
+
29
+ if u < pr or (phi[I[j]] == 0 and phi[I[j + 1]] == 0):
30
+ if f[I[j]] > f[I[j + 1]]:
31
+ c_swap(I, j, j + 1)
32
+ at_least_one_swap = 1
33
+ else:
34
+ if phi[I[j]] > phi[I[j + 1]]:
35
+ c_swap(I, j, j + 1)
36
+ at_least_one_swap = 1
37
+
38
+ if at_least_one_swap == 0:
39
+ break
40
+
41
+ return I
42
+
43
+
44
+ cdef c_swap(long[:] x, int a, int b):
45
+ cdef int tmp
46
+ tmp = x[a]
47
+ x[a] = x[b]
48
+ x[b] = tmp
49
+