pyMachDM 0.1.0__py3-none-any.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 (84) hide show
  1. pymachdm/ANN_weights/1.Weld_Beam_MachineDM.joblib +0 -0
  2. pymachdm/ANN_weights/10.DTLZ7_MachineDM.joblib +0 -0
  3. pymachdm/ANN_weights/11.DTLZ7_MachineDM.joblib +0 -0
  4. pymachdm/ANN_weights/12.MW8_MachineDM.joblib +0 -0
  5. pymachdm/ANN_weights/13.MW8_MachineDM.joblib +0 -0
  6. pymachdm/ANN_weights/14.WAVY_3Obj_MachineDM.joblib +0 -0
  7. pymachdm/ANN_weights/15.FLOW_3Obj_MachineDM.joblib +0 -0
  8. pymachdm/ANN_weights/16.DPF4_MachineDM.joblib +0 -0
  9. pymachdm/ANN_weights/17.DPF4_MachineDM.joblib +0 -0
  10. pymachdm/ANN_weights/18.River_MachineDM.joblib +0 -0
  11. pymachdm/ANN_weights/19.River_MachineDM.joblib +0 -0
  12. pymachdm/ANN_weights/2.OSY_2Obj_MachineDM.joblib +0 -0
  13. pymachdm/ANN_weights/20.C2DTLZ2_MachineDM.joblib +0 -0
  14. pymachdm/ANN_weights/21.C2DTLZ2_MachineDM.joblib +0 -0
  15. pymachdm/ANN_weights/22.Knee_5Obj_MachineDM.joblib +0 -0
  16. pymachdm/ANN_weights/23.WATER_MachineDM.joblib +0 -0
  17. pymachdm/ANN_weights/24.WATER_MachineDM.joblib +0 -0
  18. pymachdm/ANN_weights/25.Clutch_MachineDM.joblib +0 -0
  19. pymachdm/ANN_weights/26.Clutch_MachineDM.joblib +0 -0
  20. pymachdm/ANN_weights/27.NIMBUS_MachineDM.joblib +0 -0
  21. pymachdm/ANN_weights/28.NIMBUS_MachineDM.joblib +0 -0
  22. pymachdm/ANN_weights/29.DTLZ2_8Obj_MachineDM.joblib +0 -0
  23. pymachdm/ANN_weights/3.ZDT2_2Obj_MachineDM.joblib +0 -0
  24. pymachdm/ANN_weights/30.GAA_10Obj_MachineDM.joblib +0 -0
  25. pymachdm/ANN_weights/4.Crash_MachineDM.joblib +0 -0
  26. pymachdm/ANN_weights/4.ZDT3_2Obj_MachineDM.joblib +0 -0
  27. pymachdm/ANN_weights/4a.ZDT3_2Obj_MachineDM.joblib +0 -0
  28. pymachdm/ANN_weights/5.WAVY_2Obj_MachineDM.joblib +0 -0
  29. pymachdm/ANN_weights/6.WAVY_2Obj_MachineDM.joblib +0 -0
  30. pymachdm/ANN_weights/7.Carside_MachineDM.joblib +0 -0
  31. pymachdm/ANN_weights/8.Carside_MachineDM.joblib +0 -0
  32. pymachdm/ANN_weights/9.FLOWER_3Obj_MachineDM.joblib +0 -0
  33. pymachdm/__init__.py +71 -0
  34. pymachdm/ann/__init__.py +16 -0
  35. pymachdm/ann/multioutput_class.py +115 -0
  36. pymachdm/ann/multioutput_reg.py +110 -0
  37. pymachdm/imcdm_methods/__init__.py +25 -0
  38. pymachdm/imcdm_methods/guess_start.py +46 -0
  39. pymachdm/imcdm_methods/guess_sub.py +49 -0
  40. pymachdm/imcdm_methods/mod_guess_start.py +47 -0
  41. pymachdm/imcdm_methods/mod_guess_sub.py +47 -0
  42. pymachdm/imcdm_methods/nimbus_inter.py +64 -0
  43. pymachdm/imcdm_methods/nimbus_start.py +48 -0
  44. pymachdm/imcdm_methods/nimbus_sub.py +56 -0
  45. pymachdm/imcdm_methods/stem_start.py +47 -0
  46. pymachdm/imcdm_methods/stem_sub.py +51 -0
  47. pymachdm/imcdm_methods/stom_start.py +46 -0
  48. pymachdm/imcdm_methods/stom_sub.py +47 -0
  49. pymachdm/machdm_imcdm/__init__.py +4 -0
  50. pymachdm/machdm_imcdm/machdm_all.py +771 -0
  51. pymachdm/machdm_imcdm/machine_dm.py +124 -0
  52. pymachdm/pareto/__init__.py +3 -0
  53. pymachdm/pareto/pareto_analyser.py +162 -0
  54. pymachdm/plots/__init__.py +7 -0
  55. pymachdm/plots/plot_2d_scatter.py +57 -0
  56. pymachdm/plots/plot_3d_scatter.py +91 -0
  57. pymachdm/plots/plot_pcp.py +93 -0
  58. pymachdm/plots/plot_radviz.py +496 -0
  59. pymachdm/plots/plot_tsne.py +369 -0
  60. pymachdm/problems/__init__.py +4 -0
  61. pymachdm/problems/problem_factory.py +879 -0
  62. pymachdm/problems/symbolic_problem_factory.py +696 -0
  63. pymachdm/run_machdm.py +232 -0
  64. pymachdm/soo_aasf/__init__.py +7 -0
  65. pymachdm/soo_aasf/guess_asf.py +99 -0
  66. pymachdm/soo_aasf/mod_guess_asf.py +112 -0
  67. pymachdm/soo_aasf/nimbus_asf.py +104 -0
  68. pymachdm/soo_aasf/stem_asf.py +99 -0
  69. pymachdm/soo_aasf/stom_asf.py +81 -0
  70. pymachdm/utils/__init__.py +21 -0
  71. pymachdm/utils/auto_tradeoff_stom.py +34 -0
  72. pymachdm/utils/compute_lambda.py +71 -0
  73. pymachdm/utils/compute_lambda_with_g.py +85 -0
  74. pymachdm/utils/cos_sim.py +8 -0
  75. pymachdm/utils/generate_ref_dirs.py +6 -0
  76. pymachdm/utils/predict_best.py +45 -0
  77. pymachdm/utils/predict_best2.py +62 -0
  78. pymachdm/utils/predict_prob.py +67 -0
  79. pymachdm/utils/predict_rank.py +47 -0
  80. pymachdm-0.1.0.dist-info/LICENSE +21 -0
  81. pymachdm-0.1.0.dist-info/METADATA +223 -0
  82. pymachdm-0.1.0.dist-info/RECORD +84 -0
  83. pymachdm-0.1.0.dist-info/WHEEL +5 -0
  84. pymachdm-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,879 @@
