pydmoo 0.0.11__py3-none-any.whl → 0.0.12__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.
@@ -0,0 +1,680 @@
1
+ from math import floor
2
+
3
+ import numpy as np
4
+ from pymoo.util.remote import Remote
5
+ from scipy.spatial.distance import cdist
6
+
7
+ from pydmoo.problems.dyn import DynamicTestProblem
8
+ from pydmoo.problems.dynamic.df import get_PF
9
+
10
+
11
+ def knee_point(F):
12
+ ideal_point = np.min(F, axis=0)
13
+ distances = cdist(F, [ideal_point])
14
+ knee_idx = np.argmax(distances)
15
+ return F[knee_idx]
16
+
17
+
18
+ def G_t(t):
19
+ """G(t) = sin(0.5πt)"""
20
+ return np.sin(0.5 * np.pi * t)
21
+
22
+
23
+ def H_t(t):
24
+ """H(t) = 1.5 + G(t)"""
25
+ return 1.5 + G_t(t)
26
+
27
+
28
+ def alpha_t(t):
29
+ """αt = 5cos(0.5πt)"""
30
+ return 5 * np.cos(0.5 * np.pi * t)
31
+
32
+
33
+ def beta_t(t):
34
+ """βt = 0.2 + 2.8|G(t)|"""
35
+ return 0.2 + 2.8 * np.abs(G_t(t))
36
+
37
+
38
+ def omega_t(t):
39
+ """ωt = ⌊10G(t)⌋"""
40
+ return np.floor(10 * G_t(t))
41
+
42
+
43
+ def a_t(t):
44
+ """a = sin(0.5πt)"""
45
+ return np.sin(0.5 * np.pi * t)
46
+
47
+
48
+ def b_t(t):
49
+ """b = 1 + |cos(0.5πt)|"""
50
+ return 1 + np.abs(np.cos(0.5 * np.pi * t))
51
+
52
+
53
+ def y_t(x1, t):
54
+ """y = 0.5 + G(t)(x1 - 0.5)"""
55
+ return 0.5 + G_t(t) * (x1 - 0.5)
56
+
57
+
58
+ def p_t(t):
59
+ """pt = ⌊6G(t)⌋"""
60
+ return np.floor(6 * G_t(t))
61
+
62
+
63
+ class GTS(DynamicTestProblem):
64
+
65
+ def __init__(self,
66
+ part_idx,
67
+ bounds,
68
+ R_case="one",
69
+ add_time_perturbation=True,
70
+ n_var=10,
71
+ nt=10,
72
+ taut=20,
73
+ **kwargs):
74
+ super().__init__(nt,
75
+ taut,
76
+ add_time_perturbation=add_time_perturbation,
77
+ n_var=n_var,
78
+ n_obj=2,
79
+ xl=0,
80
+ xu=1,
81
+ **kwargs)
82
+
83
+ self.time_linkage = 1
84
+
85
+ self.sub_vec_1, self.sub_vec_2, self.sub_vec_3 = self._partition_dimension(part_idx)
86
+
87
+ # positive semidefinite matrices
88
+ if R_case == "one":
89
+ self.R_2 = np.eye(len(self.sub_vec_2))
90
+ self.R_3 = np.eye(len(self.sub_vec_3))
91
+ elif R_case == "two":
92
+ self.R_2 = np.diag([i + 1 for i in range(len(self.sub_vec_2))])
93
+ self.R_3 = np.diag([i + 1 for i in range(len(self.sub_vec_3))])
94
+ elif R_case == "three":
95
+ diag_matrix = np.diag(len(self.sub_vec_2) + np.arange(len(self.sub_vec_2)))
96
+ ones_matrix = np.ones((len(self.sub_vec_2), len(self.sub_vec_2)))
97
+ self.R_2 = np.where(np.eye(len(self.sub_vec_2), dtype=bool), diag_matrix, ones_matrix)
98
+
99
+ diag_matrix = np.diag(len(self.sub_vec_3) + np.arange(len(self.sub_vec_3)))
100
+ ones_matrix = np.ones((len(self.sub_vec_3), len(self.sub_vec_3)))
101
+ self.R_3 = np.where(np.eye(len(self.sub_vec_3), dtype=bool), diag_matrix, ones_matrix)
102
+ else:
103
+ raise ValueError(f"{R_case} must be `one`, `two` or `three`.")
104
+
105
+ # norm
106
+ self.p = 1
107
+
108
+ self.xl[self.sub_vec_1] = bounds[0][0]
109
+ self.xu[self.sub_vec_1] = bounds[0][1]
110
+ self.xl[self.sub_vec_2] = bounds[1][0]
111
+ self.xu[self.sub_vec_2] = bounds[1][1]
112
+ self.xl[self.sub_vec_3] = bounds[2][0]
113
+ self.xu[self.sub_vec_3] = bounds[2][1]
114
+
115
+ def _calc_pareto_front(self, *args, **kwargs):
116
+ return Remote.get_instance().load("pydmoo", "pf", "GTS", f"{str(self.__class__.__name__)}.pf")
117
+
118
+ def _calc_pareto_set(self, *args, **kwargs):
119
+ return Remote.get_instance().load("pydmoo", "ps", "GTS", f"{str(self.__class__.__name__)}.ps")
120
+
121
+ # Designed to handle time-linkage properties within the GTS test suites.
122
+ def cal(self, F):
123
+ self.time_linkage = 1 + np.linalg.norm(knee_point(self.pareto_front()) - knee_point(F))
124
+
125
+ def _partition_dimension(self, part_idx):
126
+ fd = floor(self.n_var / 2)
127
+ sub_vec_1 = range(0, part_idx)
128
+ sub_vec_2 = range(part_idx, fd + (part_idx - 1))
129
+ sub_vec_3 = range(fd + (part_idx - 1), self.n_var)
130
+ return sub_vec_1, sub_vec_2, sub_vec_3
131
+
132
+
133
+ class GTS1(GTS):
134
+ def __init__(self, **kwargs):
135
+ super().__init__(part_idx=1, bounds=((0, 1), (-1, 1), (-1, 2)), **kwargs)
136
+
137
+ def _evaluate(self, x, out, *args, **kwargs):
138
+ xi = np.cos(0.5 * np.pi * self.time)
139
+ xj = G_t(self.time) + np.power(x[:, 0], H_t(self.time))
140
+
141
+ x2, x3 = (x[:, self.sub_vec_2] - xi.reshape(-1, 1)), (x[:, self.sub_vec_3] - xj.reshape(-1, 1))
142
+
143
+ # quadratic form
144
+ diag_x2_R2_x2T = np.einsum('ij,jk,ik->i', x2, self.R_2, x2)
145
+ diag_x3_R3_x3T = np.einsum('ij,jk,ik->i', x3, self.R_3, x3)
146
+ g = 1 + np.power(diag_x2_R2_x2T, self.p) + np.power(diag_x3_R3_x3T, self.p)
147
+
148
+ f1 = x[:, 0]
149
+ f2 = g * (1 - np.power(x[:, 0] / g, H_t(self.time)))
150
+
151
+ out["F"] = np.column_stack([f1, f2])
152
+
153
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
154
+ x = np.linspace(0, 1, n_pareto_points)
155
+ f1 = x
156
+ f2 = 1 - np.power(x, H_t(self.time))
157
+ return np.array([f1, f2]).T
158
+
159
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
160
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
161
+ x_vec2 = np.full(len(x_vec1), np.cos(0.5 * np.pi * self.time))
162
+ x_vec3 = G_t(self.time) + np.power(x_vec1, H_t(self.time))
163
+ X, Y, Z = x_vec1, x_vec2, x_vec3
164
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
165
+
166
+
167
+ class GTS2(GTS):
168
+ def __init__(self, **kwargs):
169
+ super().__init__(part_idx=2, bounds=((0, 1), (0, 1), (-1, 2)), **kwargs)
170
+
171
+ def _evaluate(self, x, out, *args, **kwargs):
172
+ t = 3 * np.pi * self.time ** 2
173
+ cot = np.cos(t) / (np.sin(t) + (np.sin(t) == 0) * 1e-32)
174
+
175
+ xi = (1 / np.pi) * np.abs(np.arctan(cot))
176
+ xj = G_t(self.time) + np.power(x[:, 0], H_t(self.time))
177
+
178
+ x2, x3 = (x[:, self.sub_vec_2] - xi.reshape(-1, 1)), (x[:, self.sub_vec_3] - xj.reshape(-1, 1))
179
+
180
+ # quadratic form
181
+ diag_x2_R2_x2T = np.einsum('ij,jk,ik->i', x2, self.R_2, x2)
182
+ diag_x3_R3_x3T = np.einsum('ij,jk,ik->i', x3, self.R_3, x3)
183
+ g = 1 + np.power(diag_x2_R2_x2T, self.p) + np.power(diag_x3_R3_x3T, self.p)
184
+
185
+ f1 = 0.5 * x[:, 0] + x[:, 1]
186
+ f2 = g * (2.8 - np.power(f1 / g, H_t(self.time)))
187
+
188
+ out["F"] = np.column_stack([f1, f2])
189
+
190
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
191
+ H = 20
192
+ x1, x2 = np.meshgrid(np.linspace(0, 1, H), np.linspace(0, 1, H), indexing='xy')
193
+
194
+ f1 = 0.5 * x1 + x2
195
+ f2 = 2.8 - np.power(f1, H_t(self.time))
196
+ return get_PF(np.array([f1, f2]), False)
197
+
198
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
199
+ t = 3 * np.pi * self.time ** 2
200
+ cot = np.cos(t) / (np.sin(t) + (np.sin(t) == 0) * 1e-32)
201
+
202
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
203
+ x_vec2 = np.full(len(x_vec1), (1 / np.pi) * np.abs(np.arctan(cot)))
204
+ x_vec3 = G_t(self.time) + np.power(x_vec1, H_t(self.time))
205
+ X, Y, Z = x_vec1, x_vec2, x_vec3
206
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
207
+
208
+
209
+ class GTS3(GTS):
210
+ def __init__(self, **kwargs):
211
+ super().__init__(part_idx=1, bounds=((0, 1), (-1, 1), (-1, 2)), **kwargs)
212
+
213
+ def _evaluate(self, x, out, *args, **kwargs):
214
+ xi = (G_t(self.time) * np.sin(4 * np.pi * x[:, 0])) / (1 + np.abs(G_t(self.time)))
215
+ xj = G_t(self.time) + np.power(x[:, 0], H_t(self.time))
216
+
217
+ x2, x3 = (x[:, self.sub_vec_2] - xi.reshape(-1, 1)), (x[:, self.sub_vec_3] - xj.reshape(-1, 1))
218
+
219
+ # quadratic form
220
+ diag_x2_R2_x2T = np.einsum('ij,jk,ik->i', x2, self.R_2, x2)
221
+ diag_x3_R3_x3T = np.einsum('ij,jk,ik->i', x3, self.R_3, x3)
222
+ g = 1 + np.power(diag_x2_R2_x2T, self.p) + np.power(diag_x3_R3_x3T, self.p)
223
+
224
+ f1 = g * np.power(x[:, 0] + 0.1 * np.sin(3 * np.pi * x[:, 0]), beta_t(self.time))
225
+ f2 = g * np.power(1 - x[:, 0] + 0.1 * np.sin(3 * np.pi * x[:, 0]), beta_t(self.time))
226
+
227
+ out["F"] = np.column_stack([f1, f2])
228
+
229
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
230
+ x = np.linspace(0, 1, n_pareto_points)
231
+ f1 = np.power(x + 0.1 * np.sin(3 * np.pi * x), beta_t(self.time))
232
+ f2 = np.power(1 - x + 0.1 * np.sin(3 * np.pi * x), beta_t(self.time))
233
+
234
+ return get_PF(np.array([f1, f2]), True)
235
+
236
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
237
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
238
+ x_vec2 = (G_t(self.time) * np.sin(4 * np.pi * x_vec1)) / (1 + np.abs(G_t(self.time)))
239
+ x_vec3 = G_t(self.time) + np.power(x_vec1, H_t(self.time))
240
+ X, Y, Z = x_vec1, x_vec2, x_vec3
241
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
242
+
243
+
244
+ class GTS4(GTS):
245
+ def __init__(self, **kwargs):
246
+ super().__init__(part_idx=1, bounds=((0, 1), (0, 1), (-1, 1)), **kwargs)
247
+
248
+ def _evaluate(self, x, out, *args, **kwargs):
249
+ xi = np.abs(G_t(self.time))
250
+ xj = (G_t(self.time) * np.sin(4 * np.pi * x[:, 0])) / (1 + np.abs(G_t(self.time)))
251
+
252
+ x2, x3 = (x[:, self.sub_vec_2] - xi.reshape(-1, 1)), (x[:, self.sub_vec_3] - xj.reshape(-1, 1))
253
+
254
+ # quadratic form
255
+ diag_x2_R2_x2T = np.einsum('ij,jk,ik->i', x2, self.R_2, x2)
256
+ diag_x3_R3_x3T = np.einsum('ij,jk,ik->i', x3, self.R_3, x3)
257
+ g = 1 + np.power(diag_x2_R2_x2T, self.p) + np.power(diag_x3_R3_x3T, self.p)
258
+
259
+ g += (-0.5 + 0.25 * np.sin(0.3 * np.pi * self.time))
260
+
261
+ f1 = g * ((1 + self.time) / (x[:, 0] + 3))
262
+ f2 = g * ((x[:, 0] + 3) / (1 + self.time))
263
+
264
+ out["F"] = np.column_stack([f1, f2])
265
+
266
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
267
+ x = np.linspace(0, 1, n_pareto_points)
268
+ g = 1 + (-0.5 + 0.25 * np.sin(0.3 * np.pi * self.time))
269
+
270
+ f1 = g * ((1 + self.time) / (x + 3))
271
+ f2 = g * ((x + 3) / (1 + self.time))
272
+
273
+ return np.array([f1, f2]).T
274
+
275
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
276
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
277
+ x_vec2 = np.full(len(x_vec1), np.abs(G_t(self.time)))
278
+ x_vec3 = (G_t(self.time) * np.sin(4 * np.pi * x_vec1)) / (1 + np.abs(G_t(self.time)))
279
+ X, Y, Z = x_vec1, x_vec2, x_vec3
280
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
281
+
282
+
283
+ class GTS5(GTS):
284
+ def __init__(self, **kwargs):
285
+ super().__init__(part_idx=2, bounds=((0, 1), (-1, 1), (-1, 2)), **kwargs)
286
+
287
+ def _evaluate(self, x, out, *args, **kwargs):
288
+ xi = np.cos(0.5 * np.pi * self.time)
289
+ xj = G_t(self.time) + np.power(x[:, 0], H_t(self.time))
290
+
291
+ x2, x3 = (x[:, self.sub_vec_2] - xi.reshape(-1, 1)), (x[:, self.sub_vec_3] - xj.reshape(-1, 1))
292
+
293
+ # quadratic form
294
+ diag_x2_R2_x2T = np.einsum('ij,jk,ik->i', x2, self.R_2, x2)
295
+ diag_x3_R3_x3T = np.einsum('ij,jk,ik->i', x3, self.R_3, x3)
296
+ g = 1 + np.power(diag_x2_R2_x2T, self.p) + np.power(diag_x3_R3_x3T, self.p)
297
+
298
+ g += 0.5 + 0.5 * G_t(self.time)
299
+
300
+ x12 = 0.5 * x[:, 0] + x[:, 1]
301
+ _sin = 0.02 * np.sin(omega_t(self.time) * np.pi * x12)
302
+ f1 = g * (x12 + _sin)
303
+ f2 = g * (1.6 - x12 + _sin)
304
+
305
+ out["F"] = np.column_stack([f1, f2])
306
+
307
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
308
+ H = 20
309
+ x1, x2 = np.meshgrid(np.linspace(0, 1, H), np.linspace(0, 1, H), indexing='xy')
310
+ g = 1 + 0.5 + 0.5 * G_t(self.time)
311
+
312
+ x12 = 0.5 * x1 + x2
313
+ _sin = 0.02 * np.sin(omega_t(self.time) * np.pi * x12)
314
+ f1 = g * (x12 + _sin)
315
+ f2 = g * (1.6 - x12 + _sin)
316
+
317
+ return get_PF(np.array([f1, f2]), True)
318
+
319
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
320
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
321
+ x_vec2 = np.full(len(x_vec1), np.cos(0.5 * np.pi * self.time))
322
+ x_vec3 = G_t(self.time) + np.power(x_vec1, H_t(self.time))
323
+ X, Y, Z = x_vec1, x_vec2, x_vec3
324
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
325
+
326
+
327
+ class GTS6(GTS):
328
+ def __init__(self, **kwargs):
329
+ super().__init__(part_idx=1, bounds=((0, 1), (-1, 1), (-1, 2)), **kwargs)
330
+
331
+ def _evaluate(self, x, out, *args, **kwargs):
332
+ xi = self.time_linkage * np.cos(0.5 * np.pi * self.time)
333
+ xj = self.time_linkage * (G_t(self.time) + np.power(x[:, 0], H_t(self.time)))
334
+
335
+ x2, x3 = (x[:, self.sub_vec_2] - xi.reshape(-1, 1)), (x[:, self.sub_vec_3] - xj.reshape(-1, 1))
336
+
337
+ # quadratic form
338
+ diag_x2_R2_x2T = np.einsum('ij,jk,ik->i', x2, self.R_2, x2)
339
+ diag_x3_R3_x3T = np.einsum('ij,jk,ik->i', x3, self.R_3, x3)
340
+ g = 1 + np.power(diag_x2_R2_x2T, self.p) + np.power(diag_x3_R3_x3T, self.p)
341
+
342
+ f1 = x[:, 0]
343
+ f2 = g * (1 - np.power(f1 / g, H_t(self.time)))
344
+
345
+ out["F"] = np.column_stack([f1, f2])
346
+
347
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
348
+ f1 = np.linspace(0, 1, n_pareto_points)
349
+ f2 = 1 - np.power(f1, H_t(self.time))
350
+ return np.array([f1, f2]).T
351
+
352
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
353
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
354
+ x_vec2 = np.full(len(x_vec1), np.cos(0.5 * np.pi * self.time))
355
+ x_vec3 = G_t(self.time) + np.power(x_vec1, H_t(self.time))
356
+ X, Y, Z = x_vec1, x_vec2, x_vec3
357
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
358
+
359
+
360
+ class GTS7(GTS):
361
+ def __init__(self, **kwargs):
362
+ super().__init__(part_idx=1, bounds=((-1, 2.5), (-1, 1), (0, 1)), **kwargs)
363
+
364
+ def _evaluate(self, x, out, *args, **kwargs):
365
+ xi = self.time_linkage * np.cos(0.5 * np.pi * self.time)
366
+ xj = self.time_linkage * 1 / (1 + np.exp(alpha_t(self.time) * (x[:, 0] - 0.5)))
367
+
368
+ x2, x3 = (x[:, self.sub_vec_2] - xi.reshape(-1, 1)), (x[:, self.sub_vec_3] - xj.reshape(-1, 1))
369
+
370
+ # quadratic form
371
+ diag_x2_R2_x2T = np.einsum('ij,jk,ik->i', x2, self.R_2, x2)
372
+ diag_x3_R3_x3T = np.einsum('ij,jk,ik->i', x3, self.R_3, x3)
373
+ g = 1 + np.power(diag_x2_R2_x2T, self.p) + np.power(diag_x3_R3_x3T, self.p)
374
+
375
+ f1 = g * np.power(np.abs(x[:, 0] - a_t(self.time)), H_t(self.time))
376
+ f2 = g * np.power(np.abs(x[:, 0] - a_t(self.time) - b_t(self.time)), H_t(self.time))
377
+
378
+ out["F"] = np.column_stack([f1, f2])
379
+
380
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
381
+ x = np.linspace(a_t(self.time), a_t(self.time) + b_t(self.time), n_pareto_points)
382
+
383
+ f1 = np.power(np.abs(x - a_t(self.time)), H_t(self.time))
384
+ f2 = np.power(np.abs(x - a_t(self.time) - b_t(self.time)), H_t(self.time))
385
+
386
+ return np.array([f1, f2]).T
387
+
388
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
389
+ x_vec1 = np.linspace(a_t(self.time), a_t(self.time) + b_t(self.time), n_pareto_points)
390
+ x_vec2 = np.full(len(x_vec1), np.cos(0.5 * np.pi * self.time))
391
+ x_vec3 = 1 / (1 + np.exp(alpha_t(self.time) * (x_vec1 - 0.5)))
392
+ X, Y, Z = x_vec1, x_vec2, x_vec3
393
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
394
+
395
+
396
+ class GTS8(GTS):
397
+ def __init__(self, **kwargs):
398
+ super().__init__(part_idx=2, bounds=((0, 1), (0, 1), (-1, 2)), **kwargs)
399
+
400
+ def _evaluate(self, x, out, *args, **kwargs):
401
+ xi = self.time_linkage * 1 / (1 + np.exp(alpha_t(self.time) * (x[:, 0] - 0.5)))
402
+ xj = self.time_linkage * (G_t(self.time) + np.power(x[:, 0], H_t(self.time)))
403
+
404
+ x2, x3 = (x[:, self.sub_vec_2] - xi.reshape(-1, 1)), (x[:, self.sub_vec_3] - xj.reshape(-1, 1))
405
+
406
+ # quadratic form
407
+ diag_x2_R2_x2T = np.einsum('ij,jk,ik->i', x2, self.R_2, x2)
408
+ diag_x3_R3_x3T = np.einsum('ij,jk,ik->i', x3, self.R_3, x3)
409
+ g = 1 + np.power(diag_x2_R2_x2T, self.p) + np.power(diag_x3_R3_x3T, self.p)
410
+
411
+ g += 0.25 * np.abs(np.cos(0.3 * np.pi * self.time))
412
+
413
+ f1 = 0.5 * x[:, 0] + x[:, 1]
414
+ f2 = g * (2.8 - np.power(f1 / g, H_t(self.time)))
415
+
416
+ out["F"] = np.column_stack([f1, f2])
417
+
418
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
419
+ H = 20
420
+ x1, x2 = np.meshgrid(np.linspace(0, 1, H), np.linspace(0, 1, H), indexing='xy')
421
+
422
+ f1 = 0.5 * x1 + x2
423
+ g = 1 + 0.25 * np.abs(np.cos(0.3 * np.pi * self.time))
424
+ f2 = g * (2.8 - np.power(f1 / g, H_t(self.time)))
425
+ return get_PF(np.array([f1, f2]), False)
426
+
427
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
428
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
429
+ x_vec2 = 1 / (1 + np.exp(alpha_t(self.time) * (x_vec1 - 0.5)))
430
+ x_vec3 = G_t(self.time) + np.power(x_vec1, H_t(self.time))
431
+ X, Y, Z = x_vec1, x_vec2, x_vec3
432
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
433
+
434
+
435
+ # modified DF12
436
+ class GTS9(GTS):
437
+ def __init__(self, **kwargs):
438
+ super().__init__(part_idx=2, bounds=((0, 1), (0, 1), (-1, 1)), **kwargs)
439
+ self.n_obj = 3
440
+
441
+ def _evaluate(self, x, out, *args, **kwargs):
442
+ xi = 1 / (1 + np.exp(alpha_t(self.time) * (x[:, 0] - 0.5)))
443
+ xj = np.sin(self.time * x[:, 0])
444
+
445
+ x2, x3 = (x[:, self.sub_vec_2] - xi.reshape(-1, 1)), (x[:, self.sub_vec_3] - xj.reshape(-1, 1))
446
+
447
+ # quadratic form
448
+ diag_x2_R2_x2T = np.einsum('ij,jk,ik->i', x2, self.R_2, x2)
449
+ diag_x3_R3_x3T = np.einsum('ij,jk,ik->i', x3, self.R_3, x3)
450
+ g = 1 + np.power(diag_x2_R2_x2T, self.p) + np.power(diag_x3_R3_x3T, self.p)
451
+
452
+ g += np.abs(np.cos(0.27 * np.pi * self.time))
453
+
454
+ f1 = g * np.cos(0.5 * np.pi * x[:, 1]) * np.cos(0.5 * np.pi * x[:, 0])
455
+ f2 = g * np.sin(0.5 * np.pi * x[:, 1]) * np.cos(0.5 * np.pi * x[:, 0])
456
+ f3 = g * np.sin(0.5 * np.pi * x[:, 0])
457
+
458
+ out["F"] = np.column_stack([f1, f2, f3])
459
+
460
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
461
+ H = 20
462
+ x1, x2 = np.meshgrid(np.linspace(0, 1, H), np.linspace(0, 1, H), indexing='xy')
463
+
464
+ g = 1
465
+ g += np.abs(np.cos(0.27 * np.pi * self.time))
466
+
467
+ f1 = np.multiply(np.multiply(g, np.cos(0.5 * np.pi * x2)), np.cos(0.5 * np.pi * x1))
468
+ f2 = np.multiply(np.multiply(g, np.sin(0.5 * np.pi * x2)), np.cos(0.5 * np.pi * x1))
469
+ f3 = np.multiply(g, np.sin(0.5 * np.pi * x1))
470
+
471
+ return get_PF(np.array([f1, f2, f3]), True)
472
+
473
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
474
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
475
+ x_vec2 = 1 / (1 + np.exp(alpha_t(self.time) * (x_vec1 - 0.5)))
476
+ x_vec3 = np.sin(self.time * x_vec1)
477
+ X, Y, Z = x_vec1, x_vec2, x_vec3
478
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
479
+
480
+
481
+ # modified DF13
482
+ class GTS10(GTS):
483
+ def __init__(self, **kwargs):
484
+ super().__init__(part_idx=2, bounds=((0, 1), (0, 1), (-1, 1)), **kwargs)
485
+ self.n_obj = 3
486
+
487
+ def _evaluate(self, x, out, *args, **kwargs):
488
+ xi = np.abs(G_t(self.time))
489
+ xj = -0.5 + np.abs(G_t(self.time) * np.sin(4 * np.pi * x[:, 1])) / (0.5 * (1 + np.abs(G_t(self.time))))
490
+
491
+ x2, x3 = (x[:, self.sub_vec_2] - xi.reshape(-1, 1)), (x[:, self.sub_vec_3] - xj.reshape(-1, 1))
492
+
493
+ # quadratic form
494
+ diag_x2_R2_x2T = np.einsum('ij,jk,ik->i', x2, self.R_2, x2)
495
+ diag_x3_R3_x3T = np.einsum('ij,jk,ik->i', x3, self.R_3, x3)
496
+ g = 1 + np.power(diag_x2_R2_x2T, self.p) + np.power(diag_x3_R3_x3T, self.p)
497
+
498
+ f1 = g * np.cos(0.5 * np.pi * x[:, 0]) ** 2
499
+ f2 = g * np.cos(0.5 * np.pi * x[:, 1]) ** 2
500
+
501
+ _sin1 = np.sin(0.5 * np.pi * x[:, 0])
502
+ _sin2 = np.sin(0.5 * np.pi * x[:, 1])
503
+ _cos1 = np.cos(p_t(self.time) * np.pi * x[:, 0])
504
+ _cos2 = np.cos(p_t(self.time) * np.pi * x[:, 1])
505
+ f3 = g * (_sin1 ** 2 + _sin1 * _cos1 ** 2 + _sin2 ** 2 + _sin2 * _cos2 ** 2)
506
+
507
+ out["F"] = np.column_stack([f1, f2, f3])
508
+
509
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
510
+ H = 20
511
+ x1, x2 = np.meshgrid(np.linspace(0, 1, H), np.linspace(0, 1, H), indexing='xy')
512
+ G = np.sin(0.5 * np.pi * self.time)
513
+ p = np.floor(6 * G)
514
+
515
+ f1 = np.cos(0.5 * np.pi * x1) ** 2
516
+ f2 = np.cos(0.5 * np.pi * x2) ** 2
517
+ f3 = np.sin(0.5 * np.pi * x1) ** 2 + np.sin(0.5 * np.pi * x1) * np.cos(p * np.pi * x1) ** 2 + np.sin(
518
+ 0.5 * np.pi * x2) ** 2 + np.sin(0.5 * np.pi * x2) * np.cos(p * np.pi * x2) ** 2
519
+
520
+ return get_PF(np.array([f1, f2, f3]), True)
521
+
522
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
523
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
524
+ x_vec2 = np.full(len(x_vec1), np.abs(G_t(self.time)))
525
+ x_vec3 = -0.5 + np.abs(G_t(self.time) * np.sin(4 * np.pi * x_vec1)) / (0.5 * (1 + np.abs(G_t(self.time))))
526
+ X, Y, Z = x_vec1, x_vec2, x_vec3
527
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
528
+
529
+
530
+ # modified DF14
531
+ class GTS11(GTS):
532
+ def __init__(self, **kwargs):
533
+ super().__init__(part_idx=2, bounds=((0, 1), (0, 1), (-1, 2)), **kwargs)
534
+ self.n_obj = 3
535
+
536
+ def _evaluate(self, x, out, *args, **kwargs):
537
+ xi = np.abs(G_t(self.time))
538
+ xj = G_t(self.time) + np.power(x[:, 0], H_t(self.time))
539
+
540
+ x2, x3 = (x[:, self.sub_vec_2] - xi.reshape(-1, 1)), (x[:, self.sub_vec_3] - xj.reshape(-1, 1))
541
+
542
+ # quadratic form
543
+ diag_x2_R2_x2T = np.einsum('ij,jk,ik->i', x2, self.R_2, x2)
544
+ diag_x3_R3_x3T = np.einsum('ij,jk,ik->i', x3, self.R_3, x3)
545
+ g = 1 + np.power(diag_x2_R2_x2T, self.p) + np.power(diag_x3_R3_x3T, self.p)
546
+
547
+ y = y_t(x[:, 0], self.time)
548
+ f1 = g * (1.05 - y + 0.05 * np.sin(6 * np.pi * y))
549
+ f2 = g * (1.05 - x[:, 1] + 0.05 * np.sin(6 * np.pi * x[:, 1])) * (y + 0.05 * np.sin(6 * np.pi * y))
550
+ f3 = g * (x[:, 1] + 0.05 * np.sin(6 * np.pi * x[:, 1])) * (y + 0.05 * np.sin(6 * np.pi * y))
551
+
552
+ out["F"] = np.column_stack([f1, f2, f3])
553
+
554
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
555
+ H = 20
556
+ x1, x2 = np.meshgrid(np.linspace(0, 1, H), np.linspace(0, 1, H), indexing='xy')
557
+
558
+ y = y_t(x1, self.time)
559
+ f1 = 1.05 - y + 0.05 * np.sin(6 * np.pi * y)
560
+ f2 = np.multiply(1.05 - x2 + 0.05 * np.sin(6 * np.pi * x2), y + 0.05 * np.sin(6 * np.pi * y))
561
+ f3 = np.multiply(x2 + 0.05 * np.sin(6 * np.pi * x2), y + 0.05 * np.sin(6 * np.pi * y))
562
+
563
+ return get_PF(np.array([f1, f2, f3]), False)
564
+
565
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
566
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
567
+ x_vec2 = np.full(len(x_vec1), np.abs(G_t(self.time)))
568
+ x_vec3 = G_t(self.time) + np.power(x_vec1, H_t(self.time))
569
+ X, Y, Z = x_vec1, x_vec2, x_vec3
570
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
571
+
572
+
573
+ class GTS1_2(GTS1):
574
+ def __init__(self, R_case="two", **kwargs):
575
+ super().__init__(R_case=R_case, **kwargs)
576
+
577
+
578
+ class GTS2_2(GTS1):
579
+ def __init__(self, R_case="two", **kwargs):
580
+ super().__init__(R_case=R_case, **kwargs)
581
+
582
+
583
+ class GTS3_2(GTS1):
584
+ def __init__(self, R_case="two", **kwargs):
585
+ super().__init__(R_case=R_case, **kwargs)
586
+
587
+
588
+ class GTS4_2(GTS1):
589
+ def __init__(self, R_case="two", **kwargs):
590
+ super().__init__(R_case=R_case, **kwargs)
591
+
592
+
593
+ class GTS5_2(GTS1):
594
+ def __init__(self, R_case="two", **kwargs):
595
+ super().__init__(R_case=R_case, **kwargs)
596
+
597
+
598
+ class GTS6_2(GTS1):
599
+ def __init__(self, R_case="two", **kwargs):
600
+ super().__init__(R_case=R_case, **kwargs)
601
+
602
+
603
+ class GTS7_2(GTS1):
604
+ def __init__(self, R_case="two", **kwargs):
605
+ super().__init__(R_case=R_case, **kwargs)
606
+
607
+
608
+ class GTS8_2(GTS1):
609
+ def __init__(self, R_case="two", **kwargs):
610
+ super().__init__(R_case=R_case, **kwargs)
611
+
612
+
613
+ class GTS9_2(GTS1):
614
+ def __init__(self, R_case="two", **kwargs):
615
+ super().__init__(R_case=R_case, **kwargs)
616
+
617
+
618
+ class GTS10_2(GTS1):
619
+ def __init__(self, R_case="two", **kwargs):
620
+ super().__init__(R_case=R_case, **kwargs)
621
+
622
+
623
+ class GTS11_2(GTS1):
624
+ def __init__(self, R_case="two", **kwargs):
625
+ super().__init__(R_case=R_case, **kwargs)
626
+
627
+
628
+ class GTS1_3(GTS1):
629
+ def __init__(self, R_case="three", **kwargs):
630
+ super().__init__(R_case=R_case, **kwargs)
631
+
632
+
633
+ class GTS2_3(GTS1):
634
+ def __init__(self, R_case="three", **kwargs):
635
+ super().__init__(R_case=R_case, **kwargs)
636
+
637
+
638
+ class GTS3_3(GTS1):
639
+ def __init__(self, R_case="three", **kwargs):
640
+ super().__init__(R_case=R_case, **kwargs)
641
+
642
+
643
+ class GTS4_3(GTS1):
644
+ def __init__(self, R_case="three", **kwargs):
645
+ super().__init__(R_case=R_case, **kwargs)
646
+
647
+
648
+ class GTS5_3(GTS1):
649
+ def __init__(self, R_case="three", **kwargs):
650
+ super().__init__(R_case=R_case, **kwargs)
651
+
652
+
653
+ class GTS6_3(GTS1):
654
+ def __init__(self, R_case="three", **kwargs):
655
+ super().__init__(R_case=R_case, **kwargs)
656
+
657
+
658
+ class GTS7_3(GTS1):
659
+ def __init__(self, R_case="three", **kwargs):
660
+ super().__init__(R_case=R_case, **kwargs)
661
+
662
+
663
+ class GTS8_3(GTS1):
664
+ def __init__(self, R_case="three", **kwargs):
665
+ super().__init__(R_case=R_case, **kwargs)
666
+
667
+
668
+ class GTS9_3(GTS1):
669
+ def __init__(self, R_case="three", **kwargs):
670
+ super().__init__(R_case=R_case, **kwargs)
671
+
672
+
673
+ class GTS10_3(GTS1):
674
+ def __init__(self, R_case="three", **kwargs):
675
+ super().__init__(R_case=R_case, **kwargs)
676
+
677
+
678
+ class GTS11_3(GTS1):
679
+ def __init__(self, R_case="three", **kwargs):
680
+ super().__init__(R_case=R_case, **kwargs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pydmoo
3
- Version: 0.0.11
3
+ Version: 0.0.12
4
4
  Summary: pydmoo
5
5
  Project-URL: Homepage, https://github.com/dynoptimization/pydmoo
6
6
  Project-URL: Repository, https://github.com/dynoptimization/pydmoo