pymoo 0.6.1.5.dev0__cp310-cp310-macosx_11_0_arm64.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-310-darwin.so +0 -0
  91. pymoo/cython/calc_perpendicular_distance.pyx +67 -0
  92. pymoo/cython/decomposition.cpython-310-darwin.so +0 -0
  93. pymoo/cython/decomposition.pyx +165 -0
  94. pymoo/cython/hv.cpython-310-darwin.so +0 -0
  95. pymoo/cython/hv.pyx +18 -0
  96. pymoo/cython/info.cpython-310-darwin.so +0 -0
  97. pymoo/cython/info.pyx +5 -0
  98. pymoo/cython/mnn.cpython-310-darwin.so +0 -0
  99. pymoo/cython/mnn.pyx +273 -0
  100. pymoo/cython/non_dominated_sorting.cpython-310-darwin.so +0 -0
  101. pymoo/cython/non_dominated_sorting.pyx +645 -0
  102. pymoo/cython/pruning_cd.cpython-310-darwin.so +0 -0
  103. pymoo/cython/pruning_cd.pyx +197 -0
  104. pymoo/cython/stochastic_ranking.cpython-310-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
@@ -0,0 +1,104 @@
1
+ import pymoo.gradient.toolbox as anp
2
+ import numpy as np
3
+
4
+ from pymoo.core.problem import Problem
5
+
6
+
7
+ class Clutch(Problem):
8
+
9
+ def __init__(self):
10
+ super().__init__(n_var=5, n_obj=2, n_ieq_constr=19, vtype=int)
11
+ # ri, ro, t, F, Xp
12
+ # self.xl = np.array([60, 90, 1, 600, 2])
13
+ self.xl = np.array([0, 0, 0, 0, 0])
14
+ self.xu = np.array([20, 20, 4, 400, 7])
15
+
16
+ self.x1 = np.arange(60, 81)
17
+ self.x2 = np.arange(90, 111)
18
+ self.x3 = np.arange(1, 3.5, 0.5)
19
+ self.x4 = np.arange(600, 1001)
20
+ self.x5 = np.arange(2, 11)
21
+
22
+ def _evaluate(self, x, out, *args, **kwargs):
23
+
24
+ x1, x2, x3, x4, x5 = anp.split(x, 5, axis=1)
25
+
26
+ x1 = self.x1[x1]
27
+ x2 = self.x2[x2]
28
+ x3 = self.x3[x3]
29
+ x4 = self.x4[x4]
30
+ x5 = self.x5[x5]
31
+
32
+ pi = anp.pi
33
+ mu = 0.5
34
+ s = 1.5
35
+ M_f = 3 # Nm
36
+ ri_max = 80 # mm
37
+ t_max = 3 # mm
38
+ n = 250 # rpm
39
+ w = pi * n/30 # rad/s
40
+ R_sr = (2/3) * ((x2**3 - x1**3)/(x2**2 - x1**2)) # mm
41
+ p_max = 1 # MPa
42
+ T_max = 15 # s
43
+ I_z = 55 # kg*m^2
44
+ ro_min = 90 # mm
45
+ F_max = 1000 # N
46
+ A = pi * (x2**2 - x1**2) # mm^2
47
+ deltaR = 20 # mm
48
+ rho = 0.0000078 # kg/mm^2
49
+ delta = 0.5 # mm
50
+ ro_max = 110 # mm
51
+
52
+ Z_max = 9
53
+ p_rz = x4/A # N/mm^2
54
+ L_max = 30 # mm
55
+ Vsr_max = 10 #m/s
56
+ M_s = 40 # Nm
57
+ ri_min = 60 # mm
58
+ t_min = 1.5 # mm
59
+
60
+ M_h = (2/3) * mu * x4 * x5 * ((x2**3 - x1**3)/(x2**2 - x1**2)) # N*mm
61
+ Vsr = (pi * R_sr * n)/30 # mm/s
62
+
63
+ T = (I_z * w)/(M_h/1000 + M_f)
64
+
65
+ g1 = (x2 - x1 - deltaR) * -1
66
+ g2 = (L_max - (x5 + 1) * (x3 + delta)) * -1
67
+ g3 = (p_max - p_rz) * -1
68
+ g4 = (p_max * Vsr_max*1000 - p_rz * Vsr) * -1
69
+ g5 = (Vsr_max*1000 - Vsr) * -1
70
+ g6 = (M_h/1000 - (s * M_s)) * -1
71
+ g7 = T * -1
72
+ g8 = (T_max - T) * -1
73
+
74
+ _g9 = -x1 + ri_min
75
+ _g10 = x1 - ri_max
76
+
77
+ _g11 = -x2 + ro_min
78
+ _g12 = x2 - ro_max
79
+
80
+ _g13 = -x3 + t_min
81
+ _g14 = x3 - t_max
82
+
83
+ _g15 = -x4
84
+ _g16 = x4 - F_max
85
+
86
+ _g17 = -x5 + 2
87
+ _g18 = x5 - Z_max
88
+
89
+ f1 = pi * (x2**2 - x1**2) * x3 * (x5 + 1) * rho
90
+ f2 = T
91
+
92
+ out["F"] = anp.column_stack([f1, f2])
93
+ out["G"] = anp.column_stack([g1, g2, g3, g4, g5, g6, g7, g8])
94
+
95
+
96
+ if __name__ == "__main__":
97
+ x = np.array([[10, 0, 1, 400, 1]])
98
+ # x = np.array([[10, 0, 0, 260, 1]])
99
+
100
+ problem = Clutch()
101
+
102
+ res = problem.evaluate(x)
103
+
104
+ print(res)
@@ -0,0 +1,55 @@
1
+ import pymoo.gradient.toolbox as anp
2
+ import numpy as np
3
+
4
+ from pymoo.core.problem import Problem
5
+
6
+
7
+ class CSI(Problem):
8
+ def __init__(self):
9
+ xl = np.array([0.500, 0.450, 0.500, 0.500, 0.875, 0.400, 0.400])
10
+ xu = np.array([1.500, 1.350, 1.500, 1.500, 2.625, 1.200, 1.200])
11
+ super().__init__(n_var=7, n_obj=3, n_ieq_constr=10, xl=xl, xu=xu, vtype=float)
12
+
13
+ def _evaluate(self, x, out, *args, **kwargs):
14
+
15
+ # the definition is index 1 based -> simply add a dummy var in the beginning
16
+ x = anp.column_stack([anp.zeros((len(x), 1)), x])
17
+
18
+ F = 4.72 - 0.5 * x[:, 4] - 0.19 * x[:, 2] * x[:, 3]
19
+
20
+ V_mbp = 10.58 - 0.674 * x[:, 1] * x[:, 2] - 0.67275 * x[:, 2]
21
+
22
+ V_fd = 16.45 - 0.489 * x[:, 3] * x[:, 7] - 0.843 * x[:, 5] * x[:, 6]
23
+
24
+ f1 = 1.98 + 4.9 * x[:, 1] + 6.67 * x[:, 2] + 6.98 * x[:, 3] + 4.01 * x[:, 4] + 1.78 * x[:, 5] + \
25
+ 0.00001 * x[:, 6] + 2.73 * x[:, 7]
26
+
27
+ f2 = F
28
+
29
+ f3 = 0.5 * (V_mbp + V_fd)
30
+
31
+ g1 = 1.16 - 0.3717 * x[:, 2] * x[:, 4] - 0.0092928 * x[:, 3] - 1
32
+
33
+ g2 = 0.261 - 0.0159 * x[:, 1] * x[:, 2] - 0.06486 * x[:, 1] - 0.019 * x[:, 2] * x[:, 7] + \
34
+ 0.0144 * x[:, 3] * x[:, 5] + 0.0154464 * x[:, 6] - 0.32
35
+
36
+ g3 = 0.214 + 0.00817 * x[:, 5] - 0.045195 * x[:, 1] - 0.0135168 * x[:, 1] + 0.03099 * x[:, 2] * x[:, 6] - \
37
+ 0.018 * x[:, 2] * x[:, 7] + 0.007176 * x[:, 3] + 0.023232 * x[:, 3] - 0.00364 * x[:, 5] * x[:, 6] - \
38
+ 0.018 * x[:, 2] ** 2 - 0.32
39
+
40
+ g4 = 0.74 - 0.61 * x[:, 2] - 0.031296 * x[:, 3] - 0.031872 * x[:, 7] + 0.227 * x[:, 2] ** 2 - 0.32
41
+
42
+ g5 = 28.98 + 3.818 * x[:, 3] - 4.2 * x[:, 1] * x[:, 2] + 1.27296 * x[:, 6] - 2.68065 * x[:, 7] - 32
43
+
44
+ g6 = 33.86 + 2.95 * x[:, 3] - 5.057 * x[:, 1] * x[:, 2] - 3.795 * x[:, 2] - 3.4431 * x[:, 7] + 1.45728 - 32
45
+
46
+ g7 = 46.36 - 9.9 * x[:, 2] - 4.4505 * x[:, 1] - 32
47
+
48
+ g8 = F - 4
49
+
50
+ g9 = V_mbp - 9.9
51
+
52
+ g10 = V_fd - 15.7
53
+
54
+ out["F"] = anp.column_stack([f1, f2, f3])
55
+ out["G"] = anp.column_stack([g1, g2, g3, g4, g5, g6, g7, g8, g9, g10])
@@ -0,0 +1,198 @@
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
+ def g_linear(x):
9
+ return 1 + np.sum(x, axis=1)
10
+
11
+
12
+ def g_multimodal(x):
13
+ A = 10
14
+ return 1 + A * x.shape[1] + np.sum(x ** 2 - A * np.cos(2 * np.pi * x), axis=1)
15
+
16
+
17
+ class CTP(Problem):
18
+
19
+ def __init__(self, n_var=2, n_ieq_constr=1, option="linear"):
20
+ super().__init__(n_var=n_var, n_obj=2, n_ieq_constr=n_ieq_constr, xl=0, xu=1, vtype=float)
21
+
22
+ if option == "linear":
23
+ self.calc_g = g_linear
24
+
25
+ elif option == "multimodal":
26
+ self.calc_g = g_multimodal
27
+ self.xl[1:] = -5.12
28
+ self.xu[1:] = 5.12
29
+
30
+ else:
31
+ print("Unknown option for CTP single.")
32
+
33
+ def calc_objectives(self, x):
34
+ f1 = x[:, 0]
35
+ gg = self.calc_g(x[:, 1:])
36
+ f2 = gg * (1 - (f1 / gg) ** 0.5)
37
+ return f1, f2
38
+
39
+ def calc_constraint(self, theta, a, b, c, d, e, f1, f2):
40
+
41
+ # Equations in readable format
42
+ exp1 = (f2 - e) * anp.cos(theta) - f1 * anp.sin(theta)
43
+
44
+ exp2 = (f2 - e) * anp.sin(theta) + f1 * anp.cos(theta)
45
+ exp2 = b * anp.pi * (exp2 ** c)
46
+ exp2 = anp.abs(anp.sin(exp2))
47
+ exp2 = a * (exp2 ** d)
48
+
49
+ # as in the paper
50
+ # val = - (exp1 - exp2)
51
+
52
+ # as in the C code of NSGA2
53
+ val = 1 - exp1 / exp2
54
+
55
+ # ONE EQUATION
56
+ # _val = - (anp.cos(theta) * (f2 - e) - anp.sin(theta) * f1 -
57
+ # a * anp.abs(anp.sin(b * anp.pi * (anp.sin(theta) * (f2 - e) + anp.cos(theta) * f1) ** c)) ** d)
58
+
59
+ return val
60
+
61
+ def _calc_pareto_front(self, *args, **kwargs):
62
+ return Remote.get_instance().load("pymoo", "pf", "CTP", str(self.__class__.__name__).lower() + ".pf")
63
+
64
+
65
+ class CTP1(CTP):
66
+
67
+ def __init__(self, n_var=2, n_ieq_constr=2, **kwargs):
68
+ super().__init__(n_var, n_ieq_constr, **kwargs)
69
+
70
+ a, b = np.zeros(n_ieq_constr + 1), np.zeros(n_ieq_constr + 1)
71
+ a[0], b[0] = 1, 1
72
+ delta = 1 / (n_ieq_constr + 1)
73
+ alpha = delta
74
+
75
+ for j in range(n_ieq_constr):
76
+ beta = a[j] * np.exp(-b[j] * alpha)
77
+ a[j + 1] = (a[j] + beta) / 2
78
+ b[j + 1] = - 1 / alpha * np.log(beta / a[j + 1])
79
+
80
+ alpha += delta
81
+
82
+ self.a = a[1:]
83
+ self.b = b[1:]
84
+
85
+ def _evaluate(self, x, out, *args, **kwargs):
86
+ f1 = x[:, 0]
87
+ gg = self.calc_g(x[:, 1:])
88
+ f2 = gg * anp.exp(-f1 / gg)
89
+ out["F"] = anp.column_stack([f1, f2])
90
+
91
+ a, b = self.a, self.b
92
+ g = []
93
+ for j in range(self.n_ieq_constr):
94
+ _g = - (f2 - (a[j] * anp.exp(-b[j] * f1)))
95
+ g.append(_g)
96
+ out["G"] = anp.column_stack(g)
97
+
98
+
99
+ class CTP2(CTP):
100
+
101
+ def _evaluate(self, x, out, *args, **kwargs):
102
+ f1, f2 = self.calc_objectives(x)
103
+ out["F"] = anp.column_stack([f1, f2])
104
+
105
+ theta = -0.2 * anp.pi
106
+ a, b, c, d, e = 0.2, 10, 1, 6, 1
107
+ out["G"] = self.calc_constraint(theta, a, b, c, d, e, f1, f2)
108
+
109
+
110
+ class CTP3(CTP):
111
+
112
+ def _evaluate(self, x, out, *args, **kwargs):
113
+ f1, f2 = self.calc_objectives(x)
114
+ out["F"] = anp.column_stack([f1, f2])
115
+
116
+ theta = -0.2 * anp.pi
117
+ a, b, c, d, e = 0.1, 10, 1, 0.5, 1
118
+
119
+ out["G"] = self.calc_constraint(theta, a, b, c, d, e, f1, f2)
120
+
121
+
122
+ class CTP4(CTP):
123
+
124
+ def _evaluate(self, x, out, *args, **kwargs):
125
+ f1, f2 = self.calc_objectives(x)
126
+ out["F"] = anp.column_stack([f1, f2])
127
+
128
+ theta = -0.2 * anp.pi
129
+ a, b, c, d, e = 0.75, 10, 1, 0.5, 1
130
+
131
+ out["G"] = self.calc_constraint(theta, a, b, c, d, e, f1, f2)
132
+
133
+
134
+ class CTP5(CTP):
135
+
136
+ def _evaluate(self, x, out, *args, **kwargs):
137
+ f1, f2 = self.calc_objectives(x)
138
+ out["F"] = anp.column_stack([f1, f2])
139
+
140
+ theta = -0.2 * anp.pi
141
+ a, b, c, d, e = 0.1, 10, 2, 0.5, 1
142
+
143
+ out["G"] = self.calc_constraint(theta, a, b, c, d, e, f1, f2)
144
+
145
+
146
+ class CTP6(CTP):
147
+
148
+ def __init__(self, **kwargs):
149
+ super().__init__(**kwargs)
150
+ self.xu = np.full(self.n_var, 20)
151
+ self.xu[0] = 1
152
+
153
+ def _evaluate(self, x, out, *args, **kwargs):
154
+ f1, f2 = self.calc_objectives(x)
155
+ out["F"] = anp.column_stack([f1, f2])
156
+
157
+ theta = 0.1 * anp.pi
158
+ a, b, c, d, e = 40, 0.5, 1, 2, -2
159
+
160
+ out["G"] = self.calc_constraint(theta, a, b, c, d, e, f1, f2)
161
+
162
+
163
+ class CTP7(CTP):
164
+
165
+ def _evaluate(self, x, out, *args, **kwargs):
166
+ f1, f2 = self.calc_objectives(x)
167
+ out["F"] = anp.column_stack([f1, f2])
168
+
169
+ theta = -0.05 * anp.pi
170
+ a, b, c, d, e = 40, 5, 1, 6, 0
171
+
172
+ out["G"] = self.calc_constraint(theta, a, b, c, d, e, f1, f2)
173
+
174
+
175
+ class CTP8(CTP):
176
+ def __init__(self, **kwargs):
177
+ super().__init__(n_ieq_constr=2, **kwargs)
178
+ self.xu = np.full(self.n_var, 20)
179
+ self.xu[0] = 1
180
+
181
+ def _evaluate(self, x, out, *args, **kwargs):
182
+ f1, f2 = self.calc_objectives(x)
183
+ out["F"] = anp.column_stack([f1, f2])
184
+
185
+ theta = 0.1 * anp.pi
186
+ a, b, c, d, e = 40, 0.5, 1, 2, -2
187
+ g1 = self.calc_constraint(theta, a, b, c, d, e, f1, f2)
188
+
189
+ theta = -0.05 * anp.pi
190
+ a, b, c, d, e = 40, 2, 1, 6, 0
191
+ g2 = self.calc_constraint(theta, a, b, c, d, e, f1, f2)
192
+
193
+ out["G"] = anp.column_stack([g1, g2])
194
+
195
+
196
+ if __name__ == '__main__':
197
+ problem = CTP1(n_ieq_constr=3)
198
+ print(problem.n_ieq_constr)
@@ -0,0 +1,213 @@
1
+ import numpy as np
2
+
3
+ from pymoo.core.problem import Problem
4
+ from pymoo.util.remote import Remote
5
+
6
+ DIFFICULTIES = [
7
+ (0.25, 0., 0.), (0., 0.25, 0.), (0., 0., 0.25), (0.25, 0.25, 0.25),
8
+ (0.5, 0., 0.), (0., 0.5, 0.), (0., 0., 0.5), (0.5, 0.5, 0.5),
9
+ (0.75, 0., 0.), (0., 0.75, 0.), (0., 0., 0.75), (0.75, 0.75, 0.75),
10
+ (0., 1.0, 0.), (0.5, 1.0, 0.), (0., 1.0, 0.5), (0.5, 1.0, 0.5)
11
+ ]
12
+
13
+
14
+ class DASCMOP(Problem):
15
+ def __init__(self, n_obj, n_ieq_constr, difficulty, **kwargs):
16
+ super().__init__(n_var=30,
17
+ n_obj=n_obj,
18
+ n_ieq_constr=n_ieq_constr,
19
+ vtype=float, xl=0., xu=1., **kwargs)
20
+
21
+ if isinstance(difficulty, int):
22
+ self.difficulty = difficulty
23
+ if not (1 <= difficulty <= len(DIFFICULTIES)):
24
+ raise Exception(f"Difficulty must be 1 <= difficulty <= {len(DIFFICULTIES)}, but it is {difficulty}!")
25
+ vals = DIFFICULTIES[difficulty - 1]
26
+ else:
27
+ self.difficulty = -1
28
+ vals = difficulty
29
+
30
+ self.eta, self.zeta, self.gamma = vals
31
+
32
+ def g1(self, X):
33
+ contrib = (X[:, self.n_obj - 1:] - np.sin(0.5 * np.pi * X[:, 0:1])) ** 2
34
+ return contrib.sum(axis=1)[:, None]
35
+
36
+ def g2(self, X):
37
+ z = X[:, self.n_obj - 1:] - 0.5
38
+ contrib = z ** 2 - np.cos(20 * np.pi * z)
39
+ return (self.n_var - self.n_obj + 1) + contrib.sum(axis=1)[:, None]
40
+
41
+ def g3(self, X):
42
+ j = np.arange(self.n_obj - 1, self.n_var) + 1
43
+ contrib = (X[:, self.n_obj - 1:] - np.cos(0.25 * j / self.n_var * np.pi * (X[:, 0:1] + X[:, 1:2]))) ** 2
44
+ return contrib.sum(axis=1)[:, None]
45
+
46
+ def _calc_pareto_front(self, *args, **kwargs):
47
+ return Remote.get_instance().load("pymoo", "pf", "DASCMOP", f"{str(self.__class__.__name__).lower()}_{self.difficulty}.pf")
48
+
49
+
50
+ class DASCMOP1(DASCMOP):
51
+ def __init__(self, difficulty, **kwargs):
52
+ super().__init__(2, 11, difficulty)
53
+
54
+ def constraints(self, X, f0, f1, g):
55
+ a = 20.
56
+ b = 2. * self.eta - 1.
57
+ d = 0.5 if self.zeta != 0 else 0.
58
+ if self.zeta > 0:
59
+ e = d - np.log(self.zeta)
60
+ else:
61
+ e = 1e30
62
+ r = 0.5 * self.gamma
63
+
64
+ p_k = np.array([[0., 1.0, 0., 1.0, 2.0, 0., 1.0, 2.0, 3.0]])
65
+ q_k = np.array([[1.5, 0.5, 2.5, 1.5, 0.5, 3.5, 2.5, 1.5, 0.5]])
66
+
67
+ a_k2 = 0.3
68
+ b_k2 = 1.2
69
+ theta_k = -0.25 * np.pi
70
+
71
+ c = np.zeros((X.shape[0], 2 + p_k.shape[1]))
72
+
73
+ c[:, 0] = np.sin(a * np.pi * X[:, 0]) - b
74
+ if self.zeta == 1.:
75
+ c[:, 1:2] = 1e-4 - np.abs(e - g)
76
+ else:
77
+ c[:, 1:2] = (e - g) * (g - d)
78
+
79
+ c[:, 2:] = (((f0 - p_k) * np.cos(theta_k) - (f1 - q_k) * np.sin(theta_k)) ** 2 / a_k2
80
+ + ((f0 - p_k) * np.sin(theta_k) + (f1 - q_k) * np.cos(theta_k)) ** 2 / b_k2
81
+ - r)
82
+
83
+ return -1 * c
84
+
85
+ def _evaluate(self, X, out, *args, **kwargs):
86
+ g = self.g1(X)
87
+
88
+ f0 = X[:, 0:1] + g
89
+ f1 = 1.0 - X[:, 0:1] ** 2 + g
90
+
91
+ out["F"] = np.column_stack([f0, f1])
92
+ out["G"] = self.constraints(X, f0, f1, g)
93
+
94
+
95
+ class DASCMOP2(DASCMOP1):
96
+ def _evaluate(self, X, out, *args, **kwargs):
97
+ g = self.g1(X)
98
+
99
+ f0 = X[:, 0:1] + g
100
+ f1 = 1.0 - np.sqrt(X[:, 0:1]) + g
101
+
102
+ out["F"] = np.column_stack([f0, f1])
103
+ out["G"] = self.constraints(X, f0, f1, g)
104
+
105
+
106
+ class DASCMOP3(DASCMOP1):
107
+ def _evaluate(self, X, out, *args, **kwargs):
108
+ g = self.g1(X)
109
+
110
+ f0 = X[:, 0:1] + g
111
+ f1 = 1.0 - np.sqrt(X[:, 0:1]) + 0.5 * np.abs(np.sin(5 * np.pi * X[:, 0:1])) + g
112
+
113
+ out["F"] = np.column_stack([f0, f1])
114
+ out["G"] = self.constraints(X, f0, f1, g)
115
+
116
+
117
+ class DASCMOP4(DASCMOP1):
118
+ def _evaluate(self, X, out, *args, **kwargs):
119
+ g = self.g2(X)
120
+
121
+ f0 = X[:, 0:1] + g
122
+ f1 = 1.0 - X[:, 0:1] ** 2 + g
123
+
124
+ out["F"] = np.column_stack([f0, f1])
125
+ out["G"] = self.constraints(X, f0, f1, g)
126
+
127
+
128
+ class DASCMOP5(DASCMOP1):
129
+
130
+ def _evaluate(self, X, out, *args, **kwargs):
131
+ g = self.g2(X)
132
+
133
+ f0 = X[:, 0:1] + g
134
+ f1 = 1.0 - np.sqrt(X[:, 0:1]) + g
135
+
136
+ out["F"] = np.column_stack([f0, f1])
137
+ out["G"] = self.constraints(X, f0, f1, g)
138
+
139
+
140
+ class DASCMOP6(DASCMOP1):
141
+ def _evaluate(self, X, out, *args, **kwargs):
142
+ g = self.g2(X)
143
+
144
+ f0 = X[:, 0:1] + g
145
+ f1 = 1.0 - np.sqrt(X[:, 0:1]) + 0.5 * np.abs(np.sin(5 * np.pi * X[:, 0:1])) + g
146
+
147
+ out["F"] = np.column_stack([f0, f1])
148
+ out["G"] = self.constraints(X, f0, f1, g)
149
+
150
+
151
+ class DASCMOP7(DASCMOP):
152
+
153
+ def __init__(self, difficulty_factors, **kwargs):
154
+ super().__init__(3, 7, difficulty_factors)
155
+
156
+ def constraints(self, X, f0, f1, f2, g):
157
+ a = 20.
158
+ b = 2. * self.eta - 1.
159
+ d = 0.5 if self.zeta != 0 else 0
160
+ if self.zeta > 0:
161
+ e = d - np.log(self.zeta)
162
+ else:
163
+ e = 1e30
164
+ r = 0.5 * self.gamma
165
+
166
+ x_k = np.array([[1.0, 0., 0., 1.0 / np.sqrt(3.0)]])
167
+ y_k = np.array([[0., 1.0, 0., 1.0 / np.sqrt(3.0)]])
168
+ z_k = np.array([[0., 0., 1.0, 1.0 / np.sqrt(3.0)]])
169
+
170
+ c = np.zeros((X.shape[0], 3 + x_k.shape[1]))
171
+
172
+ c[:, 0] = np.sin(a * np.pi * X[:, 0]) - b
173
+ c[:, 1] = np.cos(a * np.pi * X[:, 1]) - b
174
+ if self.zeta == 1:
175
+ c[:, 2:3] = 1e-4 - np.abs(e - g)
176
+ else:
177
+ c[:, 2:3] = (e - g) * (g - d)
178
+
179
+ c[:, 3:] = (f0 - x_k) ** 2 + (f1 - y_k) ** 2 + (f2 - z_k) ** 2 - r ** 2
180
+ return -1 * c
181
+
182
+ def _evaluate(self, X, out, *args, **kwargs):
183
+ g = self.g2(X)
184
+
185
+ f0 = X[:, 0:1] * X[:, 1:2] + g
186
+ f1 = X[:, 1:2] * (1.0 - X[:, 0:1]) + g
187
+ f2 = 1 - X[:, 1:2] + g
188
+
189
+ out["F"] = np.column_stack([f0, f1, f2])
190
+ out["G"] = self.constraints(X, f0, f1, f2, g)
191
+
192
+
193
+ class DASCMOP8(DASCMOP7):
194
+
195
+ def objectives(self, X, g):
196
+ f0 = np.cos(0.5 * np.pi * X[:, 0:1]) * np.cos(0.5 * np.pi * X[:, 1:2]) + g
197
+ f1 = np.cos(0.5 * np.pi * X[:, 0:1]) * np.sin(0.5 * np.pi * X[:, 1:2]) + g
198
+ f2 = np.sin(0.5 * np.pi * X[:, 0:1]) + g
199
+ return np.column_stack([f0, f1, f2])
200
+
201
+ def _evaluate(self, X, out, *args, **kwargs):
202
+ g = self.g2(X)
203
+ F = self.objectives(X, g)
204
+ out["F"] = F
205
+ out["G"] = self.constraints(X, F[:, 0:1], F[:, 1:2], F[:, 2:3], g)
206
+
207
+
208
+ class DASCMOP9(DASCMOP8):
209
+ def _evaluate(self, X, out, *args, **kwargs):
210
+ g = self.g3(X)
211
+ F = self.objectives(X, g)
212
+ out["F"] = F
213
+ out["G"] = self.constraints(X, F[:, 0:1], F[:, 1:2], F[:, 2:3], g)
@@ -0,0 +1,25 @@
1
+ import pymoo.gradient.toolbox as anp
2
+
3
+ from pymoo.core.problem import Problem
4
+ from pymoo.util.remote import Remote
5
+
6
+
7
+ class Kursawe(Problem):
8
+ def __init__(self):
9
+ super().__init__(n_var=3, n_obj=2, xl=-5, xu=5, vtype=float)
10
+
11
+ def _evaluate(self, x, out, *args, **kwargs):
12
+ l = []
13
+ for i in range(2):
14
+ l.append(-10 * anp.exp(-0.2 * anp.sqrt(anp.square(x[:, i]) + anp.square(x[:, i + 1]))))
15
+ f1 = anp.sum(anp.column_stack(l), axis=1)
16
+
17
+ f2 = anp.sum(anp.power(anp.abs(x), 0.8) + 5 * anp.sin(anp.power(x, 3)), axis=1)
18
+
19
+ out["F"] = anp.column_stack([f1, f2])
20
+
21
+ def _calc_pareto_front(self, *args, **kwargs):
22
+ return Remote.get_instance().load("pymoo", "pf", "kursawe.pf")
23
+
24
+
25
+
@@ -0,0 +1,68 @@
1
+ import numpy as np
2
+
3
+ from pymoo.core.problem import ElementwiseProblem
4
+ from pymoo.util.remote import Remote
5
+
6
+
7
+ class MODAct(ElementwiseProblem):
8
+ """Multi-Objective Design of Actuators
9
+
10
+ MODAct is a framework for real-world constrained multi-objective optimization.
11
+ Refer to the python package https://github.com/epfl-lamd/modact from requirements.
12
+
13
+ Best-known Pareto fronts must be downloaded from here: https://doi.org/10.5281/zenodo.3824302
14
+
15
+ Parameters
16
+ ----------
17
+
18
+ function: str or modact.problems
19
+ The name of the benchmark problem to use either as a string or the
20
+ problem object instance. Example values: cs1, cs3, ct2, ct4, cts3
21
+
22
+ References:
23
+ ----------
24
+ C. Picard and J. Schiffmann, “Realistic Constrained Multi-Objective Optimization Benchmark Problems from Design,”
25
+ IEEE Transactions on Evolutionary Computation, pp. 1–1, 2020.
26
+ """
27
+
28
+ def __init__(self, function, pf=None, **kwargs):
29
+
30
+ self.function = function
31
+ self.pf = pf
32
+
33
+ try:
34
+ import modact.problems as pb
35
+ except:
36
+ raise Exception("Please install the modact library: https://github.com/epfl-lamd/modact")
37
+
38
+ if isinstance(function, pb.Problem):
39
+ self.fct = function
40
+ else:
41
+ self.fct = pb.get_problem(function)
42
+
43
+ lb, ub = self.fct.bounds()
44
+ n_var = len(lb)
45
+ n_obj = len(self.fct.weights)
46
+ n_ieq_constr = len(self.fct.c_weights)
47
+ xl = lb
48
+ xu = ub
49
+
50
+ self.weights = np.array(self.fct.weights)
51
+ self.c_weights = np.array(self.fct.c_weights)
52
+
53
+ super().__init__(n_var=n_var, n_obj=n_obj, n_ieq_constr=n_ieq_constr, xl=xl, xu=xu, vtype=float, **kwargs)
54
+
55
+ def _evaluate(self, x, out, *args, **kwargs):
56
+ f, g = self.fct(x)
57
+ out["F"] = np.array(f) * -1 * self.weights
58
+ out["G"] = np.array(g) * self.c_weights
59
+
60
+ def _calc_pareto_front(self, *args, **kwargs):
61
+ # allows to provide a custom pf - because of the size of files published by the author
62
+ if self.pf is None:
63
+ pf = Remote.get_instance().load("pymoo", "pf", "MODACT", f"{self.function}.pf")
64
+ # pf = pf * [1, -1]
65
+ pf = pf * self.weights * -1
66
+ return pf
67
+ else:
68
+ return self.pf