pymoo 0.6.1.6__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.
Files changed (337) 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 +110 -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 +91 -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/cmopso.py +239 -0
  14. pymoo/algorithms/moo/ctaea.py +305 -0
  15. pymoo/algorithms/moo/dnsga2.py +80 -0
  16. pymoo/algorithms/moo/kgb.py +450 -0
  17. pymoo/algorithms/moo/moead.py +183 -0
  18. pymoo/algorithms/moo/mopso_cd.py +309 -0
  19. pymoo/algorithms/moo/nsga2.py +113 -0
  20. pymoo/algorithms/moo/nsga3.py +361 -0
  21. pymoo/algorithms/moo/pinsga2.py +370 -0
  22. pymoo/algorithms/moo/rnsga2.py +188 -0
  23. pymoo/algorithms/moo/rnsga3.py +246 -0
  24. pymoo/algorithms/moo/rvea.py +214 -0
  25. pymoo/algorithms/moo/sms.py +196 -0
  26. pymoo/algorithms/moo/spea2.py +191 -0
  27. pymoo/algorithms/moo/unsga3.py +49 -0
  28. pymoo/algorithms/soo/__init__.py +0 -0
  29. pymoo/algorithms/soo/convex/__init__.py +0 -0
  30. pymoo/algorithms/soo/nonconvex/__init__.py +0 -0
  31. pymoo/algorithms/soo/nonconvex/brkga.py +162 -0
  32. pymoo/algorithms/soo/nonconvex/cmaes.py +556 -0
  33. pymoo/algorithms/soo/nonconvex/de.py +283 -0
  34. pymoo/algorithms/soo/nonconvex/direct.py +148 -0
  35. pymoo/algorithms/soo/nonconvex/es.py +213 -0
  36. pymoo/algorithms/soo/nonconvex/g3pcx.py +94 -0
  37. pymoo/algorithms/soo/nonconvex/ga.py +95 -0
  38. pymoo/algorithms/soo/nonconvex/ga_niching.py +223 -0
  39. pymoo/algorithms/soo/nonconvex/isres.py +74 -0
  40. pymoo/algorithms/soo/nonconvex/nelder.py +251 -0
  41. pymoo/algorithms/soo/nonconvex/nrbo.py +191 -0
  42. pymoo/algorithms/soo/nonconvex/optuna.py +80 -0
  43. pymoo/algorithms/soo/nonconvex/pattern.py +185 -0
  44. pymoo/algorithms/soo/nonconvex/pso.py +337 -0
  45. pymoo/algorithms/soo/nonconvex/pso_ep.py +307 -0
  46. pymoo/algorithms/soo/nonconvex/random_search.py +25 -0
  47. pymoo/algorithms/soo/nonconvex/sres.py +56 -0
  48. pymoo/algorithms/soo/univariate/__init__.py +0 -0
  49. pymoo/algorithms/soo/univariate/exp.py +46 -0
  50. pymoo/algorithms/soo/univariate/golden.py +65 -0
  51. pymoo/algorithms/soo/univariate/quadr_interp.py +81 -0
  52. pymoo/algorithms/soo/univariate/wolfe.py +163 -0
  53. pymoo/config.py +33 -0
  54. pymoo/constraints/__init__.py +3 -0
  55. pymoo/constraints/adaptive.py +66 -0
  56. pymoo/constraints/as_obj.py +56 -0
  57. pymoo/constraints/as_penalty.py +41 -0
  58. pymoo/constraints/eps.py +34 -0
  59. pymoo/constraints/from_bounds.py +36 -0
  60. pymoo/core/__init__.py +0 -0
  61. pymoo/core/algorithm.py +408 -0
  62. pymoo/core/callback.py +38 -0
  63. pymoo/core/crossover.py +79 -0
  64. pymoo/core/decision_making.py +102 -0
  65. pymoo/core/decomposition.py +76 -0
  66. pymoo/core/duplicate.py +163 -0
  67. pymoo/core/evaluator.py +116 -0
  68. pymoo/core/indicator.py +34 -0
  69. pymoo/core/individual.py +784 -0
  70. pymoo/core/infill.py +65 -0
  71. pymoo/core/initialization.py +44 -0
  72. pymoo/core/mating.py +39 -0
  73. pymoo/core/meta.py +21 -0
  74. pymoo/core/mixed.py +164 -0
  75. pymoo/core/mutation.py +44 -0
  76. pymoo/core/operator.py +46 -0
  77. pymoo/core/parameters.py +134 -0
  78. pymoo/core/plot.py +208 -0
  79. pymoo/core/population.py +180 -0
  80. pymoo/core/problem.py +373 -0
  81. pymoo/core/recorder.py +99 -0
  82. pymoo/core/repair.py +23 -0
  83. pymoo/core/replacement.py +96 -0
  84. pymoo/core/result.py +52 -0
  85. pymoo/core/sampling.py +45 -0
  86. pymoo/core/selection.py +61 -0
  87. pymoo/core/solution.py +10 -0
  88. pymoo/core/survival.py +107 -0
  89. pymoo/core/termination.py +70 -0
  90. pymoo/core/variable.py +415 -0
  91. pymoo/decomposition/__init__.py +0 -0
  92. pymoo/decomposition/aasf.py +24 -0
  93. pymoo/decomposition/asf.py +10 -0
  94. pymoo/decomposition/pbi.py +13 -0
  95. pymoo/decomposition/perp_dist.py +13 -0
  96. pymoo/decomposition/tchebicheff.py +11 -0
  97. pymoo/decomposition/util.py +13 -0
  98. pymoo/decomposition/weighted_sum.py +8 -0
  99. pymoo/docs.py +187 -0
  100. pymoo/experimental/__init__.py +0 -0
  101. pymoo/experimental/algorithms/__init__.py +0 -0
  102. pymoo/experimental/algorithms/gde3.py +57 -0
  103. pymoo/functions/__init__.py +135 -0
  104. pymoo/functions/compiled/__init__.py +0 -0
  105. pymoo/functions/compiled/calc_perpendicular_distance.cpp +27464 -0
  106. pymoo/functions/compiled/calc_perpendicular_distance.cpython-312-darwin.so +0 -0
  107. pymoo/functions/compiled/decomposition.cpp +28853 -0
  108. pymoo/functions/compiled/decomposition.cpython-312-darwin.so +0 -0
  109. pymoo/functions/compiled/info.cpp +7058 -0
  110. pymoo/functions/compiled/info.cpython-312-darwin.so +0 -0
  111. pymoo/functions/compiled/mnn.cpp +30095 -0
  112. pymoo/functions/compiled/mnn.cpython-312-darwin.so +0 -0
  113. pymoo/functions/compiled/non_dominated_sorting.cpp +35692 -0
  114. pymoo/functions/compiled/non_dominated_sorting.cpython-312-darwin.so +0 -0
  115. pymoo/functions/compiled/pruning_cd.cpp +29248 -0
  116. pymoo/functions/compiled/pruning_cd.cpython-312-darwin.so +0 -0
  117. pymoo/functions/compiled/stochastic_ranking.cpp +28042 -0
  118. pymoo/functions/compiled/stochastic_ranking.cpython-312-darwin.so +0 -0
  119. pymoo/functions/standard/__init__.py +1 -0
  120. pymoo/functions/standard/calc_perpendicular_distance.py +20 -0
  121. pymoo/functions/standard/decomposition.py +18 -0
  122. pymoo/functions/standard/hv.py +5 -0
  123. pymoo/functions/standard/mnn.py +78 -0
  124. pymoo/functions/standard/non_dominated_sorting.py +474 -0
  125. pymoo/functions/standard/pruning_cd.py +93 -0
  126. pymoo/functions/standard/stochastic_ranking.py +42 -0
  127. pymoo/gradient/__init__.py +24 -0
  128. pymoo/gradient/automatic.py +85 -0
  129. pymoo/gradient/grad_autograd.py +105 -0
  130. pymoo/gradient/grad_complex.py +35 -0
  131. pymoo/gradient/grad_jax.py +51 -0
  132. pymoo/gradient/numpy.py +22 -0
  133. pymoo/gradient/toolbox/__init__.py +19 -0
  134. pymoo/indicators/__init__.py +0 -0
  135. pymoo/indicators/distance_indicator.py +55 -0
  136. pymoo/indicators/gd.py +7 -0
  137. pymoo/indicators/gd_plus.py +7 -0
  138. pymoo/indicators/hv/__init__.py +59 -0
  139. pymoo/indicators/hv/approximate.py +105 -0
  140. pymoo/indicators/hv/exact.py +68 -0
  141. pymoo/indicators/hv/exact_2d.py +102 -0
  142. pymoo/indicators/igd.py +7 -0
  143. pymoo/indicators/igd_plus.py +7 -0
  144. pymoo/indicators/kktpm.py +151 -0
  145. pymoo/indicators/migd.py +55 -0
  146. pymoo/indicators/rmetric.py +203 -0
  147. pymoo/indicators/spacing.py +52 -0
  148. pymoo/mcdm/__init__.py +0 -0
  149. pymoo/mcdm/compromise_programming.py +19 -0
  150. pymoo/mcdm/high_tradeoff.py +40 -0
  151. pymoo/mcdm/pseudo_weights.py +32 -0
  152. pymoo/operators/__init__.py +0 -0
  153. pymoo/operators/control.py +190 -0
  154. pymoo/operators/crossover/__init__.py +0 -0
  155. pymoo/operators/crossover/binx.py +47 -0
  156. pymoo/operators/crossover/dex.py +125 -0
  157. pymoo/operators/crossover/erx.py +164 -0
  158. pymoo/operators/crossover/expx.py +53 -0
  159. pymoo/operators/crossover/hux.py +37 -0
  160. pymoo/operators/crossover/nox.py +25 -0
  161. pymoo/operators/crossover/ox.py +88 -0
  162. pymoo/operators/crossover/pcx.py +84 -0
  163. pymoo/operators/crossover/pntx.py +49 -0
  164. pymoo/operators/crossover/sbx.py +137 -0
  165. pymoo/operators/crossover/spx.py +5 -0
  166. pymoo/operators/crossover/ux.py +20 -0
  167. pymoo/operators/mutation/__init__.py +0 -0
  168. pymoo/operators/mutation/bitflip.py +17 -0
  169. pymoo/operators/mutation/gauss.py +60 -0
  170. pymoo/operators/mutation/inversion.py +42 -0
  171. pymoo/operators/mutation/nom.py +7 -0
  172. pymoo/operators/mutation/pm.py +96 -0
  173. pymoo/operators/mutation/rm.py +23 -0
  174. pymoo/operators/repair/__init__.py +0 -0
  175. pymoo/operators/repair/bounce_back.py +32 -0
  176. pymoo/operators/repair/bounds_repair.py +97 -0
  177. pymoo/operators/repair/inverse_penalty.py +91 -0
  178. pymoo/operators/repair/rounding.py +18 -0
  179. pymoo/operators/repair/to_bound.py +31 -0
  180. pymoo/operators/repair/vtype.py +11 -0
  181. pymoo/operators/sampling/__init__.py +0 -0
  182. pymoo/operators/sampling/lhs.py +76 -0
  183. pymoo/operators/sampling/rnd.py +52 -0
  184. pymoo/operators/selection/__init__.py +0 -0
  185. pymoo/operators/selection/rnd.py +75 -0
  186. pymoo/operators/selection/tournament.py +78 -0
  187. pymoo/operators/survival/__init__.py +0 -0
  188. pymoo/operators/survival/rank_and_crowding/__init__.py +1 -0
  189. pymoo/operators/survival/rank_and_crowding/classes.py +212 -0
  190. pymoo/operators/survival/rank_and_crowding/metrics.py +208 -0
  191. pymoo/optimize.py +72 -0
  192. pymoo/parallelization/__init__.py +15 -0
  193. pymoo/parallelization/dask.py +25 -0
  194. pymoo/parallelization/joblib.py +28 -0
  195. pymoo/parallelization/ray.py +31 -0
  196. pymoo/parallelization/starmap.py +24 -0
  197. pymoo/problems/__init__.py +157 -0
  198. pymoo/problems/dyn.py +47 -0
  199. pymoo/problems/dynamic/__init__.py +0 -0
  200. pymoo/problems/dynamic/cec2015.py +108 -0
  201. pymoo/problems/dynamic/df.py +451 -0
  202. pymoo/problems/dynamic/misc.py +167 -0
  203. pymoo/problems/functional.py +48 -0
  204. pymoo/problems/many/__init__.py +5 -0
  205. pymoo/problems/many/cdtlz.py +159 -0
  206. pymoo/problems/many/dcdtlz.py +88 -0
  207. pymoo/problems/many/dtlz.py +264 -0
  208. pymoo/problems/many/wfg.py +553 -0
  209. pymoo/problems/multi/__init__.py +14 -0
  210. pymoo/problems/multi/bnh.py +34 -0
  211. pymoo/problems/multi/carside.py +48 -0
  212. pymoo/problems/multi/clutch.py +104 -0
  213. pymoo/problems/multi/csi.py +55 -0
  214. pymoo/problems/multi/ctp.py +198 -0
  215. pymoo/problems/multi/dascmop.py +213 -0
  216. pymoo/problems/multi/kursawe.py +25 -0
  217. pymoo/problems/multi/modact.py +68 -0
  218. pymoo/problems/multi/mw.py +400 -0
  219. pymoo/problems/multi/omnitest.py +48 -0
  220. pymoo/problems/multi/osy.py +32 -0
  221. pymoo/problems/multi/srn.py +28 -0
  222. pymoo/problems/multi/sympart.py +94 -0
  223. pymoo/problems/multi/tnk.py +24 -0
  224. pymoo/problems/multi/truss2d.py +83 -0
  225. pymoo/problems/multi/welded_beam.py +41 -0
  226. pymoo/problems/multi/wrm.py +36 -0
  227. pymoo/problems/multi/zdt.py +151 -0
  228. pymoo/problems/multi_to_single.py +22 -0
  229. pymoo/problems/single/__init__.py +12 -0
  230. pymoo/problems/single/ackley.py +24 -0
  231. pymoo/problems/single/cantilevered_beam.py +34 -0
  232. pymoo/problems/single/flowshop_scheduling.py +113 -0
  233. pymoo/problems/single/g.py +874 -0
  234. pymoo/problems/single/griewank.py +18 -0
  235. pymoo/problems/single/himmelblau.py +15 -0
  236. pymoo/problems/single/knapsack.py +49 -0
  237. pymoo/problems/single/mopta08.py +26 -0
  238. pymoo/problems/single/multimodal.py +20 -0
  239. pymoo/problems/single/pressure_vessel.py +30 -0
  240. pymoo/problems/single/rastrigin.py +20 -0
  241. pymoo/problems/single/rosenbrock.py +22 -0
  242. pymoo/problems/single/schwefel.py +18 -0
  243. pymoo/problems/single/simple.py +13 -0
  244. pymoo/problems/single/sphere.py +19 -0
  245. pymoo/problems/single/traveling_salesman.py +79 -0
  246. pymoo/problems/single/zakharov.py +19 -0
  247. pymoo/problems/static.py +14 -0
  248. pymoo/problems/util.py +42 -0
  249. pymoo/problems/zero_to_one.py +27 -0
  250. pymoo/termination/__init__.py +23 -0
  251. pymoo/termination/collection.py +12 -0
  252. pymoo/termination/cv.py +48 -0
  253. pymoo/termination/default.py +45 -0
  254. pymoo/termination/delta.py +64 -0
  255. pymoo/termination/fmin.py +16 -0
  256. pymoo/termination/ftol.py +144 -0
  257. pymoo/termination/indicator.py +49 -0
  258. pymoo/termination/max_eval.py +14 -0
  259. pymoo/termination/max_gen.py +15 -0
  260. pymoo/termination/max_time.py +20 -0
  261. pymoo/termination/robust.py +34 -0
  262. pymoo/termination/xtol.py +33 -0
  263. pymoo/util/__init__.py +33 -0
  264. pymoo/util/archive.py +152 -0
  265. pymoo/util/cache.py +29 -0
  266. pymoo/util/clearing.py +82 -0
  267. pymoo/util/display/__init__.py +0 -0
  268. pymoo/util/display/column.py +52 -0
  269. pymoo/util/display/display.py +34 -0
  270. pymoo/util/display/multi.py +100 -0
  271. pymoo/util/display/output.py +53 -0
  272. pymoo/util/display/progress.py +54 -0
  273. pymoo/util/display/single.py +67 -0
  274. pymoo/util/dominator.py +67 -0
  275. pymoo/util/hv.py +21 -0
  276. pymoo/util/matlab_engine.py +39 -0
  277. pymoo/util/misc.py +447 -0
  278. pymoo/util/nds/__init__.py +0 -0
  279. pymoo/util/nds/dominance_degree_non_dominated_sort.py +159 -0
  280. pymoo/util/nds/efficient_non_dominated_sort.py +152 -0
  281. pymoo/util/nds/fast_non_dominated_sort.py +70 -0
  282. pymoo/util/nds/find_non_dominated.py +54 -0
  283. pymoo/util/nds/naive_non_dominated_sort.py +36 -0
  284. pymoo/util/nds/non_dominated_sorting.py +94 -0
  285. pymoo/util/nds/tree_based_non_dominated_sort.py +133 -0
  286. pymoo/util/normalization.py +312 -0
  287. pymoo/util/optimum.py +42 -0
  288. pymoo/util/randomized_argsort.py +63 -0
  289. pymoo/util/ref_dirs/__init__.py +24 -0
  290. pymoo/util/ref_dirs/construction.py +89 -0
  291. pymoo/util/ref_dirs/das_dennis.py +52 -0
  292. pymoo/util/ref_dirs/energy.py +317 -0
  293. pymoo/util/ref_dirs/energy_layer.py +119 -0
  294. pymoo/util/ref_dirs/genetic_algorithm.py +64 -0
  295. pymoo/util/ref_dirs/incremental.py +69 -0
  296. pymoo/util/ref_dirs/misc.py +128 -0
  297. pymoo/util/ref_dirs/optimizer.py +59 -0
  298. pymoo/util/ref_dirs/performance.py +162 -0
  299. pymoo/util/ref_dirs/reduction.py +85 -0
  300. pymoo/util/ref_dirs/sample_and_map.py +24 -0
  301. pymoo/util/reference_direction.py +258 -0
  302. pymoo/util/remote.py +55 -0
  303. pymoo/util/roulette.py +29 -0
  304. pymoo/util/running_metric.py +128 -0
  305. pymoo/util/sliding_window.py +25 -0
  306. pymoo/util/value_functions.py +720 -0
  307. pymoo/util/vectors.py +40 -0
  308. pymoo/util/vf_dominator.py +102 -0
  309. pymoo/vendor/__init__.py +0 -0
  310. pymoo/vendor/cec2018.py +398 -0
  311. pymoo/vendor/gta.py +617 -0
  312. pymoo/vendor/vendor_cmaes.py +421 -0
  313. pymoo/vendor/vendor_coco.py +81 -0
  314. pymoo/vendor/vendor_scipy.py +232 -0
  315. pymoo/version.py +1 -0
  316. pymoo/visualization/__init__.py +21 -0
  317. pymoo/visualization/app/__init__.py +0 -0
  318. pymoo/visualization/app/pso.py +61 -0
  319. pymoo/visualization/fitness_landscape.py +128 -0
  320. pymoo/visualization/heatmap.py +123 -0
  321. pymoo/visualization/matplotlib.py +61 -0
  322. pymoo/visualization/pcp.py +121 -0
  323. pymoo/visualization/petal.py +91 -0
  324. pymoo/visualization/radar.py +108 -0
  325. pymoo/visualization/radviz.py +68 -0
  326. pymoo/visualization/scatter.py +150 -0
  327. pymoo/visualization/star_coordinate.py +75 -0
  328. pymoo/visualization/util.py +296 -0
  329. pymoo/visualization/video/__init__.py +0 -0
  330. pymoo/visualization/video/callback_video.py +82 -0
  331. pymoo/visualization/video/one_var_one_obj.py +57 -0
  332. pymoo/visualization/video/two_var_one_obj.py +62 -0
  333. pymoo-0.6.1.6.dist-info/METADATA +209 -0
  334. pymoo-0.6.1.6.dist-info/RECORD +337 -0
  335. pymoo-0.6.1.6.dist-info/WHEEL +6 -0
  336. pymoo-0.6.1.6.dist-info/licenses/LICENSE +191 -0
  337. pymoo-0.6.1.6.dist-info/top_level.txt +1 -0
