pymoo 0.6.1.5.dev0__cp312-cp312-macosx_10_13_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 (328) hide show
  1. pymoo/__init__.py +3 -0
  2. pymoo/algorithms/__init__.py +0 -0
  3. pymoo/algorithms/base/__init__.py +0 -0
  4. pymoo/algorithms/base/bracket.py +38 -0
  5. pymoo/algorithms/base/genetic.py +109 -0
  6. pymoo/algorithms/base/line.py +62 -0
  7. pymoo/algorithms/base/local.py +39 -0
  8. pymoo/algorithms/base/meta.py +79 -0
  9. pymoo/algorithms/hyperparameters.py +89 -0
  10. pymoo/algorithms/moo/__init__.py +0 -0
  11. pymoo/algorithms/moo/age.py +310 -0
  12. pymoo/algorithms/moo/age2.py +194 -0
  13. pymoo/algorithms/moo/ctaea.py +298 -0
  14. pymoo/algorithms/moo/dnsga2.py +76 -0
  15. pymoo/algorithms/moo/kgb.py +446 -0
  16. pymoo/algorithms/moo/moead.py +183 -0
  17. pymoo/algorithms/moo/nsga2.py +113 -0
  18. pymoo/algorithms/moo/nsga3.py +358 -0
  19. pymoo/algorithms/moo/pinsga2.py +370 -0
  20. pymoo/algorithms/moo/rnsga2.py +188 -0
  21. pymoo/algorithms/moo/rnsga3.py +246 -0
  22. pymoo/algorithms/moo/rvea.py +214 -0
  23. pymoo/algorithms/moo/sms.py +195 -0
  24. pymoo/algorithms/moo/spea2.py +190 -0
  25. pymoo/algorithms/moo/unsga3.py +47 -0
  26. pymoo/algorithms/soo/__init__.py +0 -0
  27. pymoo/algorithms/soo/convex/__init__.py +0 -0
  28. pymoo/algorithms/soo/nonconvex/__init__.py +0 -0
  29. pymoo/algorithms/soo/nonconvex/brkga.py +161 -0
  30. pymoo/algorithms/soo/nonconvex/cmaes.py +554 -0
  31. pymoo/algorithms/soo/nonconvex/de.py +279 -0
  32. pymoo/algorithms/soo/nonconvex/direct.py +149 -0
  33. pymoo/algorithms/soo/nonconvex/es.py +203 -0
  34. pymoo/algorithms/soo/nonconvex/g3pcx.py +94 -0
  35. pymoo/algorithms/soo/nonconvex/ga.py +93 -0
  36. pymoo/algorithms/soo/nonconvex/ga_niching.py +223 -0
  37. pymoo/algorithms/soo/nonconvex/isres.py +74 -0
  38. pymoo/algorithms/soo/nonconvex/nelder.py +251 -0
  39. pymoo/algorithms/soo/nonconvex/optuna.py +80 -0
  40. pymoo/algorithms/soo/nonconvex/pattern.py +183 -0
  41. pymoo/algorithms/soo/nonconvex/pso.py +399 -0
  42. pymoo/algorithms/soo/nonconvex/pso_ep.py +297 -0
  43. pymoo/algorithms/soo/nonconvex/random_search.py +25 -0
  44. pymoo/algorithms/soo/nonconvex/sres.py +56 -0
  45. pymoo/algorithms/soo/univariate/__init__.py +0 -0
  46. pymoo/algorithms/soo/univariate/backtracking.py +59 -0
  47. pymoo/algorithms/soo/univariate/exp.py +46 -0
  48. pymoo/algorithms/soo/univariate/golden.py +65 -0
  49. pymoo/algorithms/soo/univariate/quadr_interp.py +81 -0
  50. pymoo/algorithms/soo/univariate/wolfe.py +163 -0
  51. pymoo/config.py +33 -0
  52. pymoo/constraints/__init__.py +3 -0
  53. pymoo/constraints/adaptive.py +62 -0
  54. pymoo/constraints/as_obj.py +56 -0
  55. pymoo/constraints/as_penalty.py +41 -0
  56. pymoo/constraints/eps.py +26 -0
  57. pymoo/constraints/from_bounds.py +36 -0
  58. pymoo/core/__init__.py +0 -0
  59. pymoo/core/algorithm.py +394 -0
  60. pymoo/core/callback.py +38 -0
  61. pymoo/core/crossover.py +77 -0
  62. pymoo/core/decision_making.py +102 -0
  63. pymoo/core/decomposition.py +76 -0
  64. pymoo/core/duplicate.py +163 -0
  65. pymoo/core/evaluator.py +116 -0
  66. pymoo/core/indicator.py +34 -0
  67. pymoo/core/individual.py +784 -0
  68. pymoo/core/infill.py +64 -0
  69. pymoo/core/initialization.py +42 -0
  70. pymoo/core/mating.py +39 -0
  71. pymoo/core/meta.py +21 -0
  72. pymoo/core/mixed.py +165 -0
  73. pymoo/core/mutation.py +44 -0
  74. pymoo/core/operator.py +40 -0
  75. pymoo/core/parameters.py +134 -0
  76. pymoo/core/plot.py +210 -0
  77. pymoo/core/population.py +180 -0
  78. pymoo/core/problem.py +460 -0
  79. pymoo/core/recorder.py +99 -0
  80. pymoo/core/repair.py +23 -0
  81. pymoo/core/replacement.py +96 -0
  82. pymoo/core/result.py +52 -0
  83. pymoo/core/sampling.py +43 -0
  84. pymoo/core/selection.py +61 -0
  85. pymoo/core/solution.py +10 -0
  86. pymoo/core/survival.py +103 -0
  87. pymoo/core/termination.py +70 -0
  88. pymoo/core/variable.py +399 -0
  89. pymoo/cython/__init__.py +0 -0
  90. pymoo/cython/calc_perpendicular_distance.cpython-312-darwin.so +0 -0
  91. pymoo/cython/calc_perpendicular_distance.pyx +67 -0
  92. pymoo/cython/decomposition.cpython-312-darwin.so +0 -0
  93. pymoo/cython/decomposition.pyx +165 -0
  94. pymoo/cython/hv.cpython-312-darwin.so +0 -0
  95. pymoo/cython/hv.pyx +18 -0
  96. pymoo/cython/info.cpython-312-darwin.so +0 -0
  97. pymoo/cython/info.pyx +5 -0
  98. pymoo/cython/mnn.cpython-312-darwin.so +0 -0
  99. pymoo/cython/mnn.pyx +273 -0
  100. pymoo/cython/non_dominated_sorting.cpython-312-darwin.so +0 -0
  101. pymoo/cython/non_dominated_sorting.pyx +645 -0
  102. pymoo/cython/pruning_cd.cpython-312-darwin.so +0 -0
  103. pymoo/cython/pruning_cd.pyx +197 -0
  104. pymoo/cython/stochastic_ranking.cpython-312-darwin.so +0 -0
  105. pymoo/cython/stochastic_ranking.pyx +49 -0
  106. pymoo/cython/utils.pxd +129 -0
  107. pymoo/cython/vendor/__init__.py +0 -0
  108. pymoo/cython/vendor/hypervolume.cpp +1621 -0
  109. pymoo/cython/vendor/hypervolume.h +63 -0
  110. pymoo/decomposition/__init__.py +0 -0
  111. pymoo/decomposition/aasf.py +24 -0
  112. pymoo/decomposition/asf.py +10 -0
  113. pymoo/decomposition/pbi.py +13 -0
  114. pymoo/decomposition/perp_dist.py +13 -0
  115. pymoo/decomposition/tchebicheff.py +11 -0
  116. pymoo/decomposition/util.py +13 -0
  117. pymoo/decomposition/weighted_sum.py +8 -0
  118. pymoo/docs.py +187 -0
  119. pymoo/experimental/__init__.py +0 -0
  120. pymoo/experimental/algorithms/__init__.py +0 -0
  121. pymoo/experimental/algorithms/gde3.py +57 -0
  122. pymoo/gradient/__init__.py +21 -0
  123. pymoo/gradient/automatic.py +57 -0
  124. pymoo/gradient/grad_autograd.py +105 -0
  125. pymoo/gradient/grad_complex.py +35 -0
  126. pymoo/gradient/grad_jax.py +51 -0
  127. pymoo/gradient/toolbox/__init__.py +6 -0
  128. pymoo/indicators/__init__.py +0 -0
  129. pymoo/indicators/distance_indicator.py +55 -0
  130. pymoo/indicators/gd.py +7 -0
  131. pymoo/indicators/gd_plus.py +7 -0
  132. pymoo/indicators/hv/__init__.py +63 -0
  133. pymoo/indicators/hv/exact.py +71 -0
  134. pymoo/indicators/hv/exact_2d.py +102 -0
  135. pymoo/indicators/hv/monte_carlo.py +74 -0
  136. pymoo/indicators/igd.py +7 -0
  137. pymoo/indicators/igd_plus.py +7 -0
  138. pymoo/indicators/kktpm.py +151 -0
  139. pymoo/indicators/migd.py +55 -0
  140. pymoo/indicators/rmetric.py +203 -0
  141. pymoo/indicators/spacing.py +52 -0
  142. pymoo/mcdm/__init__.py +0 -0
  143. pymoo/mcdm/compromise_programming.py +19 -0
  144. pymoo/mcdm/high_tradeoff.py +40 -0
  145. pymoo/mcdm/pseudo_weights.py +32 -0
  146. pymoo/operators/__init__.py +0 -0
  147. pymoo/operators/control.py +187 -0
  148. pymoo/operators/crossover/__init__.py +0 -0
  149. pymoo/operators/crossover/binx.py +45 -0
  150. pymoo/operators/crossover/dex.py +122 -0
  151. pymoo/operators/crossover/erx.py +162 -0
  152. pymoo/operators/crossover/expx.py +51 -0
  153. pymoo/operators/crossover/hux.py +37 -0
  154. pymoo/operators/crossover/nox.py +13 -0
  155. pymoo/operators/crossover/ox.py +84 -0
  156. pymoo/operators/crossover/pcx.py +82 -0
  157. pymoo/operators/crossover/pntx.py +49 -0
  158. pymoo/operators/crossover/sbx.py +125 -0
  159. pymoo/operators/crossover/spx.py +5 -0
  160. pymoo/operators/crossover/ux.py +20 -0
  161. pymoo/operators/mutation/__init__.py +0 -0
  162. pymoo/operators/mutation/bitflip.py +17 -0
  163. pymoo/operators/mutation/gauss.py +58 -0
  164. pymoo/operators/mutation/inversion.py +42 -0
  165. pymoo/operators/mutation/nom.py +7 -0
  166. pymoo/operators/mutation/pm.py +94 -0
  167. pymoo/operators/mutation/rm.py +23 -0
  168. pymoo/operators/repair/__init__.py +0 -0
  169. pymoo/operators/repair/bounce_back.py +32 -0
  170. pymoo/operators/repair/bounds_repair.py +95 -0
  171. pymoo/operators/repair/inverse_penalty.py +89 -0
  172. pymoo/operators/repair/rounding.py +18 -0
  173. pymoo/operators/repair/to_bound.py +31 -0
  174. pymoo/operators/repair/vtype.py +11 -0
  175. pymoo/operators/sampling/__init__.py +0 -0
  176. pymoo/operators/sampling/lhs.py +73 -0
  177. pymoo/operators/sampling/rnd.py +50 -0
  178. pymoo/operators/selection/__init__.py +0 -0
  179. pymoo/operators/selection/rnd.py +72 -0
  180. pymoo/operators/selection/tournament.py +76 -0
  181. pymoo/operators/survival/__init__.py +0 -0
  182. pymoo/operators/survival/rank_and_crowding/__init__.py +1 -0
  183. pymoo/operators/survival/rank_and_crowding/classes.py +209 -0
  184. pymoo/operators/survival/rank_and_crowding/metrics.py +208 -0
  185. pymoo/optimize.py +72 -0
  186. pymoo/problems/__init__.py +157 -0
  187. pymoo/problems/dyn.py +47 -0
  188. pymoo/problems/dynamic/__init__.py +0 -0
  189. pymoo/problems/dynamic/cec2015.py +108 -0
  190. pymoo/problems/dynamic/df.py +452 -0
  191. pymoo/problems/dynamic/misc.py +167 -0
  192. pymoo/problems/functional.py +48 -0
  193. pymoo/problems/many/__init__.py +5 -0
  194. pymoo/problems/many/cdtlz.py +159 -0
  195. pymoo/problems/many/dcdtlz.py +88 -0
  196. pymoo/problems/many/dtlz.py +264 -0
  197. pymoo/problems/many/wfg.py +550 -0
  198. pymoo/problems/multi/__init__.py +14 -0
  199. pymoo/problems/multi/bnh.py +34 -0
  200. pymoo/problems/multi/carside.py +48 -0
  201. pymoo/problems/multi/clutch.py +104 -0
  202. pymoo/problems/multi/csi.py +55 -0
  203. pymoo/problems/multi/ctp.py +198 -0
  204. pymoo/problems/multi/dascmop.py +213 -0
  205. pymoo/problems/multi/kursawe.py +25 -0
  206. pymoo/problems/multi/modact.py +68 -0
  207. pymoo/problems/multi/mw.py +400 -0
  208. pymoo/problems/multi/omnitest.py +48 -0
  209. pymoo/problems/multi/osy.py +32 -0
  210. pymoo/problems/multi/srn.py +28 -0
  211. pymoo/problems/multi/sympart.py +94 -0
  212. pymoo/problems/multi/tnk.py +24 -0
  213. pymoo/problems/multi/truss2d.py +83 -0
  214. pymoo/problems/multi/welded_beam.py +41 -0
  215. pymoo/problems/multi/wrm.py +36 -0
  216. pymoo/problems/multi/zdt.py +151 -0
  217. pymoo/problems/multi_to_single.py +22 -0
  218. pymoo/problems/single/__init__.py +12 -0
  219. pymoo/problems/single/ackley.py +24 -0
  220. pymoo/problems/single/cantilevered_beam.py +34 -0
  221. pymoo/problems/single/flowshop_scheduling.py +112 -0
  222. pymoo/problems/single/g.py +874 -0
  223. pymoo/problems/single/griewank.py +18 -0
  224. pymoo/problems/single/himmelblau.py +15 -0
  225. pymoo/problems/single/knapsack.py +48 -0
  226. pymoo/problems/single/mopta08.py +26 -0
  227. pymoo/problems/single/multimodal.py +20 -0
  228. pymoo/problems/single/pressure_vessel.py +30 -0
  229. pymoo/problems/single/rastrigin.py +20 -0
  230. pymoo/problems/single/rosenbrock.py +22 -0
  231. pymoo/problems/single/schwefel.py +18 -0
  232. pymoo/problems/single/simple.py +13 -0
  233. pymoo/problems/single/sphere.py +19 -0
  234. pymoo/problems/single/traveling_salesman.py +79 -0
  235. pymoo/problems/single/zakharov.py +19 -0
  236. pymoo/problems/static.py +14 -0
  237. pymoo/problems/util.py +42 -0
  238. pymoo/problems/zero_to_one.py +27 -0
  239. pymoo/termination/__init__.py +23 -0
  240. pymoo/termination/collection.py +12 -0
  241. pymoo/termination/cv.py +48 -0
  242. pymoo/termination/default.py +45 -0
  243. pymoo/termination/delta.py +64 -0
  244. pymoo/termination/fmin.py +16 -0
  245. pymoo/termination/ftol.py +144 -0
  246. pymoo/termination/indicator.py +49 -0
  247. pymoo/termination/max_eval.py +14 -0
  248. pymoo/termination/max_gen.py +15 -0
  249. pymoo/termination/max_time.py +20 -0
  250. pymoo/termination/robust.py +34 -0
  251. pymoo/termination/xtol.py +33 -0
  252. pymoo/util/__init__.py +0 -0
  253. pymoo/util/archive.py +150 -0
  254. pymoo/util/cache.py +29 -0
  255. pymoo/util/clearing.py +82 -0
  256. pymoo/util/display/__init__.py +0 -0
  257. pymoo/util/display/column.py +52 -0
  258. pymoo/util/display/display.py +34 -0
  259. pymoo/util/display/multi.py +96 -0
  260. pymoo/util/display/output.py +53 -0
  261. pymoo/util/display/progress.py +54 -0
  262. pymoo/util/display/single.py +67 -0
  263. pymoo/util/dominator.py +67 -0
  264. pymoo/util/function_loader.py +129 -0
  265. pymoo/util/hv.py +23 -0
  266. pymoo/util/matlab_engine.py +39 -0
  267. pymoo/util/misc.py +460 -0
  268. pymoo/util/mnn.py +70 -0
  269. pymoo/util/nds/__init__.py +0 -0
  270. pymoo/util/nds/dominance_degree_non_dominated_sort.py +159 -0
  271. pymoo/util/nds/efficient_non_dominated_sort.py +152 -0
  272. pymoo/util/nds/fast_non_dominated_sort.py +70 -0
  273. pymoo/util/nds/naive_non_dominated_sort.py +36 -0
  274. pymoo/util/nds/non_dominated_sorting.py +67 -0
  275. pymoo/util/nds/tree_based_non_dominated_sort.py +133 -0
  276. pymoo/util/normalization.py +312 -0
  277. pymoo/util/optimum.py +42 -0
  278. pymoo/util/plotting.py +177 -0
  279. pymoo/util/pruning_cd.py +89 -0
  280. pymoo/util/randomized_argsort.py +60 -0
  281. pymoo/util/ref_dirs/__init__.py +24 -0
  282. pymoo/util/ref_dirs/construction.py +88 -0
  283. pymoo/util/ref_dirs/das_dennis.py +52 -0
  284. pymoo/util/ref_dirs/energy.py +319 -0
  285. pymoo/util/ref_dirs/energy_layer.py +119 -0
  286. pymoo/util/ref_dirs/genetic_algorithm.py +63 -0
  287. pymoo/util/ref_dirs/incremental.py +68 -0
  288. pymoo/util/ref_dirs/misc.py +128 -0
  289. pymoo/util/ref_dirs/optimizer.py +59 -0
  290. pymoo/util/ref_dirs/performance.py +162 -0
  291. pymoo/util/ref_dirs/reduction.py +85 -0
  292. pymoo/util/ref_dirs/sample_and_map.py +24 -0
  293. pymoo/util/reference_direction.py +260 -0
  294. pymoo/util/remote.py +55 -0
  295. pymoo/util/roulette.py +27 -0
  296. pymoo/util/running_metric.py +128 -0
  297. pymoo/util/sliding_window.py +25 -0
  298. pymoo/util/stochastic_ranking.py +32 -0
  299. pymoo/util/value_functions.py +719 -0
  300. pymoo/util/vectors.py +40 -0
  301. pymoo/util/vf_dominator.py +99 -0
  302. pymoo/vendor/__init__.py +0 -0
  303. pymoo/vendor/cec2018.py +398 -0
  304. pymoo/vendor/gta.py +617 -0
  305. pymoo/vendor/hv.py +267 -0
  306. pymoo/vendor/vendor_cmaes.py +412 -0
  307. pymoo/vendor/vendor_coco.py +81 -0
  308. pymoo/vendor/vendor_scipy.py +232 -0
  309. pymoo/version.py +1 -0
  310. pymoo/visualization/__init__.py +8 -0
  311. pymoo/visualization/fitness_landscape.py +127 -0
  312. pymoo/visualization/heatmap.py +123 -0
  313. pymoo/visualization/pcp.py +120 -0
  314. pymoo/visualization/petal.py +91 -0
  315. pymoo/visualization/radar.py +108 -0
  316. pymoo/visualization/radviz.py +68 -0
  317. pymoo/visualization/scatter.py +150 -0
  318. pymoo/visualization/star_coordinate.py +75 -0
  319. pymoo/visualization/util.py +123 -0
  320. pymoo/visualization/video/__init__.py +0 -0
  321. pymoo/visualization/video/callback_video.py +82 -0
  322. pymoo/visualization/video/one_var_one_obj.py +57 -0
  323. pymoo/visualization/video/two_var_one_obj.py +62 -0
  324. pymoo-0.6.1.5.dev0.dist-info/METADATA +187 -0
  325. pymoo-0.6.1.5.dev0.dist-info/RECORD +328 -0
  326. pymoo-0.6.1.5.dev0.dist-info/WHEEL +6 -0
  327. pymoo-0.6.1.5.dev0.dist-info/licenses/LICENSE +191 -0
  328. pymoo-0.6.1.5.dev0.dist-info/top_level.txt +1 -0