1
+ # problem_factory.py
2
+ import numpy as np
3
+ import math as ma
4
+ from pymoo.core.problem import ElementwiseProblem
5
+
6
+
7
+ # --- Example Problems ---
8
+
9
+ # =======================================
10
+ # ========= OSY 2-Objective =============
11
+ # =======================================
12
+ class OSY_2Obj(ElementwiseProblem):
13
+
14
+ def __init__(self):
15
+ super().__init__(n_var=6,
16
+ n_obj=2,
17
+ n_ieq_constr=6,
18
+ xl=np.array([0, 0, 1,0,1,0]),
19
+ xu=np.array([10,10,5,6,5,10]))
20
+
21
+ def _evaluate(self, x, out, *args, **kwargs):
22
+
23
+ f1 = -(25*(x[0]-2)**2 + (x[1]-2)**2 + (x[2]-1)**2 + (x[3]-4)**2 + (x[4]-1)**2)
24
+ f2 = x[0]**2 + x[1]**2 + x[2]**2 + x[3]**2 + x[4]**2 + x[5]**2
25
+
26
+ g1 = (x[0] + x[1] -2)/2
27
+ g2 = (6 - x[0] - x[1])/6
28
+ g3 = (2- x[1] + x[0])/2
29
+ g4 = (2- x[0] + 3*x[1])/2
30
+ g5 = (4- (x[2]-3)**2 - x[3])/4
31
+ g6 = ((x[4]-3)**2 + x[5] - 4)/4
32
+
33
+ out["F"] = [f1, f2]
34
+ out["G"] = [-g1, -g2, -g3, -g4, -g5, -g6]
35
+
36
+ # =======================================
37
+ # ======== WAVY 2-Objective =============
38
+ # =======================================
39
+ class WAVY_2Obj(ElementwiseProblem):
40
+
41
+ def __init__(self):
42
+ super().__init__(n_var=5,
43
+ n_obj=2,
44
+ n_ieq_constr=0,
45
+ xl=np.zeros(5),
46
+ xu=np.ones(5))
47
+
48
+ def _evaluate(self, x, out, *args, **kwargs):
49
+
50
+ g = 10*((x[1]-0.5)**2 + (x[2]-0.5)**2 + (x[3]-0.5)**2 + (x[4]-0.5)**2)
51
+ f1 = (1+g)*x[0]
52
+ f2 = (1+g)*(1- (x[0]**0.5 + 0.115*np.sin(1.75*ma.pi*x[0])))
53
+
54
+ out["F"] = [f1, f2]
55
+
56
+
57
+ class ZDT2_POW(ElementwiseProblem):
58
+
59
+ def __init__(self):
60
+ # n_var=5 as requested, though ZDT2 traditionally uses 30
61
+ super().__init__(n_var=5,
62
+ n_obj=2,
63
+ n_ieq_constr=0,
64
+ xl=np.zeros(5),
65
+ xu=np.ones(5))
66
+
67
+ def _evaluate(self, x, out, *args, **kwargs):
68
+ # f1 is simply the first decision variable
69
+ f1 = x[0]
70
+
71
+ g = 1.0 + (9.0/4.0) * np.sum(x[1:])
72
+
73
+ # h function defines the non-convex (concave) shape
74
+ h = 1.0 - (f1 / g)**6
75
+
76
+ f2 = g * h
77
+
78
+ out["F"] = [f1, f2]
79
+
80
+ # =======================================
81
+ # ======== ZDT3 2-Objective =============
82
+ # =======================================
83
+ class ZDT3_Problem(ElementwiseProblem):
84
+
85
+ def __init__(self):
86
+ super().__init__(n_var=5,
87
+ n_obj=2,
88
+ n_ieq_constr=0,
89
+ xl=np.zeros(5),
90
+ xu=np.ones(5))
91
+
92
+ def _evaluate(self, x, out, *args, **kwargs):
93
+
94
+ f1 = x[0] # Objective 1
95
+ g = 1 + 9*(x[1]+x[2]+x[3]+x[4])/4
96
+ h = 1 - (f1/g)**0.5 - (f1/g)*np.sin(10*ma.pi*f1)
97
+ f2 = g*h # Objective 2
98
+
99
+ out["F"] = [f1, f2]
100
+
101
+ # ============================================
102
+ # ======== Welded Beam 2-Objective ===========
103
+ # ============================================
104
+
105
+ class Welded_Beam(ElementwiseProblem):
106
+
107
+ def __init__(self):
108
+ super().__init__(
109
+ n_var=4,
110
+ n_obj=2,
111
+ n_constr=4,
112
+ xl=np.array([0.125, 0.125, 0.1, 0.1]),
113
+ xu=np.array([5, 5, 10, 10])
114
+ )
115
+
116
+ def _evaluate(self, x, out, *args, **kwargs):
117
+
118
+ h=x[0]; b=x[1]; l=x[2]; t=x[3]
119
+ f1 = 1.10471 * h**2 * l + 0.04811 * t * b * (14 + l)
120
+ f2 = (2.1952 / (t**3 * b))
121
+
122
+ sigma = 504000 / (t**2 * b)
123
+ Pc = 64746.022 * (1 - 0.0282346 * t) * t * b**3
124
+ tau1 = 6000 / (np.sqrt(2) * h * l)
125
+ tau2 = (6000*(14+0.5*l)*np.sqrt(0.25*(l**2+(h + t)**2)))/(2*(0.707*h*l*((l**2/12)+0.25*(h+t)**2)))
126
+ tau = np.sqrt(tau1**2 + tau2**2 + (l * tau1 * tau2) / np.sqrt(0.25 * (l**2 + (h + t)**2)))
127
+
128
+ g1 = 13600 - tau
129
+ g2 = 30000 - sigma
130
+ g3 = b - h
131
+ g4 = Pc - 6000
132
+
133
+ out["F"] = [f1, f2]
134
+ out["G"] = [-g1, -g2, -g3, -g4]
135
+
136
+
137
+ # =======================================
138
+ # ======== Knee 2-Objective =============
139
+ # =======================================
140
+
141
+ class Knee_Problem(ElementwiseProblem):
142
+
143
+ def __init__(self):
144
+ super().__init__(n_var=5,
145
+ n_obj=2,
146
+ n_ieq_constr=0,
147
+ xl=np.array([0, 0, 0, 0, 0]),
148
+ xu=np.array([1, 1, 1, 1, 1]))
149
+
150
+ def _evaluate(self, x, out, *args, **kwargs):
151
+ K = 5
152
+ r = 5 +10*((x[0]-0.5)**2) + np.cos(2*K*ma.pi*x[0])/K
153
+ g = 1 + 9/4 * (x[1] + x[2] + x[3] + x[4])
154
+
155
+ f1 = g*r*np.sin(ma.pi*x[0]/2) # Objective 1
156
+ f2 = g*r*np.cos(ma.pi*x[0]/2) # Objective 2
157
+
158
+
159
+ out["F"] = [f1, f2]
160
+
161
+ # =======================================
162
+ # ======== WAVY 3-Objective =============
163
+ # =======================================
164
+ class WAVY_3Obj(ElementwiseProblem):
165
+
166
+ def __init__(self):
167
+ super().__init__(n_var=5,
168
+ n_obj=3,
169
+ n_ieq_constr=0,
170
+ xl=np.zeros(5),
171
+ xu=np.ones(5))
172
+
173
+ def _evaluate(self, x, out, *args, **kwargs):
174
+
175
+ g = 10*((x[2]-0.5)**2 + (x[3]-0.5)**2 + (x[4]-0.5)**2)
176
+ f1 = x[0]
177
+ f2 = x[1]
178
+ f3 = (1+g)*(2- (x[0]**0.5 + 0.115*np.sin(1.75*ma.pi*x[0])) - (x[1]**0.5 + 0.115*np.sin(1.75*ma.pi*x[1])))
179
+
180
+ out["F"] = [f1, f2, f3]
181
+
182
+
183
+ # =======================================
184
+ # ======== FLOWER 3-Objective =============
185
+ # =======================================
186
+
187
+ class FLOWER_3Obj(ElementwiseProblem):
188
+
189
+ def __init__(self):
190
+ super().__init__(n_var=2,
191
+ n_obj=3,
192
+ n_ieq_constr=0,
193
+ xl=np.array([0,0]),
194
+ xu=np.array([1.57,4.52]))
195
+
196
+ def _evaluate(self, x, out, *args, **kwargs):
197
+
198
+ g = np.exp(x[1]*(x[1]-5)) - 6*(np.sin(2*x[1]))/5 - 2*x[1] - 1
199
+ f1 = g*np.sin(x[0])/10
200
+ f2 = g*np.cos(x[0])/10
201
+ f3 = (x[1]**2)/20
202
+
203
+ out["F"] = [f1, f2, f3]
204
+
205
+ # =======================================
206
+ # ======== FLOW 3-Objective =============
207
+ # =======================================
208
+
209
+ class FLOW_3Obj(ElementwiseProblem):
210
+
211
+ def __init__(self):
212
+ super().__init__(n_var=5,
213
+ n_obj=3,
214
+ n_ieq_constr=1,
215
+ xl=np.zeros(5),
216
+ xu=np.ones(5))
217
+
218
+ def _evaluate(self, x, out, *args, **kwargs):
219
+
220
+ g = 10*((x[2]-0.5)**2 + (x[3]-0.5)**2 + (x[4]-0.5)**2)
221
+
222
+ f1 = x[0]
223
+ f2 = x[1]
224
+ f3 = (1 + g)*(1- (x[0] + x[1]) - 0.15*np.sin(2*ma.pi*(x[0] + x[1])))
225
+ g1 = x[0] + x[1] - 1
226
+
227
+ out["F"] = [f1, f2, f3]
228
+ out["G"] = [g1]
229
+
230
+ # =======================================
231
+ # ======== Knee 3-Objective =============
232
+ # =======================================
233
+
234
+ class Knee_Problem_3D(ElementwiseProblem):
235
+
236
+ def __init__(self):
237
+ super().__init__(n_var=5,
238
+ n_obj=3,
239
+ n_ieq_constr=0,
240
+ xl=np.array([0, 0, 0, 0, 0]),
241
+ xu=np.array([1, 1, 1, 1, 1]))
242
+
243
+ def _evaluate(self, x, out, *args, **kwargs):
244
+ K = 2
245
+ r1 = 5 +10*((x[0]-0.5)**2) + 2*np.cos(2*K*ma.pi*x[0])/K
246
+ r2 = 5 +10*((x[1]-0.5)**2) + 2*np.cos(2*K*ma.pi*x[1])/K
247
+ r = 0.5*(r1 + r2)
248
+ g = 1 + (9/4*(x[2] + x[3] + x[4]))
249
+
250
+ f1 = g*r*np.sin(ma.pi*x[0]/2)*np.sin(ma.pi*x[1]/2) # Objective 1
251
+ f2 = g*r*np.sin(ma.pi*x[0]/2)*np.cos(ma.pi*x[1]/2) # Objective 2
252
+ f3 = g*r*np.cos(ma.pi*x[0]/2) # Objective 3
253
+
254
+
255
+ out["F"] = [f1, f2, f3]
256
+
257
+
258
+ # ================================================
259
+ # ======== Crashworthiness 3-Objective ===========
260
+ # ================================================
261
+
262
+ class Crash_Worth(ElementwiseProblem):
263
+
264
+ def __init__(self):
265
+ super().__init__(n_var=5,
266
+ n_obj=3,
267
+ n_constr=0,
268
+ xl=np.array([1, 1, 1, 1, 1]),
269
+ xu=np.array([3, 3, 3, 3, 3]),
270
+ elementwise_evaluation=True)
271
+
272
+ def _evaluate(self, x, out, *args, **kwargs):
273
+ f1 = 1640.2823 + 2.3573285*x[0] + 2.3220035*x[1] + 4.5688768*x[2] + 7.7213633*x[3] + 4.4559504*x[4]
274
+ f2 = 6.5856 + 1.15*x[0] - 1.0427*x[1] + 0.9738*x[2] +0.8364*x[3]- 0.3695*x[0]*x[3] + 0.0861*x[0]*x[4] + 0.3628*x[1]*x[3] - 0.1106*(x[0]**2) - 0.3437*(x[2]**2) + 0.1764*(x[3]**2)
275
+
276
+ f3 = -0.0551 + 0.0181*x[0] + 0.1024*x[1] + 0.0421*x[2] - 0.0073*x[0]*x[1] + 0.024*x[1]*x[2] - 0.0118*x[1]*x[3] - 0.0204*x[2]*x[3] - 0.008*x[2]*x[4] - 0.0241*(x[1]**2) + 0.0109*(x[3]**2)
277
+
278
+
279
+ out["F"] = [f1, f2, f3]
280
+
281
+
282
+ # ========================================
283
+ # ======== Carside 3-Objective ===========
284
+ # ========================================
285
+
286
+ class Car_Side(ElementwiseProblem):
287
+
288
+ def __init__(self):
289
+ super().__init__(
290
+ n_var=7,
291
+ n_obj=3,
292
+ n_constr=10,
293
+ xl=np.array([0.5, 0.45, 0.5, 0.5, 0.875, 0.4, 0.4]),
294
+ xu=np.array([1.5, 1.35, 1.5, 1.5, 2.625, 1.2, 1.2])
295
+ )
296
+
297
+ def _evaluate(self, x, out, *args, **kwargs):
298
+ # Objective functions
299
+ f1 = 1.98 + 4.9*x[0] + 6.67*x[1] + 6.98*x[2] + 4.01*x[3] + 1.78*x[4] + 1e-5*x[5] + 2.73*x[6]
300
+ f2 = 4.72 - 0.5*x[3] - 0.19*x[1]*x[2]
301
+ V_MBP = 10.58 - 0.674*x[0]*x[1] - 0.67275*x[1]
302
+ V_FD = 16.45 - 0.489*x[2]*x[6] - 0.843*x[4]*x[5]
303
+ f3 = 0.5 * V_MBP * V_FD
304
+
305
+ # Constraint functions
306
+ g1 = 1 - 1.16 + 0.3717*x[1]*x[3] + 0.0092928*x[2]
307
+ g2 = 0.32 - 0.261 + 0.0159*x[0]*x[1] + 0.06486*x[0] + 0.019*x[1]*x[6] - 0.0144*x[2]*x[4] - 0.0154464*x[5]
308
+ g3 = 0.32 - 0.214 - 0.00817*x[4] + 0.045195*x[0] + 0.0135168*x[0] - 0.03099*x[1]*x[5] + 0.018*x[1]*x[6] - 0.007176*x[2] - 0.023232*x[2] + 0.00364*x[4]*x[5] + 0.018*x[1]**2
309
+ g4 = 0.32 - 0.74 + 0.61*x[1] + 0.031296*x[2] + 0.031872*x[6] - 0.227*x[1]**2
310
+ g5 = 32 - 28.98 - 3.818*x[2] + 4.2*x[0]*x[1] - 1.27296*x[5] + 2.68065*x[6]
311
+ g6 = 32 - 33.86 - 2.95*x[2] + 5.057*x[0]*x[1] + 3.795*x[1] + 3.4431*x[6] - 1.45728
312
+ g7 = 32 - 46.36 + 9.9*x[1] + 4.4505*x[0]
313
+ g8 = 4 - (4.72 - 0.5*x[3] - 0.19*x[1]*x[2])
314
+ g9 = 9.9 - (10.58 - 0.674*x[0]*x[1] - 0.67275*x[1])
315
+ g10 = 15.7 - (16.45 - 0.489*x[2]*x[6] - 0.843*x[4]*x[5])
316
+
317
+ # Set the objectives and constraints in the output dictionary
318
+ out["F"] = [f1, f2, f3]
319
+ out["G"] = [-g1, -g2, -g3, -g4, -g5, -g6, -g7, -g8, -g9, -g10]
320
+
321
+ # ======================================
322
+ # ======== C2-DTLZ-2 3-Objective =======
323
+ # ======================================
324
+ class C2DTLZ2(ElementwiseProblem):
325
+
326
+ def __init__(self):
327
+ super().__init__(n_var=10,
328
+ n_obj=3,
329
+ n_constr=1,
330
+ xl=np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
331
+ xu=np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))
332
+
333
+ def _evaluate(self, x, out, *args, **kwargs):
334
+ G = np.sum((x[2:10]-0.5)**2)
335
+ f1 = (1+G)*np.cos(ma.pi*x[0]/2)*np.cos(ma.pi*x[1]/2)
336
+ f2 = (1+G)*np.cos(ma.pi*x[0]/2)*np.sin(ma.pi*x[1]/2)
337
+ f3 = (1+G)*np.sin(ma.pi*x[0]/2)
338
+
339
+ g1 = min(min((f1-1)**2 + f2**2 + f3**2 -0.4**2 ,f1**2 + (f2-1)**2 + f3**2 - 0.4**2,
340
+ f1**2 + f2**2 - 0.4**2 + (f3-1)**2) ,(f1-1/(np.sqrt(3)))**2 + (f2-1/(np.sqrt(3)))**2+
341
+ (f3-1/(np.sqrt(3)))**2 - 0.16)
342
+
343
+ out["F"] = [f1, f2, f3]
344
+ out["G"] = [g1]
345
+
346
+ # ======================================
347
+ # =========== MW-8 3-Objective =========
348
+ # ======================================
349
+ class MW8_Problem(ElementwiseProblem):
350
+
351
+ def __init__(self, n_var=15):
352
+ # MW8 is standard with 3 objectives and 1 inequality constraint
353
+ super().__init__(n_var=n_var,
354
+ n_obj=3,
355
+ n_ieq_constr=1,
356
+ xl=np.zeros(n_var),
357
+ xu=np.ones(n_var))
358
+
359
+ def _evaluate(self, x, out, *args, **kwargs):
360
+ # 1. Distance function (g)
361
+ # Standard MW 'g' calculation using decision variables from index 2 onwards
362
+ z = 1 - np.exp(-10.0 * (x[2:] - 0.5)**2)
363
+ g = 1.0 + np.sum(0.1 * z**2 + 1.5 - 1.5 * np.cos(2 * np.pi * z))
364
+
365
+ # 2. Objective functions (Spherical Mapping)
366
+ # Uses x[0] and x[1] to determine position on the 3D surface
367
+ f1 = g * np.cos(0.5 * np.pi * x[0]) * np.cos(0.5 * np.pi * x[1])
368
+ f2 = g * np.cos(0.5 * np.pi * x[0]) * np.sin(0.5 * np.pi * x[1])
369
+ f3 = g * np.sin(0.5 * np.pi * x[0])
370
+
371
+ # 3. Constraint (MW8 Discontinuity)
372
+ # Calculates the elevation angle to determine feasibility
373
+ radius = np.sqrt(f1**2 + f2**2 + f3**2)
374
+ theta = np.arcsin(f3 / radius)
375
+
376
+ # The 'LA2' logic: A * sin(B * theta^C)^D
377
+ # In MW8: 0.5 * sin(6.0 * theta)^2
378
+ boundary = 1.25 - 0.5 * np.power(np.sin(6.0 * theta), 2.0)
379
+
380
+ # g0 <= 0 is feasible
381
+ g1 = radius**2 - boundary**2
382
+
383
+ out["F"] = [f1, f2, f3]
384
+ out["G"] = [g1]
385
+
386
+
387
+ # ================================================
388
+ # ======== DTLZ7 Problem 3-Objective =========
389
+ # ================================================
390
+ class DTLZ7(ElementwiseProblem):
391
+
392
+ def __init__(self):
393
+ super().__init__(n_var=5,
394
+ n_obj=3,
395
+ n_constr=0,
396
+ xl=np.zeros(5),
397
+ xu=np.ones(5))
398
+
399
+ def _evaluate(self, x, out, *args, **kwargs):
400
+
401
+ # f1 and f2
402
+ f1 = x[0]
403
+ f2 = x[1]
404
+
405
+ # g(x3...x5)
406
+ g = 1 + (9.0 / (5 - 2)) * np.sum(x[2:])
407
+
408
+ # h term
409
+ h = 3 - (f1 / (1 + g)) * (1 + np.sin(3 * np.pi * f1)) - (f2 / (1 + g)) * (1 + np.sin(3 * np.pi * f2))
410
+
411
+ # f3
412
+ f3 = (1 + g) * h
413
+
414
+ out["F"] = np.array([f1, f2, f3])
415
+
416
+ # ======================================
417
+ # ======== DPF4 4-Objective ===========
418
+ # ======================================
419
+
420
+ class DPF4_Example(ElementwiseProblem):
421
+
422
+ def __init__(self):
423
+ super().__init__(n_var=2,
424
+ n_obj=4,
425
+ n_constr=1,
426
+ xl=np.array([50, 50]),
427
+ xu=np.array([150, 150]))
428
+
429
+ def _evaluate(self, x, out, *args, **kwargs):
430
+ f1 = ((x[0]-50)**2 + (x[1]-50)**2)**0.5
431
+ f2 = ((x[0]-50)**2 + (x[1]-150)**2)**0.5
432
+ f3 = ((x[0]-150)**2 + (x[1]-50)**2)**0.5
433
+ f4 = ((x[0]-150)**2 + (x[1]-150)**2)**0.5
434
+ g1 = ((x[0]-100)**2 + (x[1]-100)**2)/400-1
435
+ g2 = 1-((x[0]-100)**2 + (x[1]-100)**2)/3025
436
+ out["F"] = [f1, f2, f3, f4];
437
+ out["G"] = [g2*g1]
438
+
439
+ # ======================================
440
+ # ======== River 4-Objective ===========
441
+ # ======================================
442
+
443
+ class River(ElementwiseProblem):
444
+
445
+ def __init__(self):
446
+ super().__init__(n_var=2,
447
+ n_obj=4,
448
+ n_constr=0,
449
+ xl=np.array([0.3,0.3]),
450
+ xu=np.array([1.0,1.0]))
451
+
452
+ def _evaluate(self, x, out, *args, **kwargs):
453
+
454
+ f1 = -(4.07 + 2.27*x[0])
455
+ f2 = -(2.60 + 0.03*x[0] + 0.02*x[1] + 0.01/(1.39-x[0]**2) + 0.30/(1.39-x[1]**2))
456
+ f3 = -8.21 + 0.71/(1.09-x[0]**2)
457
+ f4 = -0.96 + 0.96/(1.09-x[1]**2)
458
+
459
+ out["F"] = [f1, f2, f3, f4]
460
+
461
+ # ======================================
462
+ # ======== C2-DTLZ-2 5-Objective =======
463
+ # ======================================
464
+ class C2DTLZ2_5Obj(ElementwiseProblem):
465
+
466
+ def __init__(self):
467
+ super().__init__(n_var=10,
468
+ n_obj=5,
469
+ n_constr=1,
470
+ xl=np.zeros(10),
471
+ xu=np.ones(10))
472
+
473
+ def _evaluate(self, x, out, *args, **kwargs):
474
+
475
+ # Distance term
476
+ G = np.sum((x[4:] - 0.5) ** 2)
477
+
478
+ # Objectives (DTLZ2, 5 objectives)
479
+ f1 = (1 + G) * np.cos(ma.pi * x[0] / 2) * np.cos(ma.pi * x[1] / 2) * np.cos(ma.pi * x[2] / 2) * np.cos(ma.pi * x[3] / 2)
480
+ f2 = (1 + G) * np.cos(ma.pi * x[0] / 2) * np.cos(ma.pi * x[1] / 2) * np.cos(ma.pi * x[2] / 2) * np.sin(ma.pi * x[3] / 2)
481
+ f3 = (1 + G) * np.cos(ma.pi * x[0] / 2) * np.cos(ma.pi * x[1] / 2) * np.sin(ma.pi * x[2] / 2)
482
+ f4 = (1 + G) * np.cos(ma.pi * x[0] / 2) * np.sin(ma.pi * x[1] / 2)
483
+ f5 = (1 + G) * np.sin(ma.pi * x[0] / 2)
484
+
485
+ # Constraint (spherical regions, C2-style)
486
+ g1 = min(
487
+ (f1 - 1)**2 + f2**2 + f3**2 + f4**2 + f5**2 - 0.4**2,
488
+ f1**2 + (f2 - 1)**2 + f3**2 + f4**2 + f5**2 - 0.4**2,
489
+ f1**2 + f2**2 + (f3 - 1)**2 + f4**2 + f5**2 - 0.4**2,
490
+ f1**2 + f2**2 + f3**2 + (f4 - 1)**2 + f5**2 - 0.4**2,
491
+ f1**2 + f2**2 + f3**2 + f4**2 + (f5 - 1)**2 - 0.4**2,
492
+ np.sum((np.array([f1, f2, f3, f4, f5]) - 1/np.sqrt(5))**2) - 0.16
493
+ )
494
+
495
+ out["F"] = [f1, f2, f3, f4, f5]
496
+ out["G"] = [g1]
497
+
498
+
499
+ # ====================================
500
+ # ======== Knee 5-Objective ==========
501
+ # ====================================
502
+
503
+ class Knee_5obj(ElementwiseProblem):
504
+
505
+ def __init__(self):
506
+ super().__init__(n_var=8,
507
+ n_obj=5,
508
+ n_ieq_constr=0,
509
+ xl=np.zeros(8),
510
+ xu=np.ones(8))
511
+
512
+ def _evaluate(self, x, out, *args, **kwargs):
513
+
514
+ K = 2
515
+
516
+ # Knee-inducing radius terms
517
+ r1 = 5 + 10 * (x[0] - 0.5) ** 2 + 2 * np.cos(2 * K * ma.pi * x[0]) / K
518
+ r2 = 5 + 10 * (x[1] - 0.5) ** 2 + 2 * np.cos(2 * K * ma.pi * x[1]) / K
519
+ r = 0.5 * (r1 + r2)
520
+
521
+ # Distance term
522
+ g = 1 + (9 / 6) * np.sum(x[4:])
523
+
524
+ # Objectives (5D hyperspherical knee)
525
+ f1 = g*r*np.sin(ma.pi * x[0] / 2) * np.sin(ma.pi * x[1] / 2) * np.sin(ma.pi * x[2] / 2) * np.sin(ma.pi * x[3] / 2)
526
+ f2 = g*r*np.sin(ma.pi * x[0] / 2) * np.sin(ma.pi * x[1] / 2) * np.sin(ma.pi * x[2] / 2) * np.cos(ma.pi * x[3] / 2)
527
+ f3 = g*r*np.sin(ma.pi * x[0] / 2) * np.sin(ma.pi * x[1] / 2) * np.cos(ma.pi * x[2] / 2)
528
+ f4 = g*r*np.sin(ma.pi * x[0] / 2) * np.cos(ma.pi * x[1] / 2)
529
+ f5 = g*r*np.cos(ma.pi * x[0] / 2)
530
+
531
+ out["F"] = [f1, f2, f3, f4, f5]
532
+
533
+ # ======================================
534
+ # ======== WATER 5-Objective ===========
535
+ # ======================================
536
+
537
+ class WATER(ElementwiseProblem):
538
+
539
+ def __init__(self):
540
+ super().__init__(n_var=3,
541
+ n_obj=5,
542
+ n_constr=7,
543
+ xl=np.array([0.01, 0.01, 0.01]),
544
+ xu=np.array([0.45, 0.1, 0.1]))
545
+
546
+ def _evaluate(self, x, out, *args, **kwargs):
547
+ x1, x2, x3 = x
548
+
549
+ # Objective functions
550
+ f1 = 106780.37 * (x2 + x3) + 61704.67
551
+ f2 = 3000 * x1
552
+ f3 = (305700 * 2289 * x2) / ((0.06 * 2289)**0.65)
553
+ f4 = 250 * 2289 * np.exp(-39.75 * x2 + 9.9 * x3 + 2.74)
554
+ f5 = 25 * ((1.39 / (x1 * x2)) + 4940 * x3 - 80)
555
+
556
+ # Constraints
557
+ g1 = 1 - (0.00139 / (x1 * x2) - 4.94 * x3 + 0.08)
558
+ g2 = 1 - (0.000306 / (x1 * x2) - 1.082 * x3 + 0.0986)
559
+ g3 = 50000 - (12.307 / (x1 * x2) - 49408.24 * x3 - 4051.02)
560
+ g4 = 16000 - (2.098 / (x1 * x2) - 8046.33 * x3 + 696.71)
561
+ g5 = 10000 - (2.138 / (x1 * x2) - 7883.39 * x3 + 705.04)
562
+ g6 = 2000 - 0.417 * (x1 * x2) - 1721.26 * x3 + 136.54
563
+ g7 = 550 - 0.164 * (x1 * x2) - 631.13 * x3 + 54.48
564
+
565
+ # Set objective and constraint values
566
+ out["F"] = np.array([f1, f2, f3, f4, f5])
567
+ out["G"] = np.array([-g1, -g2, -g3, -g4, -g5, -g6, -g7])
568
+
569
+
570
+ # =============================================
571
+ # ======== Clutch Brake 6-Objective ===========
572
+ # =============================================
573
+
574
+ class Clutch_Brake(ElementwiseProblem):
575
+ def __init__(self):
576
+ super().__init__(n_var=5,
577
+ n_obj=5,
578
+ n_constr=16,
579
+ xl=np.array([55, 75, 1.5, 300, 2]),
580
+ xu=np.array([80, 110, 3, 1000, 10]))
581
+
582
+ def _evaluate(self, x, out, *args, **kwargs):
583
+ x1 = x[0]; x2 = x[1]; x3 = x[2]; x4 = x[3]; x5 = x[4];
584
+ Jz = 55; rho = 0.0000078; Mf = 3; n = 250; mu = 0.5; Pmax = 10; Vmax= 2000; Tmax= 15; s = 1.5; Fmax = 1000;
585
+
586
+ omega = 3.14*n/30; Mh = (2/3)*(mu)*x4*x5*(x2**3 - x1**3)/(x2**2 - x1**2)
587
+ Rsr = (2/3)*(x2**3 - x1**3)/(x2**2 - x1**2)
588
+ S = 3.14*(x2**2 - x1**2); F = Mh/Rsr; Prz = x4/S; Vsr = 3.14*Rsr*n/30
589
+
590
+
591
+ f1 = 3.14*(x2**2 - x1**2)*x3*(x5 + 1)*rho
592
+ f2 = Jz*omega/(Mh+Mf)
593
+ f3 = x5
594
+ f4 = x2
595
+ f5 = x4
596
+
597
+ g1 = 55 - x1
598
+ g2 = x2 - 110
599
+ g3 = 20 - (x2 - x1)
600
+ g4 = 1.5 - x3
601
+ g5 = x3 - 3
602
+ g6 = (x5 + 1)*(x3 + 0.5) - 30
603
+ g7 = (x5 + 1)-10
604
+ g8 = 1 - x5
605
+ g9 = Prz - Pmax
606
+ g10= Prz*Vsr - Pmax*Vmax
607
+ g11= Vsr - Vmax
608
+ g12= f2 - Tmax
609
+ g13= -Mh*s*Mf
610
+ g14= -f2
611
+ g15= -x4
612
+ g16= x4-Fmax
613
+
614
+ out["F"] = [f1, f2, f3, f4, f5]
615
+ out["G"] = [g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11, g12, g13, g14, g15, g16]
616
+
617
+
618
+ # =======================================
619
+ # ======== NIMBUS 6-Objective ===========
620
+ # =======================================
621
+
622
+ class NIMBUS_Bench(ElementwiseProblem):
623
+
624
+ def __init__(self):
625
+ super().__init__(n_var=2,
626
+ n_obj=6,
627
+ n_constr=0,
628
+ xl=np.array([1,1]),
629
+ xu=np.array([3,3]))
630
+
631
+ def _evaluate(self, x, out, *args, **kwargs):
632
+
633
+ f1 = -(x[0]*x[1])
634
+ f2 = (x[0]-4)**2 + x[1]**2
635
+ f3 = -(x[0]+x[1])
636
+ f4 = x[0]-x[1]
637
+ f5 = 50*x[0]**4 + 10*x[1]**4
638
+ f6 = 30*(x[0]-5)**4 + 100*(x[1]-3)**4
639
+
640
+ out["F"] = [f1, f2, f3, f4, f5, f6]
641
+
642
+ # =======================================
643
+ # ======== DTLZ-2 8-Objective ===========
644
+ # =======================================
645
+
646
+ class DTLZ2_8obj(ElementwiseProblem):
647
+ def __init__(self):
648
+ super().__init__(n_var=10, n_obj=8, n_constr=0,
649
+ xl=np.zeros(10), xu=np.ones(10))
650
+
651
+ def _evaluate(self, x, out, *args, **kwargs):
652
+ a = (1 + (x[7]-0.5)**2 + (x[8]-0.5)**2 + (x[9]-0.5)**2)
653
+ f = []
654
+ f.append(a * np.cos((11*x[0])/7)*np.cos((11*x[1])/7)*np.cos((11*x[2])/7)*np.cos((11*x[3])/7)*np.cos((11*x[4])/7)
655
+ *np.cos((11*x[5])/7)*np.cos((11*x[6])/7))
656
+ f.append(a * np.cos((11*x[0])/7)*np.cos((11*x[1])/7)*np.cos((11*x[2])/7)*np.cos((11*x[3])/7)*np.cos((11*x[4])/7)
657
+ *np.cos((11*x[5])/7)*np.sin((11*x[6])/7))
658
+ f.append(a * np.cos((11*x[0])/7)*np.cos((11*x[1])/7)*np.cos((11*x[2])/7)*np.cos((11*x[3])/7)*np.cos((11*x[4])/7)
659
+ *np.sin((11*x[5])/7))
660
+ f.append(a * np.cos((11*x[0])/7)*np.cos((11*x[1])/7)*np.cos((11*x[2])/7)*np.cos((11*x[3])/7)*np.sin((11*x[4])/7))
661
+ f.append(a * np.cos((11*x[0])/7)*np.cos((11*x[1])/7)*np.cos((11*x[2])/7)*np.sin((11*x[3])/7))
662
+ f.append(a * np.cos((11*x[0])/7)*np.cos((11*x[1])/7)*np.sin((11*x[2])/7))
663
+ f.append(a * np.cos((11*x[0])/7)*np.sin((11*x[1])/7))
664
+ f.append(a * np.sin((11*x[0])/7))
665
+ out["F"] = np.array(f)
666
+
667
+ # ========================================
668
+ # ======== DTLZ-2 15-Objective ===========
669
+ # ========================================
670
+
671
+ class DTLZ2_15obj(ElementwiseProblem):
672
+
673
+ def __init__(self):
674
+ super().__init__(
675
+ n_var=24, # >= M-1 + g variables
676
+ n_obj=15,
677
+ n_constr=0,
678
+ xl=np.zeros(24),
679
+ xu=np.ones(24)
680
+ )
681
+
682
+ def _evaluate(self, x, out, *args, **kwargs):
683
+
684
+ # g-function (distance term)
685
+ g = 1 + np.sum((x[14:] - 0.5) ** 2)
686
+
687
+ # angular variables
688
+ theta = (11 * x[:14]) / 7.0
689
+
690
+ f = []
691
+
692
+ for i in range(15):
693
+ value = g
694
+ for j in range(14 - i):
695
+ value *= np.cos(theta[j])
696
+ if i > 0:
697
+ value *= np.sin(theta[14 - i])
698
+ f.append(value)
699
+
700
+ out["F"] = np.array(f)
701
+
702
+ import numpy as np
703
+ import math as ma
704
+ from pymoo.core.problem import ElementwiseProblem
705
+
706
+ # ======================================
707
+ # ======== C2-DTLZ-2 15-Objective ======
708
+ # ======================================
709
+ class C2DTLZ2_15Obj(ElementwiseProblem):
710
+
711
+ def __init__(self):
712
+ M = 15
713
+ k = 10
714
+ n_var = M + k - 1 # standard DTLZ setting
715
+
716
+ super().__init__(n_var=n_var,
717
+ n_obj=M,
718
+ n_constr=1,
719
+ xl=np.zeros(n_var),
720
+ xu=np.ones(n_var))
721
+
722
+ self.M = M
723
+
724
+ def _evaluate(self, x, out, *args, **kwargs):
725
+
726
+ M = self.M
727
+
728
+ # Distance term
729
+ G = np.sum((x[M-1:] - 0.5) ** 2)
730
+
731
+ # Objectives
732
+ F = np.zeros(M)
733
+
734
+ for i in range(M):
735
+ value = 1 + G
736
+
737
+ for j in range(M - i - 1):
738
+ value *= np.cos(ma.pi * x[j] / 2)
739
+
740
+ if i > 0:
741
+ value *= np.sin(ma.pi * x[M - i - 1] / 2)
742
+
743
+ F[i] = value
744
+
745
+ # Constraint (C2-style hyperspheres)
746
+ f = F
747
+
748
+ # Distance from each axis point (e_i)
749
+ c_vals = []
750
+ for i in range(M):
751
+ e = np.zeros(M)
752
+ e[i] = 1.0
753
+ c_vals.append(np.sum((f - e) ** 2) - 0.4**2)
754
+
755
+ # Central spherical constraint
756
+ center = np.ones(M) / np.sqrt(M)
757
+ c_center = np.sum((f - center) ** 2) - 0.16
758
+
759
+ g1 = min(c_vals + [c_center])
760
+
761
+ out["F"] = F
762
+ out["G"] = [g1]
763
+
764
+
765
+ # --- Factory Function ---
766
+
767
+ def get_Myproblem(name: str):
768
+ """
769
+ Returns a problem instance by name.
770
+ Add more problems as needed.
771
+ """
772
+ name = name.lower()
773
+
774
+ if name == "dtlz2_8obj":
775
+ return DTLZ2_8obj()
776
+
777
+ elif name == "osy_2obj":
778
+ return OSY_2Obj()
779
+
780
+ elif name =="zdt2_pow":
781
+ return ZDT2_POW()
782
+
783
+ elif name == "zdt3_example":
784
+ return ZDT3_Problem()
785
+
786
+ elif name == "wavy_2obj_1":
787
+ return WAVY_2Obj()
788
+
789
+ elif name == "wavy_2obj_2":
790
+ return WAVY_2Obj()
791
+
792
+ elif name == "wavy_3obj":
793
+ return WAVY_3Obj()
794
+
795
+ elif name == "flower_3obj":
796
+ return FLOWER_3Obj()
797
+
798
+ elif name == "flow_3obj":
799
+ return FLOW_3Obj()
800
+
801
+ elif name == "welded_beam":
802
+ return Welded_Beam()
803
+
804
+ elif name == "knee_example":
805
+ return Knee_Problem()
806
+
807
+ elif name == "knee_example_3d":
808
+ return Knee_Problem_3D()
809
+
810
+ elif name == "crash":
811
+ return Crash_Worth()
812
+
813
+ elif name == "carside_1":
814
+ return Car_Side()
815
+
816
+ elif name == "carside_2":
817
+ return Car_Side()
818
+
819
+ elif name == "c2dtlz2":
820
+ return C2DTLZ2()
821
+
822
+ elif name == "mw8_1":
823
+ return MW8_Problem()
824
+
825
+ elif name == "mw8_2":
826
+ return MW8_Problem()
827
+
828
+ elif name == "dtlz7_1":
829
+ return DTLZ7()
830
+
831
+ elif name == "dtlz7_2":
832
+ return DTLZ7()
833
+
834
+ elif name == "dpf4_ex1":
835
+ return DPF4_Example()
836
+
837
+ elif name == "dpf4_ex2":
838
+ return DPF4_Example()
839
+
840
+ elif name == "river_ex1":
841
+ return River()
842
+
843
+ elif name == "river_ex2":
844
+ return River()
845
+
846
+ elif name == "c2dtlz2_5obj_ex1":
847
+ return C2DTLZ2_5Obj()
848
+
849
+ elif name == "c2dtlz2_5obj_ex2":
850
+ return C2DTLZ2_5Obj()
851
+
852
+ elif name == "knee_5obj":
853
+ return Knee_5obj()
854
+
855
+ elif name == "water_ex1":
856
+ return WATER()
857
+
858
+ elif name == "water_ex2":
859
+ return WATER()
860
+
861
+ elif name == "clutch_ex1":
862
+ return Clutch_Brake()
863
+
864
+ elif name == "clutch_ex2":
865
+ return Clutch_Brake()
866
+
867
+ elif name == "nimbus_bench1":
868
+ return NIMBUS_Bench()
869
+
870
+ elif name == "nimbus_bench2":
871
+ return NIMBUS_Bench()
872
+
873
+ elif name == "dtlz2_15obj":
874
+ return DTLZ2_15obj()
875
+
876
+ elif name == "c2dtlz2_15obj":
877
+ return C2DTLZ2_15Obj()
878
+ else:
879
+ raise ValueError(f"Unknown problem name: {name}")