@@ -0,0 +1,400 @@
1
+ import numpy as np
2
+
3
+ from pymoo.core.problem import Problem
4
+ # Based on the C++ implementation by the Ma and Wang
5
+ # http://www.escience.cn/people/yongwang1/index.html
6
+ from pymoo.problems.many import get_ref_dirs
7
+ from pymoo.util.remote import Remote
8
+
9
+
10
+ class MW(Problem):
11
+ def __init__(self, n_var, n_obj, n_ieq_constr, **kwargs):
12
+ if 'xl' not in kwargs:
13
+ kwargs['xl'] = 0
14
+ if 'xu' not in kwargs:
15
+ kwargs['xu'] = 1
16
+ super().__init__(n_var=n_var,
17
+ n_obj=n_obj,
18
+ n_ieq_constr=n_ieq_constr,
19
+ vtype=float, **kwargs)
20
+
21
+ @staticmethod
22
+ def LA1(A, B, C, D, theta):
23
+ return A * np.power(np.sin(B * np.pi * np.power(theta, C)), D)
24
+
25
+ @staticmethod
26
+ def LA2(A, B, C, D, theta):
27
+ return A * np.power(np.sin(B * np.power(theta, C)), D)
28
+
29
+ @staticmethod
30
+ def LA3(A, B, C, D, theta):
31
+ return A * np.power(np.cos(B * np.power(theta, C)), D)
32
+
33
+ def g1(self, X):
34
+ d = self.n_var
35
+ n = d - self.n_obj
36
+
37
+ z = np.power(X[:, self.n_obj - 1:], n)
38
+ i = np.arange(self.n_obj - 1, d)
39
+
40
+ exp = 1 - np.exp(-10.0 * (z - 0.5 - i / (2 * d)) * (z - 0.5 - i / (2 * d)))
41
+ distance = 1 + exp.sum(axis=1)
42
+ return distance
43
+
44
+ def g2(self, X):
45
+ d = self.n_var
46
+ n = d
47
+
48
+ i = np.arange(self.n_obj - 1, d)
49
+ z = 1 - np.exp(-10.0 * (X[:, self.n_obj - 1:] - i / n) * (X[:, self.n_obj - 1:] - i / n))
50
+ contrib = (0.1 / (n)) * z * z + 1.5 - 1.5 * np.cos(2 * np.pi * z)
51
+ distance = 1 + contrib.sum(axis=1)
52
+ return distance
53
+
54
+ def g3(self, X):
55
+ contrib = 2.0 * np.power(
56
+ X[:, self.n_obj - 1:] + (X[:, self.n_obj - 2:-1] - 0.5) * (X[:, self.n_obj - 2:-1] - 0.5) - 1.0, 2.0)
57
+ distance = 1 + contrib.sum(axis=1)
58
+ return distance
59
+
60
+
61
+ class MW1(MW):
62
+ def __init__(self, n_var=15, **kwargs):
63
+ super().__init__(n_var, 2, 1)
64
+
65
+ def _evaluate(self, X, out, *args, **kwargs):
66
+ g = self.g1(X)
67
+ f0 = X[:, 0]
68
+ f1 = g * (1 - 0.85 * f0 / g)
69
+
70
+ g0 = f0 + f1 - 1 - self.LA1(0.5, 2.0, 1.0, 8.0, np.sqrt(2.0) * f1 - np.sqrt(2.0) * f0)
71
+ out["F"] = np.column_stack([f0, f1])
72
+ out["G"] = g0.reshape((-1, 1))
73
+
74
+ def _calc_pareto_front(self, ref_dirs=None):
75
+ if ref_dirs is None:
76
+ F = np.zeros((100, 2))
77
+ F[:, 0] = np.linspace(0, 1, 100)
78
+ else:
79
+ F = ref_dirs
80
+ F[:, 1] = 1 - 0.85 * F[:, 0]
81
+ l = np.sqrt(2) * F[:, 1] - np.sqrt(2) * F[:, 0]
82
+ c = 1 - F[:, 0] - F[:, 1] + 0.5 * np.sin(2 * np.pi * l) ** 8
83
+ F = F[c >= 0]
84
+ return F
85
+
86
+
87
+ class MW2(MW):
88
+ def __init__(self, n_var=15, **kwargs):
89
+ super().__init__(n_var, 2, 1)
90
+
91
+ def _evaluate(self, X, out, *args, **kwargs):
92
+ g = self.g2(X)
93
+ f0 = X[:, 0]
94
+ f1 = g * (1 - f0 / g)
95
+
96
+ g0 = f0 + f1 - 1 - self.LA1(0.5, 3.0, 1.0, 8.0, np.sqrt(2.0) * f1 - np.sqrt(2.0) * f0)
97
+ out["F"] = np.column_stack([f0, f1])
98
+ out["G"] = g0.reshape((-1, 1))
99
+
100
+ def _calc_pareto_front(self, ref_dirs=None):
101
+ if ref_dirs is None:
102
+ F = np.zeros((100, 2))
103
+ F[:, 0] = np.linspace(0, 1, 100)
104
+ else:
105
+ F = ref_dirs
106
+ F[:, 1] = 1 - F[:, 0]
107
+ return F
108
+
109
+
110
+ class MW3(MW):
111
+ def __init__(self, n_var=15, **kwargs):
112
+ super().__init__(n_var, 2, 2)
113
+
114
+ def _evaluate(self, X, out, *args, **kwargs):
115
+ g = self.g3(X)
116
+ f0 = X[:, 0]
117
+ f1 = g * (1 - f0 / g)
118
+
119
+ g0 = f0 + f1 - 1.05 - self.LA1(0.45, 0.75, 1.0, 6.0, np.sqrt(2.0) * f1 - np.sqrt(2.0) * f0)
120
+ g1 = 0.85 - f0 - f1 + self.LA1(0.3, 0.75, 1.0, 2.0, np.sqrt(2.0) * f1 - np.sqrt(2.0) * f0)
121
+ out["F"] = np.column_stack([f0, f1])
122
+ out["G"] = np.column_stack([g0, g1])
123
+
124
+ def _calc_pareto_front(self, ref_dirs=None):
125
+ if ref_dirs is None:
126
+ F = np.zeros((100, 2))
127
+ F[:, 0] = np.linspace(0, 1, 100)
128
+ else:
129
+ F = ref_dirs
130
+ F[:, 1] = 1 - F[:, 0]
131
+ invalid = (0.85 - F[:, 0] - F[:, 1] + 0.3 * np.sin(0.75 * np.pi * np.sqrt(2) * (F[:, 1] - F[:, 0])) ** 2) > 0
132
+ while invalid.any():
133
+ F[invalid, :] *= 1.001
134
+ invalid = (0.85 - F[:, 0] - F[:, 1] + 0.3 * np.sin(
135
+ 0.75 * np.pi * np.sqrt(2) * (F[:, 1] - F[:, 0])) ** 2) > 0
136
+ return F
137
+
138
+
139
+ class MW4(MW):
140
+ def __init__(self, n_var=None, n_obj=3, **kwargs):
141
+ if n_var is None:
142
+ n_var = n_obj + 12
143
+ super().__init__(n_var, n_obj, 1)
144
+
145
+ def _evaluate(self, X, out, *args, **kwargs):
146
+ g = self.g1(X)
147
+ f = g.reshape((-1, 1)) * np.ones((X.shape[0], self.n_obj))
148
+ f[:, 1:] *= X[:, (self.n_obj - 2)::-1]
149
+ f[:, 0:-1] *= np.flip(np.cumprod(1 - X[:, :(self.n_obj - 1)], axis=1), axis=1)
150
+
151
+ g0 = f.sum(axis=1) - 1 - self.LA1(0.4, 2.5, 1.0, 8.0, f[:, -1] - f[:, :-1].sum(axis=1))
152
+ out["F"] = f
153
+ out["G"] = g0.reshape((-1, 1))
154
+
155
+ def _calc_pareto_front(self, ref_dirs=None):
156
+ if ref_dirs is None:
157
+ ref_dirs = get_ref_dirs(self.n_obj)
158
+ F = ref_dirs
159
+ l = F[:, -1] - np.sum(F[:, :-1], axis=1)
160
+ c = (1 + 0.4 * np.sin(2.5 * np.pi * l) ** 8) - np.sum(F, axis=1)
161
+ return F[c >= 0]
162
+
163
+
164
+ class MW5(MW):
165
+ def __init__(self, n_var=15, **kwargs):
166
+ super().__init__(n_var, 2, 3)
167
+
168
+ def _evaluate(self, X, out, *args, **kwargs):
169
+ g = self.g1(X)
170
+ f0 = g * X[:, 0]
171
+ f1 = g * np.sqrt(1.0 - np.power(f0 / g, 2.0))
172
+
173
+ with np.errstate(divide='ignore'):
174
+ atan = np.arctan(f1 / f0)
175
+
176
+ g0 = f0 ** 2 + f1 ** 2 - np.power(1.7 - self.LA2(0.2, 2.0, 1.0, 1.0, atan), 2.0)
177
+ t = 0.5 * np.pi - 2 * np.abs(atan - 0.25 * np.pi)
178
+ g1 = np.power(1 + self.LA2(0.5, 6.0, 3.0, 1.0, t), 2.0) - f0 ** 2 - f1 ** 2
179
+ g2 = np.power(1 - self.LA2(0.45, 6.0, 3.0, 1.0, t), 2.0) - f0 ** 2 - f1 ** 2
180
+ out["F"] = np.column_stack([f0, f1])
181
+ out["G"] = np.column_stack([g0, g1, g2])
182
+
183
+ def _calc_pareto_front(self, **kwargs):
184
+ return Remote.get_instance().load("pymoo", "pf", "MW", "MW5.pf")
185
+
186
+
187
+ class MW6(MW):
188
+ def __init__(self, n_var=15, **kwargs):
189
+ super().__init__(n_var, 2, 1, xl=0.0, xu=1.1)
190
+
191
+ def _evaluate(self, X, out, *args, **kwargs):
192
+ g = self.g2(X)
193
+ f0 = g * X[:, 0]
194
+ f1 = g * np.sqrt(1.1 * 1.1 - np.power(f0 / g, 2.0))
195
+
196
+ with np.errstate(divide='ignore'):
197
+ atan = np.arctan(f1 / f0)
198
+
199
+ g0 = f0 ** 2 / np.power(1.0 + self.LA3(0.15, 6.0, 4.0, 10.0, atan), 2.0) + f1 ** 2 / np.power(
200
+ 1.0 + self.LA3(0.75, 6.0, 4.0, 10.0, atan), 2.0) - 1
201
+ out["F"] = np.column_stack([f0, f1])
202
+ out["G"] = g0.reshape((-1, 1))
203
+
204
+ def _calc_pareto_front(self, ref_dirs=None):
205
+ if ref_dirs is None:
206
+ F = np.zeros((100, 2))
207
+ F[:, 0] = np.linspace(0, 1, 100)
208
+ else:
209
+ F = ref_dirs
210
+ F[:, 1] = 1 - F[:, 0]
211
+ F = F / np.sqrt(np.sum(F ** 2, axis=1) / 1.21).reshape((-1, 1))
212
+ l = np.cos(6 * np.arctan(F[:, 1] / F[:, 0]) ** 4) ** 10
213
+ c = 1 - (F[:, 0] / (1 + 0.15 * l)) ** 2 - (F[:, 1] / (1 + 0.75 * l)) ** 2
214
+ return F[c >= 0]
215
+
216
+
217
+ class MW7(MW):
218
+ def __init__(self, n_var=15, **kwargs):
219
+ super().__init__(n_var, 2, 2)
220
+
221
+ def _evaluate(self, X, out, *args, **kwargs):
222
+ g = self.g3(X)
223
+ f0 = g * X[:, 0]
224
+ f1 = g * np.sqrt(1 - np.power(f0 / g, 2))
225
+
226
+ with np.errstate(divide='ignore'):
227
+ atan = np.arctan(f1 / f0)
228
+
229
+ g0 = f0 ** 2 + f1 ** 2 - np.power(1.2 + np.abs(self.LA2(0.4, 4.0, 1.0, 16.0, atan)), 2.0)
230
+ g1 = np.power(1.15 - self.LA2(0.2, 4.0, 1.0, 8.0, atan), 2.0) - f0 ** 2 - f1 ** 2
231
+ out["F"] = np.column_stack([f0, f1])
232
+ out["G"] = np.column_stack([g0, g1])
233
+
234
+ def _calc_pareto_front(self, **kwargs):
235
+ return Remote.get_instance().load("pymoo", "pf", "MW", "MW7.pf")
236
+
237
+
238
+ class MW8(MW):
239
+ def __init__(self, n_var=None, n_obj=3, **kwargs):
240
+ if n_var is None:
241
+ n_var = n_obj + 12
242
+ super().__init__(n_var, n_obj, 1)
243
+
244
+ def _evaluate(self, X, out, *args, **kwargs):
245
+ g = self.g2(X)
246
+ f = g.reshape((-1, 1)) * np.ones((X.shape[0], self.n_obj))
247
+ f[:, 1:] *= np.sin(0.5 * np.pi * X[:, (self.n_obj - 2)::-1])
248
+ cos = np.cos(0.5 * np.pi * X[:, :(self.n_obj - 1)])
249
+ f[:, 0:-1] *= np.flip(np.cumprod(cos, axis=1), axis=1)
250
+
251
+ f_squared = (f ** 2).sum(axis=1)
252
+ g0 = f_squared - (1.25 - self.LA2(0.5, 6.0, 1.0, 2.0, np.arcsin(f[:, -1] / np.sqrt(f_squared)))) * (
253
+ 1.25 - self.LA2(0.5, 6.0, 1.0, 2.0, np.arcsin(f[:, -1] / np.sqrt(f_squared))))
254
+ out["F"] = f
255
+ out["G"] = g0.reshape((-1, 1))
256
+
257
+ def _calc_pareto_front(self, ref_dirs=None):
258
+ if ref_dirs is None:
259
+ ref_dirs = get_ref_dirs(self.n_obj)
260
+
261
+ F = ref_dirs
262
+ F = F / np.sqrt(np.sum(F ** 2, axis=1)).reshape((-1, 1))
263
+ c = (1.25 - 0.5 * np.sin(6 * np.arcsin(F[:, -1])) ** 2) ** 2 - np.sum(F ** 2, axis=1)
264
+ return F[c >= 0]
265
+
266
+
267
+ class MW9(MW):
268
+ def __init__(self, n_var=15, **kwargs):
269
+ super().__init__(n_var, 2, 1)
270
+
271
+ def _evaluate(self, X, out, *args, **kwargs):
272
+ g = self.g1(X)
273
+ f0 = g * X[:, 0]
274
+ f1 = g * (1.0 - np.power(f0 / g, 0.6))
275
+
276
+ t1 = (1 - 0.64 * f0 * f0 - f1) * (1 - 0.36 * f0 * f0 - f1)
277
+ t2 = (1.35 * 1.35 - (f0 + 0.35) * (f0 + 0.35) - f1) * (1.15 * 1.15 - (f0 + 0.15) * (f0 + 0.15) - f1)
278
+ g0 = np.minimum(t1, t2)
279
+ out["F"] = np.column_stack([f0, f1])
280
+ out["G"] = g0.reshape((-1, 1))
281
+
282
+ def _calc_pareto_front(self, **kwargs):
283
+ return Remote.get_instance().load("pymoo", "pf", "MW", "MW9.pf")
284
+
285
+
286
+ class MW10(MW):
287
+ def __init__(self, n_var=15, **kwargs):
288
+ super().__init__(n_var, 2, 3)
289
+
290
+ def _evaluate(self, X, out, *args, **kwargs):
291
+ g = self.g2(X)
292
+ f0 = g * np.power(X[:, 0], self.n_var)
293
+ f1 = g * (1.0 - np.power(f0 / g, 2.0))
294
+
295
+ g0 = -1.0 * (2.0 - 4.0 * f0 * f0 - f1) * (2.0 - 8.0 * f0 * f0 - f1)
296
+ g1 = (2.0 - 2.0 * f0 * f0 - f1) * (2.0 - 16.0 * f0 * f0 - f1)
297
+ g2 = (1.0 - f0 * f0 - f1) * (1.2 - 1.2 * f0 * f0 - f1)
298
+ out["F"] = np.column_stack([f0, f1])
299
+ out["G"] = np.column_stack([g0, g1, g2])
300
+
301
+ def _calc_pareto_front(self, **kwargs):
302
+ return Remote.get_instance().load("pymoo", "pf", "MW", "MW10.pf")
303
+
304
+
305
+ class MW11(MW):
306
+ def __init__(self, n_var=15, **kwargs):
307
+ super().__init__(n_var, 2, 4, xl=0.0, xu=np.sqrt(2))
308
+
309
+ def _evaluate(self, X, out, *args, **kwargs):
310
+ g = self.g3(X)
311
+ f0 = g * X[:, 0]
312
+ f1 = g * np.sqrt(2.0 - np.power(f0 / g, 2.0))
313
+
314
+ g0 = -1.0 * (3.0 - f0 * f0 - f1) * (3.0 - 2.0 * f0 * f0 - f1)
315
+ g1 = (3.0 - 0.625 * f0 * f0 - f1) * (3.0 - 7.0 * f0 * f0 - f1)
316
+ g2 = -1.0 * (1.62 - 0.18 * f0 * f0 - f1) * (1.125 - 0.125 * f0 * f0 - f1)
317
+ g3 = (2.07 - 0.23 * f0 * f0 - f1) * (0.63 - 0.07 * f0 * f0 - f1)
318
+ out["F"] = np.column_stack([f0, f1])
319
+ out["G"] = np.column_stack([g0, g1, g2, g3])
320
+
321
+ def _calc_pareto_front(self, **kwargs):
322
+ return Remote.get_instance().load("pymoo", "pf", "MW", "MW11.pf")
323
+
324
+
325
+ class MW12(MW):
326
+ def __init__(self, n_var=15, **kwargs):
327
+ super().__init__(n_var, 2, 2)
328
+
329
+ def _evaluate(self, X, out, *args, **kwargs):
330
+ g = self.g1(X)
331
+ f0 = g * X[:, 0]
332
+ f1 = g * (0.85 - 0.8 * (f0 / g) - 0.08 * np.abs(np.sin(3.2 * np.pi * (f0 / g))))
333
+
334
+ g0 = -1.0 * (1 - 0.625 * f0 - f1 + 0.08 * np.sin(2 * np.pi * (f1 - f0 / 1.6))) * (
335
+ 1.4 - 0.875 * f0 - f1 + 0.08 * np.sin(2 * np.pi * (f1 / 1.4 - f0 / 1.6)))
336
+ g1 = (1 - 0.8 * f0 - f1 + 0.08 * np.sin(2 * np.pi * (f1 - f0 / 1.5))) * (
337
+ 1.8 - 1.125 * f0 - f1 + 0.08 * np.sin(2 * np.pi * (f1 / 1.8 - f0 / 1.6)))
338
+ out["F"] = np.column_stack([f0, f1])
339
+ out["G"] = np.column_stack([g0, g1])
340
+
341
+ def _calc_pareto_front(self, ref_dirs=None):
342
+ if ref_dirs is None:
343
+ F = np.zeros((100, 2))
344
+ F[:, 0] = np.linspace(0, 1, 100)
345
+ else:
346
+ F = ref_dirs
347
+ F[:, 1] = 0.85 - 0.8 * F[:, 0] - 0.08 * np.abs(np.sin(3.2 * np.pi * F[:, 0]))
348
+
349
+ invalid = (1 - 0.8 * F[:, 0] - F[:, 1] + 0.08 * np.sin(2 * np.pi * (F[:, 1] - F[:, 0] / 1.5))) * (
350
+ 1.8 - 1.125 * F[:, 0] - F[:, 1] + 0.08 * np.sin(2 * np.pi * (F[:, 1] / 1.8 - F[:, 0] / 1.6))) > 0
351
+ while invalid.any():
352
+ F[invalid, :] *= 1.001
353
+ invalid = (1 - 0.8 * F[:, 0] - F[:, 1] + 0.08 * np.sin(2 * np.pi * (F[:, 1] - F[:, 0] / 1.5))) * (
354
+ 1.8 - 1.125 * F[:, 0] - F[:, 1] + 0.08 * np.sin(
355
+ 2 * np.pi * (F[:, 1] / 1.8 - F[:, 0] / 1.6))) > 0
356
+ return F
357
+
358
+
359
+ class MW13(MW):
360
+ def __init__(self, n_var=15, **kwargs):
361
+ super().__init__(n_var, 2, 2, xu=1.5)
362
+
363
+ def _evaluate(self, X, out, *args, **kwargs):
364
+ g = self.g2(X)
365
+ f0 = g * X[:, 0]
366
+ f1 = g * (5.0 - np.exp(f0 / g) - np.abs(0.5 * np.sin(3 * np.pi * f0 / g)))
367
+
368
+ g0 = -1.0 * (5.0 - (1 + f0 + 0.5 * f0 * f0) - 0.5 * np.sin(3 * np.pi * f0) - f1) * (
369
+ 5.0 - (1 + 0.7 * f0) - 0.5 * np.sin(3 * np.pi * f0) - f1)
370
+ g1 = (5.0 - np.exp(f0) - 0.5 * np.sin(3 * np.pi * f0) - f1) * (
371
+ 5.0 - (1 + 0.4 * f0) - 0.5 * np.sin(3 * np.pi * f0) - f1)
372
+ out["F"] = np.column_stack([f0, f1])
373
+ out["G"] = np.column_stack([g0, g1])
374
+
375
+ def _calc_pareto_front(self, **kwargs):
376
+ return Remote.get_instance().load("pymoo", "pf", "MW", "MW13.pf")
377
+
378
+
379
+ class MW14(MW):
380
+ def __init__(self, n_var=None, n_obj=3, **kwargs):
381
+ if n_var is None:
382
+ n_var = n_obj + 12
383
+ super().__init__(n_var, n_obj, 1, xu=1.5)
384
+
385
+ def _evaluate(self, X, out, *args, **kwargs):
386
+ g = self.g3(X)
387
+ f = np.zeros((X.shape[0], self.n_obj))
388
+ f[:, :-1] = X[:, :(self.n_obj - 1)]
389
+ LA1 = self.LA1(1.5, 1.1, 2.0, 1.0, f[:, :-1])
390
+ inter = (6 - np.exp(f[:, :-1]) - LA1).sum(axis=1)
391
+ f[:, -1] = g / (self.n_obj - 1) * inter
392
+
393
+ alpha = 6.1 - 1 - f[:, :-1] - 0.5 * f[:, :-1] * f[:, :-1] - LA1
394
+ g0 = f[:, -1] - 1 / (self.n_obj - 1) * alpha.sum(axis=1)
395
+ out["F"] = f
396
+ out["G"] = g0.reshape((-1, 1))
397
+
398
+ def _calc_pareto_front(self, **kwargs):
399
+ if self.n_obj == 3:
400
+ return Remote.get_instance().load("pymoo", "pf", "MW", "MW14.pf")
@@ -0,0 +1,48 @@
1
+ import pymoo.gradient.toolbox as anp
2
+ import numpy as np
3
+
4
+ from pymoo.core.problem import Problem
5
+
6
+
7
+ class OmniTest(Problem):
8
+ """
9
+ The Omni-test problem proposed by Deb in [1].
10
+
11
+ Parameters
12
+ ----------
13
+ n_var: number of decision variables
14
+
15
+ References
16
+ ----------
17
+ [1] Deb, K., Tiwari, S. "Omni-optimizer: A generic evolutionary algorithm for single and multi-objective optimization"
18
+ """
19
+ def __init__(self, n_var=2):
20
+ assert (n_var >= 2), "The dimension of the decision space should at least be 2!"
21
+ super().__init__(
22
+ n_var=n_var, n_obj=2, vtype=float, xl=np.full(n_var, 0), xu=np.full(n_var, 6)
23
+ )
24
+
25
+ def _evaluate(self, X, out, *args, **kwargs):
26
+ F1 = anp.sum(anp.sin(anp.pi * X), axis=1)
27
+ F2 = anp.sum(anp.cos(anp.pi * X), axis=1)
28
+ out["F"] = anp.vstack((F1, F2)).T
29
+
30
+ def _calc_pareto_set(self, n_pareto_points=500):
31
+ # The Omni-test problem has 3^D Pareto subsets
32
+ num_ps = int(3 ** self.n_var)
33
+ h = int(n_pareto_points / num_ps)
34
+ PS = np.zeros((num_ps * h, self.n_var))
35
+
36
+ candidates = np.array([np.linspace(2 * m + 1, 2 * m + 3 / 2, h) for m in range(3)])
37
+ # generate combination indices
38
+ candidates_indices = [[0, 1, 2] for _ in range(self.n_var)]
39
+ a = np.meshgrid(*candidates_indices)
40
+ combination_indices = np.array(a).T.reshape(-1, self.n_var)
41
+ # generate 3^D combinations
42
+ for i in range(num_ps):
43
+ PS[i * h:i * h + h, :] = candidates[combination_indices[i]].T
44
+ return PS
45
+
46
+ def _calc_pareto_front(self, n_pareto_points=500):
47
+ PS = self._calc_pareto_set(n_pareto_points)
48
+ return self.evaluate(PS, return_values_of=["F"])
@@ -0,0 +1,32 @@
1
+ import pymoo.gradient.toolbox as anp
2
+ import numpy as np
3
+
4
+ from pymoo.core.problem import Problem
5
+ from pymoo.util.remote import Remote
6
+
7
+
8
+ class OSY(Problem):
9
+ def __init__(self):
10
+ super().__init__(n_var=6, n_obj=2, n_ieq_constr=6, vtype=float)
11
+ self.xl = np.array([0.0, 0.0, 1.0, 0.0, 1.0, 0.0])
12
+ self.xu = np.array([10.0, 10.0, 5.0, 6.0, 5.0, 10.0])
13
+
14
+ def _evaluate(self, x, out, *args, **kwargs):
15
+ f1 = - (25 * (x[:, 0] - 2) ** 2 + (x[:, 1] - 2) ** 2 + (x[:, 2] - 1) ** 2 + (x[:, 3] - 4) ** 2 + (
16
+ x[:, 4] - 1) ** 2)
17
+ f2 = anp.sum(anp.square(x), axis=1)
18
+
19
+ g1 = (x[:, 0] + x[:, 1] - 2.0) / 2.0
20
+ g2 = (6.0 - x[:, 0] - x[:, 1]) / 6.0
21
+ g3 = (2.0 - x[:, 1] + x[:, 0]) / 2.0
22
+ g4 = (2.0 - x[:, 0] + 3.0 * x[:, 1]) / 2.0
23
+ g5 = (4.0 - (x[:, 2] - 3.0) ** 2 - x[:, 3]) / 4.0
24
+ g6 = ((x[:, 4] - 3.0) ** 2 + x[:, 5] - 4.0) / 4.0
25
+
26
+ out["F"] = anp.column_stack([f1, f2])
27
+
28
+ out["G"] = anp.column_stack([g1, g2, g3, g4, g5, g6])
29
+ out["G"] = - out["G"]
30
+
31
+ def _calc_pareto_front(self):
32
+ return Remote.get_instance().load("pymoo", "pf", "osy.pf")
@@ -0,0 +1,28 @@
1
+ import pymoo.gradient.toolbox as anp
2
+ import numpy as np
3
+
4
+ from pymoo.core.problem import Problem
5
+
6
+
7
+ class SRN(Problem):
8
+ def __init__(self):
9
+ super().__init__(n_var=2, n_obj=2, n_ieq_constr=2, xl=-20, xu=+20, vtype=float)
10
+
11
+ def _evaluate(self, x, out, *args, **kwargs):
12
+ f1 = 2 + (x[:, 0] - 2) ** 2 + (x[:, 1] - 1) ** 2
13
+ f2 = 9 * x[:, 0] - (x[:, 1] - 1) ** 2
14
+
15
+ g1 = x[:, 0] ** 2 + x[:, 1] ** 2 - 225
16
+ g2 = x[:, 0] - 3 * x[:, 1] + 10
17
+
18
+ out["F"] = anp.column_stack([f1, f2])
19
+ out["G"] = anp.column_stack([g1, g2])
20
+
21
+ def _calc_pareto_front(self, *args, n_points=100, **kwargs):
22
+ ps = self.pareto_set(n_points=n_points)
23
+ return self.evaluate(ps, return_values_of=["F"])
24
+
25
+ def _calc_pareto_set(self, *args, n_points=100, **kwargs):
26
+ x1 = np.full(n_points, -2.5)
27
+ x2 = np.linspace(2.5, 14.7902, n_points)
28
+ return np.column_stack([x1, x2])
@@ -0,0 +1,94 @@
1
+ import pymoo.gradient.toolbox as anp
2
+ import numpy as np
3
+
4
+
5
+ from pymoo.core.problem import Problem
6
+
7
+
8
+ class SYMPARTRotated(Problem):
9
+ """
10
+ The SYM-PART test problem proposed in [1].
11
+
12
+ Parameters:
13
+ -----------
14
+ length: the length of each line (i.e., each Pareto subsets), default is 1.
15
+ v_dist: vertical distance between the centers of two adjacent lines, default is 10.
16
+ h_dist: horizontal distance between the centers of two adjacent lines, default is 10.
17
+ angle: the angle to rotate the equivalent Pareto subsets counterclockwisely.
18
+ When set to a negative value, Pareto subsets are rotated clockwisely.
19
+
20
+ References:
21
+ ----------
22
+ [1] G. Rudolph, B. Naujoks, and M. Preuss, “Capabilities of EMOA to detect and preserve equivalent Pareto subsets”
23
+ """
24
+
25
+ def __init__(self, length=1, v_dist=10, h_dist=10, angle=np.pi / 4):
26
+ self.a = length
27
+ self.b = v_dist
28
+ self.c = h_dist
29
+ self.w = angle
30
+
31
+ # Calculate the inverted rotation matrix, store for fitness evaluation
32
+ self.IRM = np.array([
33
+ [np.cos(self.w), np.sin(self.w)],
34
+ [-np.sin(self.w), np.cos(self.w)]])
35
+
36
+ r = max(self.b, self.c)
37
+ xl = np.full(2, -10 * r)
38
+ xu = np.full(2, 10 * r)
39
+
40
+ super().__init__(n_var=2, n_obj=2, vtype=float, xl=xl, xu=xu)
41
+
42
+ def _evaluate(self, X, out, *args, **kwargs):
43
+ if self.w == 0:
44
+ X1 = X[:, 0]
45
+ X2 = X[:, 1]
46
+ else:
47
+ # If rotated, we rotate it back by applying the inverted rotation matrix to X
48
+ Y = anp.array([anp.matmul(self.IRM, x) for x in X])
49
+ X1 = Y[:, 0]
50
+ X2 = Y[:, 1]
51
+
52
+ a, b, c = self.a, self.b, self.c
53
+ t1_hat = anp.sign(X1) * anp.ceil((anp.abs(X1) - a - c / 2) / (2 * a + c))
54
+ t2_hat = anp.sign(X2) * anp.ceil((anp.abs(X2) - b / 2) / b)
55
+ one = anp.ones(len(X))
56
+ t1 = anp.sign(t1_hat) * anp.min(anp.vstack((anp.abs(t1_hat), one)), axis=0)
57
+ t2 = anp.sign(t2_hat) * anp.min(anp.vstack((anp.abs(t2_hat), one)), axis=0)
58
+
59
+ p1 = X1 - t1 * c
60
+ p2 = X2 - t2 * b
61
+
62
+ f1 = (p1 + a) ** 2 + p2 ** 2
63
+ f2 = (p1 - a) ** 2 + p2 ** 2
64
+ out["F"] = anp.vstack((f1, f2)).T
65
+
66
+ def _calc_pareto_set(self, n_pareto_points=500):
67
+ # The SYM-PART test problem has 9 equivalent Pareto subsets.
68
+ h = int(n_pareto_points / 9)
69
+ PS = np.zeros((h * 9, self.n_var))
70
+ cnt = 0
71
+ for row in [-1, 0, 1]:
72
+ for col in [1, 0, -1]:
73
+ X1 = np.linspace(row * self.c - self.a, row * self.c + self.a, h)
74
+ X2 = np.tile(col * self.b, h)
75
+ PS[cnt * h:cnt * h + h, :] = np.vstack((X1, X2)).T
76
+ cnt = cnt + 1
77
+ if self.w != 0:
78
+ # If rotated, we apply the rotation matrix to PS
79
+ # Calculate the rotation matrix
80
+ RM = np.array([
81
+ [np.cos(self.w), -np.sin(self.w)],
82
+ [np.sin(self.w), np.cos(self.w)]
83
+ ])
84
+ PS = np.array([np.matmul(RM, x) for x in PS])
85
+ return PS
86
+
87
+ def _calc_pareto_front(self, n_pareto_points=500):
88
+ PS = self.pareto_set(n_pareto_points)
89
+ return self.evaluate(PS, return_values_of=["F"])
90
+
91
+
92
+ class SYMPART(SYMPARTRotated):
93
+ def __init__(self, length=1, v_dist=10, h_dist=10):
94
+ super().__init__(length, v_dist, h_dist, 0)
@@ -0,0 +1,24 @@
1
+ import pymoo.gradient.toolbox as anp
2
+ import numpy as np
3
+
4
+ from pymoo.core.problem import Problem
5
+ from pymoo.util.remote import Remote
6
+
7
+
8
+ class TNK(Problem):
9
+ def __init__(self):
10
+ super().__init__(n_var=2, n_obj=2, n_ieq_constr=2, vtype=float)
11
+ self.xl = np.array([0, 1e-30])
12
+ self.xu = np.array([np.pi, np.pi])
13
+
14
+ def _evaluate(self, x, out, *args, **kwargs):
15
+ f1 = x[:, 0]
16
+ f2 = x[:, 1]
17
+ g1 = -(anp.square(x[:, 0]) + anp.square(x[:, 1]) - 1.0 - 0.1 * anp.cos(16.0 * anp.arctan(x[:, 0] / x[:, 1])))
18
+ g2 = 2 * (anp.square(x[:, 0] - 0.5) + anp.square(x[:, 1] - 0.5)) - 1
19
+
20
+ out["F"] = anp.column_stack([f1, f2])
21
+ out["G"] = anp.column_stack([g1, g2])
22
+
23
+ def _calc_pareto_front(self, *args, **kwargs):
24
+ return Remote.get_instance().load("pymoo", "pf", "tnk.pf")