pymoo/util/vectors.py ADDED
@@ -0,0 +1,40 @@
1
+ import numpy as np
2
+
3
+
4
+ def max_alpha(point, direction, xl, xu, mode="one_hits_bound"):
5
+ bounds = []
6
+
7
+ if xl is not None:
8
+ bounds.append(xl)
9
+
10
+ if xu is not None:
11
+ bounds.append(xu)
12
+
13
+ if len(bounds) == 0:
14
+ return np.inf
15
+
16
+ # the bounds in one array
17
+ bounds = np.column_stack(bounds)
18
+
19
+ # if the direction is too small we can not divide by 0 - nan will make it being ignored
20
+ dir = direction.copy()
21
+ dir[dir == 0] = np.nan
22
+
23
+ # calculate the max factor to be not out of bounds
24
+ val = (bounds - point[:, None]) / dir[:, None]
25
+
26
+ # remove nan values by setting them to a negative number
27
+ val[np.isnan(val)] = - np.inf
28
+
29
+ # if no value there - no bound exist
30
+ if len(val) == 0:
31
+ return np.inf
32
+ # otherwise return the minimum of values considered
33
+ else:
34
+ if mode == "one_hits_bound":
35
+ if not np.any(val >= 0):
36
+ return 0.0
37
+ else:
38
+ return val[val >= 0].min()
39
+ else:
40
+ return val.max()
@@ -0,0 +1,99 @@
1
+ import numpy as np
2
+
3
+ def get_relation(ind_a, ind_b):
4
+ return Dominator.get_relation(ind_a.F, ind_b.F, ind_a.CV[0], ind_b.CV[0])
5
+
6
+
7
+ class VFDominator:
8
+
9
+ def __init__(self, algorithm):
10
+
11
+ self.algorithm = algorithm
12
+
13
+ @staticmethod
14
+ def get_relation(a, b, cva=None, cvb=None):
15
+
16
+ if cva is not None and cvb is not None:
17
+ if cva < cvb:
18
+ return 1
19
+ elif cvb < cva:
20
+ return -1
21
+
22
+ val = 0
23
+ for i in range(len(a)):
24
+ if a[i] < b[i]:
25
+ # indifferent because once better and once worse
26
+ if val == -1:
27
+ return 0
28
+ val = 1
29
+ elif b[i] < a[i]:
30
+ # indifferent because once better and once worse
31
+ if val == 1:
32
+ return 0
33
+ val = -1
34
+ return val
35
+
36
+ @staticmethod
37
+ def calc_domination_matrix_loop(F, G):
38
+
39
+ n = F.shape[0]
40
+ CV = np.sum(G * (G > 0).astype(float), axis=1)
41
+ M = np.zeros((n, n))
42
+ for i in range(n):
43
+ for j in range(i + 1, n):
44
+ M[i, j] = Dominator.get_relation(F[i, :], F[j, :], CV[i], CV[j])
45
+ M[j, i] = -M[i, j]
46
+
47
+ return M
48
+
49
+ def calc_domination_matrix(self, F, _F=None, epsilon=0.0):
50
+
51
+ if _F is None:
52
+ _F = F
53
+
54
+ # look at the obj for dom
55
+ n = F.shape[0]
56
+ m = _F.shape[0]
57
+
58
+ L = np.repeat(F, m, axis=0)
59
+ R = np.tile(_F, (n, 1))
60
+
61
+ smaller = np.reshape(np.any(L + epsilon < R, axis=1), (n, m))
62
+ larger = np.reshape(np.any(L > R + epsilon, axis=1), (n, m))
63
+
64
+ non_dom = np.logical_and(smaller, np.logical_not(larger))
65
+ dom = np.logical_and(larger, np.logical_not(smaller))
66
+
67
+ if self.algorithm.vf_res is not None:
68
+
69
+ # Figure out what the v2 value is
70
+ v2 = self.algorithm.v2
71
+
72
+ # Get the value function
73
+ vf = self.algorithm.vf_res.vf
74
+
75
+ # How much does the DM value each solution?
76
+ F_vf = vf(F * -1)[:,np.newaxis]
77
+ _F_vf = vf(_F * -1)[:,np.newaxis]
78
+
79
+ # We want to compare each solution to the others
80
+ Lv = np.repeat(F_vf, m, axis=0)
81
+ Rv = np.tile(_F_vf, (n, 1))
82
+
83
+ # Which values are greater than (better) V2?
84
+ gtv2 = np.reshape(Lv < v2, (n, m))
85
+ # Which values are less than (worst) V2?
86
+ ltv2 = np.reshape(Rv > v2, (n, m))
87
+
88
+ # If you are greater than V2, you dominate all those who are smaller than V2
89
+ split_by_v2 = np.logical_and(gtv2, ltv2)
90
+
91
+ dom = np.logical_or(dom, split_by_v2)
92
+
93
+ M = non_dom * 1 \
94
+ + dom * -1
95
+
96
+ return M
97
+
98
+
99
+
File without changes
@@ -0,0 +1,398 @@
1
+ # The code is translated from Matlab by ahcheriet@gmail.com
2
+ # ========================================================|#
3
+ # The 14 test functions are for cec2018 competition on |
4
+ # dynamic multiobjective optimisation. This document is |
5
+ # free to disseminate for academic use. |
6
+ # --------------------------------------------------------|#
7
+ # The "time" term in the test suite is defined as: |
8
+ # t=1/nt*floor(tau/taut) |
9
+ # where - nt: severity of change |
10
+ # - taut: frequency of change |
11
+ # - tau: current generation counter |
12
+ # --------------------------------------------------------|#
13
+ # Any questions can be directed to |
14
+ # Dr. Shouyong Jiang at math4neu@gmail.com. |
15
+ # |
16
+ # ========================================================|#
17
+
18
+ # cec2018_DF(probID, x, tau, taut, nt)
19
+ # INPUT:
20
+ # probID: test problem identifier (i.e. 'DF1')
21
+ # x: variable vector
22
+ # tau: current generation counter
23
+ # taut: frequency of change
24
+ # nt: severity of change
25
+ #
26
+ # OUTPUT:
27
+ # f: objective vector
28
+ #
29
+ from numpy import power, setdiff1d, exp, prod
30
+
31
+
32
+ def get_bounds(problem_id='DF1', n_vars=10):
33
+ lx = np.zeros(n_vars)
34
+ ux = np.ones(n_vars)
35
+ if problem_id == 'DF3':
36
+ lx = -1 * np.ones(n_vars)
37
+ ux = 2 * np.ones(n_vars)
38
+ lx[0] = 0.0
39
+ ux[0] = 1.0
40
+ if problem_id == 'DF4':
41
+ lx = -2 * np.ones(n_vars)
42
+ ux = -2 * np.ones(n_vars)
43
+ if problem_id == 'DF5':
44
+ lx = -1 * np.ones(n_vars)
45
+ ux = -1 * np.ones(n_vars)
46
+ lx[0] = 0.0
47
+ ux[0] = 1.0
48
+ if problem_id == 'DF6':
49
+ lx = -1 * np.ones(n_vars)
50
+ ux = -1 * np.ones(n_vars)
51
+ lx[0] = 0.0
52
+ ux[0] = 1.0
53
+ if problem_id == 'DF7':
54
+ lx = 0 * np.ones(n_vars)
55
+ ux = 1 * np.ones(n_vars)
56
+ lx[0] = 1.0
57
+ ux[0] = 4.0
58
+ if problem_id == 'DF8':
59
+ lx = -1 * np.ones(n_vars)
60
+ ux = -1 * np.ones(n_vars)
61
+ lx[0] = 0.0
62
+ ux[0] = 1.0
63
+ if problem_id == 'DF9':
64
+ lx = -1 * np.ones(n_vars)
65
+ ux = -1 * np.ones(n_vars)
66
+ lx[0] = 0.0
67
+ ux[0] = 1.0
68
+ if problem_id == 'DF10':
69
+ lx = -1 * np.ones(n_vars)
70
+ ux = -1 * np.ones(n_vars)
71
+ lx[0] = 0.0
72
+ lx[1] = 0.0
73
+ ux[0] = 1.0
74
+ ux[1] = 1.0
75
+ if problem_id == 'DF12':
76
+ lx = -1 * np.ones(n_vars)
77
+ ux = -1 * np.ones(n_vars)
78
+ lx[0] = 0.0
79
+ lx[1] = 0.0
80
+ ux[0] = 1.0
81
+ ux[1] = 1.0
82
+ if problem_id == 'DF13':
83
+ lx = -1 * np.ones(n_vars)
84
+ ux = -1 * np.ones(n_vars)
85
+ lx[0] = 0.0
86
+ lx[1] = 0.0
87
+ ux[0] = 1.0
88
+ ux[1] = 1.0
89
+ if problem_id == 'DF14':
90
+ lx = -1 * np.ones(n_vars)
91
+ ux = -1 * np.ones(n_vars)
92
+ lx[0] = 0.0
93
+ lx[1] = 0.0
94
+ ux[0] = 1.0
95
+ ux[1] = 1.0
96
+ return lx, ux
97
+
98
+
99
+ def cec2018_DF(problemID='DF1', x=None, t=None):
100
+ # INPUT:
101
+ # probID: test problem identifier (i.e. 'DF1')
102
+ # x: variable vector
103
+ # tau: current generation counter
104
+ # taut: frequency of change
105
+ # nt: severity of change
106
+
107
+ # OUTPUT:
108
+ # f: objective vector
109
+
110
+ # the first change occurs after T0 generations, that is, the
111
+ # generation at which a change occurs is (T0+1), (T0+taut+1), etc.
112
+
113
+ T0 = 50
114
+ # calculate time instant
115
+ n = len(x)
116
+ f = {}
117
+ if problemID == 'DF1':
118
+ G = abs(sin(0.5 * pi * t))
119
+ H = 0.75 * sin(0.5 * pi * t) + 1.25
120
+ g = 1 + sum((x[1:] - G) ** 2)
121
+ f[0] = x[0]
122
+ f[1] = g * power(1 - (x[0] / g), H)
123
+ if problemID == 'DF2':
124
+ G = abs(sin(0.5 * pi * t))
125
+ r = 1 + floor((n - 1) * G)
126
+ tmp = setdiff1d(range(0, n), [int(r)])
127
+ g = 1 + sum([(x[int(index)] - G) ** 2 for index in tmp])
128
+ f[0] = x[int(r - 1)]
129
+ f[1] = g * (power(1 - (x[int(r - 1)] / g), 0.5))
130
+ if problemID == 'DF3':
131
+ G = sin(0.5 * pi * t)
132
+ H = G + 1.5
133
+ g = 1 + sum(power(x[1:] - G - x[0], H) ** 2)
134
+ f[0] = x[0]
135
+ f[1] = g * power(1 - (x[0] / g), H)
136
+ if problemID == 'DF4':
137
+ a = sin(0.5 * pi * t)
138
+ b = 1 + abs(cos(0.5 * pi * t))
139
+ H = 1.5 + a
140
+ g = 1 + sum((x[1:] - a * x[0] ** 2 / x[1:]) ** 2)
141
+ f[0] = g * power(abs(x[0] - a), H)
142
+ f[1] = g * power(abs(x[0] - a - b), H)
143
+ if problemID == 'DF5':
144
+ G = sin(0.5 * pi * t)
145
+ w = floor(10 * G)
146
+ g = 1 + sum((x[1:] - G) ** 2)
147
+ f[0] = g * (x[0] + 0.02 * sin(w * pi * x[0]))
148
+ f[1] = g * (1 - x[0] + 0.02 * sin(w * pi * x[0]))
149
+ if problemID == 'DF6':
150
+ G = sin(0.5 * pi * t)
151
+ a = 0.2 + 2.8 * abs(G)
152
+ y = x[1:] - G
153
+ g = 1 + sum((abs(G) * y ** 2 - 10 * cos(2 * pi * y) + 10))
154
+ f[0] = g * power(x[0] + 0.1 * sin(3 * pi * x[0]), a)
155
+ f[1] = g * power(1 - x[0] + 0.1 * sin(3 * pi * x[0]), a)
156
+ if problemID == 'DF7':
157
+ a = 5 * cos(0.5 * pi * t)
158
+ tmp = 1 / (1 + exp(a * (x[0] - 2.5)))
159
+ g = 1 + sum(power(x[1:] - tmp, 2))
160
+ f[0] = g * (1 + t) / x[0]
161
+ f[1] = g * x[0] / (1 + t)
162
+ if problemID == 'DF8':
163
+ G = sin(0.5 * pi * t)
164
+ a = 2.25 + 2 * cos(2 * pi * t)
165
+ b = 100 * G ** 2
166
+ tmp = G * sin(power(4 * pi * x[0], b)) / (1 + abs(G))
167
+ g = 1 + sum((x[1:] - tmp) ** 2)
168
+ f[0] = g * (x[0] + 0.1 * sin(3 * pi * x[0]))
169
+ f[1] = g * power(1 - x[1] + 0.1 * sin(3 * pi * x[1]), a)
170
+ if problemID == 'DF9':
171
+ N = 1 + floor(10 * abs(sin(0.5 * pi * t)))
172
+ g = 1
173
+ for i in range(1, n):
174
+ tmp = x[i] - cos(4 * t + x[0] + x[i - 1])
175
+ g = g + tmp ** 2
176
+ f[0] = g * (x[0] + max(0, (0.1 + 0.5 / N) * sin(2 * N * pi * x[0])))
177
+ f[1] = g * (1 - x[0] + max(0, (0.1 + 0.5 / N) * sin(2 * N * pi * x[0])))
178
+ if problemID == 'DF10':
179
+ G = sin(0.5 * pi * t)
180
+ H = 2.25 + 2 * cos(0.5 * pi * t)
181
+ tmp = sin(2 * pi * (x[0] + x[1])) / (1 + abs(G))
182
+ g = 1 + sum((x[2:] - tmp) ** 2)
183
+ f[0] = g * power(sin(0.5 * pi * x[0]), H)
184
+ f[1] = g * power(sin(0.5 * pi * x[1]), H) * power(cos(0.5 * pi * x[0]), H)
185
+ f[2] = g * power(cos(0.5 * pi * x[1]), H) * power(cos(0.5 * pi * x[0]), H)
186
+ if problemID == 'DF11':
187
+ G = abs(sin(0.5 * pi * t))
188
+ g = 1 + G + sum((x[2:] - 0.5 * G * x[0]) ** 2)
189
+ y = [pi * G / 6.0 + (pi / 2 - pi * G / 3.0) * x[i] for i in [0, 1]]
190
+ f[0] = g * sin(y[0])
191
+ f[1] = g * sin(y[1]) * cos(y[0])
192
+ f[2] = g * cos(y[1]) * cos(y[0])
193
+ if problemID == 'DF12':
194
+ k = 10 * sin(pi * t)
195
+ tmp1 = x[2:] - sin(t * x[0])
196
+ tmp2 = [sin(floor(k * (2 * x[0] - 1)) * pi / 2)]
197
+ g = 1 + sum(tmp1 ** 2) + prod(tmp2)
198
+ f[0] = g * cos(0.5 * pi * x[1]) * cos(0.5 * pi * x[0])
199
+ f[1] = g * sin(0.5 * pi * x[1]) * cos(0.5 * pi * x[0])
200
+ f[2] = g * sin(0.5 * pi * x[1])
201
+ if problemID == 'DF13':
202
+ G = sin(0.5 * pi * t);
203
+ p = floor(6 * G);
204
+ g = 1 + sum((x[2:] - G) ** 2)
205
+ f[0] = g * cos(0.5 * pi * x[0]) ** 2
206
+ f[1] = g * cos(0.5 * pi * x[1]) ** 2
207
+ f[2] = g * sin(0.5 * pi * x[0]) ** 2 + sin(0.5 * pi * x[0]) * cos(p * pi * x[0]) ** 2 + sin(
208
+ 0.5 * pi * x[1]) ** 2 + sin(0.5 * pi * x[1]) * cos(p * pi * x[1]) ** 2
209
+ if problemID == 'DF14':
210
+ G = sin(0.5 * pi * t)
211
+ g = 1 + sum((x[2:] - G) ** 2)
212
+ y = 0.5 + G * (x[0] - 0.5)
213
+ f[0] = g * (1 - y + 0.05 * sin(6 * pi * y))
214
+ f[1] = g * (1 - x[1] + 0.05 * sin(6 * pi * x[1])) * (y + 0.05 * sin(6 * pi * y))
215
+ f[2] = g * (x[1] + 0.05 * sin(6 * pi * x[1])) * (y + 0.05 * sin(6 * pi * y))
216
+ return f
217
+
218
+
219
+ import numpy as np
220
+ from numpy import pi, dot, floor, sin, cos, multiply, arange
221
+ from copy import copy
222
+
223
+ false = False
224
+ true = True
225
+
226
+
227
+ # cec2018_pf.m
228
+
229
+ # ========================================================|#
230
+ # PF calculation for 14 cec2018 test functions on |
231
+ # dynamic multiobjective optimisation. This document is |
232
+ # free to disseminate for academic use. |
233
+ # --------------------------------------------------------|#
234
+ # The "time" term in the test suite is defined as: |
235
+ # t=1/nt*floor(tau/taut) |
236
+ # where - nt: severity of change |
237
+ # - taut: frequency of change |
238
+ # - tau: current generation counter |
239
+ # --------------------------------------------------------|#
240
+ # Any questions can be directed to |
241
+ # Dr. Shouyong Jiang at math4neu@gmail.com. |
242
+ # |
243
+ # ========================================================|#
244
+
245
+
246
+ def cec2018_DF_PF(probID=None, t=1, n_points=100, *args, **kwargs):
247
+ # INPUT:
248
+ # probID: test problem identifier (i.e. 'DF1')
249
+ # tau: current generation counter
250
+ # taut: frequency of change
251
+ # nt: severity of change
252
+
253
+ # OUTPUT:
254
+ # h: nondominated solutions
255
+
256
+ T0 = 50
257
+ g = 1
258
+ H = 50
259
+
260
+ if 'DF1' == (probID):
261
+ x = np.linspace(0, 1, n_points)
262
+ H = dot(0.75, sin(dot(dot(0.5, pi), t))) + 1.25
263
+ f1 = copy(x)
264
+ f2 = dot(g, (1 - (x / g) ** H))
265
+ h = get_PF(np.array([f1, f2]), false)
266
+ if 'DF2' == (probID):
267
+ x = np.linspace(0, 1, n_points)
268
+ G = abs(sin(dot(dot(0.5, pi), t)))
269
+ f1 = copy(x)
270
+ f2 = dot(g, (1 - (x / g) ** 0.5)) # To be sure
271
+ h = get_PF(np.array([f1, f2]), false)
272
+ if 'DF3' == (probID):
273
+ x = np.linspace(0, 1, n_points)
274
+ G = sin(dot(dot(0.5, pi), t))
275
+ H = G + 1.5
276
+ f1 = copy(x)
277
+ f2 = dot(g, (1 - (x / g) ** H))
278
+ h = get_PF(np.array([f1, f2]), false)
279
+ if 'DF4' == (probID):
280
+ a = sin(dot(dot(0.5, pi), t))
281
+ b = 1 + abs(cos(dot(dot(0.5, pi), t)))
282
+ x = np.linspace(a, a + b)
283
+ H = 1.5 + a
284
+ f1 = dot(g, abs(x - a) ** H)
285
+ f2 = dot(g, abs(x - a - b) ** H) # Maybe
286
+ h = get_PF(np.array([f1, f2]), false)
287
+ if 'DF5' == (probID):
288
+ x = np.linspace(0, 1, n_points)
289
+ G = sin(dot(dot(0.5, pi), t))
290
+ w = floor(dot(10, G))
291
+ f1 = dot(g, (x + dot(0.02, sin(dot(dot(w, pi), x)))))
292
+ f2 = dot(g, (1 - x + dot(0.02, sin(dot(dot(w, pi), x)))))
293
+ h = get_PF(np.array([f1, f2]), false)
294
+ if 'DF6' == (probID):
295
+ x = np.linspace(0, 1, n_points)
296
+ G = sin(dot(dot(0.5, pi), t))
297
+ a = 0.2 + dot(2.8, abs(G))
298
+ f1 = dot(g, (x + dot(0.1, sin(dot(dot(3, pi), x)))) ** a)
299
+ f2 = dot(g, (1 - x + dot(0.1, sin(dot(dot(3, pi), x)))) ** a)
300
+ h = get_PF(np.array([f1, f2]), false)
301
+ if 'DF7' == (probID):
302
+ x = np.linspace(1, 4, n_points)
303
+ f1 = dot(g, (1 + t)) / x
304
+ f2 = dot(g, x) / (1 + t)
305
+ h = get_PF(np.array([f1, f2]), false)
306
+ if 'DF8' == (probID):
307
+ x = np.linspace(0, 1, n_points)
308
+ a = 2.25 + dot(2, cos(dot(dot(2, pi), t)))
309
+ f1 = dot(g, (x + dot(0.1, sin(dot(dot(3, pi), x)))))
310
+ f2 = dot(g, (1 - x + dot(0.1, sin(dot(dot(3, pi), x)))) ** a)
311
+ h = get_PF(np.array([f1, f2]), false)
312
+ if 'DF9' == (probID):
313
+ x = np.linspace(0, 1, n_points)
314
+ # N = 1 + floor(dot(10, abs(sin(dot(dot(0.5, pi), t)))))
315
+
316
+ N = 1 + floor(10 * abs(sin(0.5 * pi * t)))
317
+ print(max(0, max((0.1 + 0.5 / N) * sin(2 * N * pi * x))))
318
+ f1 = g * (x + max(0, max((0.1 + 0.5 / N) * sin(2 * N * pi * x))))
319
+ f2 = g * (1 - x + max(0, max((0.1 + 0.5 / N) * sin(2 * N * pi * x))))
320
+
321
+ # f1 = dot(g, (x + max(0, dot((0.1 + 0.5 / N), sin(dot(dot(dot(2, N), pi), x))))))
322
+ # f2 = dot(g, (1 - x + max(0, dot((0.1 + 0.5 / N), sin(dot(dot(dot(2, N), pi), x))))))
323
+ h = get_PF(np.array([f1, f2]), true)
324
+ if 'DF10' == (probID):
325
+ x1, x2 = np.meshgrid(np.linspace(0, 1, H), np.linspace(0, 1, H), indexing='xy')
326
+ H = 2.25 + dot(2, cos(dot(dot(0.5, pi), t)))
327
+ f1 = dot(g, sin(dot(dot(0.5, pi), x1)) ** H)
328
+ f2 = multiply(dot(g, sin(dot(dot(0.5, pi), x2)) ** H),
329
+ cos(dot(dot(0.5, pi), x1)) ** H)
330
+ f3 = multiply(dot(g, cos(dot(dot(0.5, pi), x2)) ** H),
331
+ cos(dot(dot(0.5, pi), x1)) ** H)
332
+ h = get_PF(np.array([f1, f2, f3]), false)
333
+ if 'DF11' == (probID):
334
+ x1, x2 = np.meshgrid(np.linspace(0, 1, H), np.linspace(0, 1, H), indexing='xy')
335
+ G = abs(sin(dot(dot(0.5, pi), t)))
336
+ y1 = dot(pi, G) / 6 + dot((pi / 2 - dot(pi, G) / 3), x1)
337
+ y2 = dot(pi, G) / 6 + dot((pi / 2 - dot(pi, G) / 3), x2)
338
+ f1 = multiply(g, sin(y1))
339
+ f2 = dot(multiply(g, sin(y2)), cos(y1))
340
+ f3 = dot(multiply(g, cos(y2)), cos(y1))
341
+ h = get_PF(np.array([f1, f2, f3]), false)
342
+ if 'DF12' == (probID):
343
+ x1, x2 = np.meshgrid(np.linspace(0, 1, H), np.linspace(0, 1, H), indexing='xy')
344
+ k = dot(10, sin(dot(pi, t)))
345
+ tmp2 = abs(
346
+ multiply(sin(dot(floor(dot(k, (dot(2, x1) - 1))), pi) / 2),
347
+ sin(dot(floor(dot(k, (dot(2, x2) - 1))), pi) / 2)))
348
+ g = 1 + tmp2
349
+ f1 = multiply(multiply(g, cos(dot(dot(0.5, pi), x2))),
350
+ cos(dot(dot(0.5, pi), x1)))
351
+ f2 = multiply(multiply(g, sin(dot(dot(0.5, pi), x2))),
352
+ cos(dot(dot(0.5, pi), x1)))
353
+ f3 = multiply(g, sin(dot(dot(0.5, pi), x1)))
354
+ h = get_PF(np.array([f1, f2, f3]), true)
355
+ if 'DF13' == (probID):
356
+ x1, x2 = np.meshgrid(np.linspace(0, 1, H), np.linspace(0, 1, H), indexing='xy')
357
+ G = sin(dot(dot(0.5, pi), t))
358
+ p = floor(dot(6, G))
359
+ f1 = multiply(g, cos(dot(dot(0.5, pi), x1)) ** 2)
360
+ f2 = multiply(g, cos(dot(dot(0.5, pi), x2)) ** 2)
361
+ f3 = multiply(g, sin(dot(dot(0.5, pi), x1)) ** 2) + multiply(
362
+ sin(dot(dot(0.5, pi), x1)),
363
+ cos(dot(dot(p, pi), x1)) ** 2) + sin(
364
+ dot(dot(0.5, pi), x2)) ** 2 + multiply(
365
+ sin(dot(dot(0.5, pi), x2)), cos(dot(dot(p, pi), x2)) ** 2)
366
+ h = get_PF(np.array([f1, f2, f3]), true)
367
+ if 'DF14' == (probID):
368
+ x1, x2 = np.meshgrid(np.linspace(0, 1, H), np.linspace(0, 1, H), indexing='xy')
369
+ G = sin(dot(dot(0.5, pi), t))
370
+ y = 0.5 + dot(G, (x1 - 0.5))
371
+ f1 = multiply(g, (1 - y + dot(0.05, sin(dot(dot(6, pi), y)))))
372
+ f2 = multiply(multiply(g, (
373
+ 1 - x2 + dot(0.05, sin(dot(dot(6, pi), x2))))),
374
+ (y + dot(0.05, sin(dot(dot(6, pi), y)))))
375
+ f3 = multiply(
376
+ multiply(g, (x2 + dot(0.05, sin(dot(dot(6, pi), x2))))),
377
+ (y + dot(0.05, sin(dot(dot(6, pi), y)))))
378
+ h = get_PF(np.array([f1, f2, f3]), false)
379
+ return h
380
+
381
+
382
+ def get_PF(f=None, nondominate=None, *args, **kwargs):
383
+ ncell = len(f)
384
+ s = np.size(f[1])
385
+ h = []
386
+ for i in arange(ncell):
387
+ fi = np.reshape(f[i], s, order='F')
388
+ h.append(fi)
389
+ h = np.array(h).T
390
+ h = np.reshape(h, (s, ncell))
391
+
392
+ if nondominate:
393
+ print("Run Non dominating Sorting")
394
+ h = []
395
+ pass
396
+ # in_ = get_skyline(h)
397
+ # h = h(in_, arange())
398
+ return h