pydmoo 0.0.11__py3-none-any.whl → 0.0.13__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,754 @@
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\\pi 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
+ """\\( \\alpha_t = 5\\cos(0.5\\pi t) \\)"""
30
+ return 5 * np.cos(0.5 * np.pi * t)
31
+
32
+
33
+ def beta_t(t):
34
+ """\\( \\beta_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
+ """\\( \\omega_t = \\lfloor 10G(t) \\rfloor \\)"""
40
+ return np.floor(10 * G_t(t))
41
+
42
+
43
+ def a_t(t):
44
+ """\\( a(t) = \\sin(0.5\\pi t) \\)"""
45
+ return np.sin(0.5 * np.pi * t)
46
+
47
+
48
+ def b_t(t):
49
+ """\\( b(t) = 1 + |\\cos(0.5\\pi t)| \\)"""
50
+ return 1 + np.abs(np.cos(0.5 * np.pi * t))
51
+
52
+
53
+ def y_t(x1, t):
54
+ """\\( y_t(x_1) = 0.5 + G(t)(x_1 - 0.5) \\)"""
55
+ return 0.5 + G_t(t) * (x1 - 0.5)
56
+
57
+
58
+ def p_t(t):
59
+ """\\( p_t = \\lfloor 6G(t) \\rfloor \\)"""
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
+ r"""
135
+ \begin{equation}
136
+ \text{min}
137
+ \begin{cases}
138
+ f_1(\mathbf{x},t) = x_1 \\
139
+ f_2(\mathbf{x},t) = g(\mathbf{x},t)(1 - (\frac{x_1}{g(\mathbf{x},t)})^{H(t)})
140
+ \end{cases}
141
+ \end{equation}
142
+
143
+ with
144
+
145
+ \begin{equation*}
146
+ \begin{split}
147
+ g(\mathbf{x},t) = 1
148
+ &+ \Bigl(\bigl(\mathbf{x}_{II,1} - h_1(\mathbf{x}_I)\bigr)^T \mathbf{R}_{II,1}(t) \bigl(\mathbf{x}_{II,1} - h_1(\mathbf{x}_I)\bigr)\Bigr)^{\frac{1}{p}} \\
149
+ &+ \Bigl(\bigl(\mathbf{x}_{II,2} - h_2(\mathbf{x}_I)\bigr)^T \mathbf{R}_{II,2}(t) \bigl(\mathbf{x}_{II,2} - h_2(\mathbf{x}_I)\bigr)\Bigr)^{\frac{1}{p}}
150
+ \end{split}
151
+ \end{equation*}
152
+
153
+ where $p \geq 1$, $\mathbf{x}_I = (x_1)$, $\mathbf{x}_{II,1} = (x_2, \cdots, x_{\lfloor\frac{D}{2}\rfloor})$ and $\mathbf{x}_{II,2} = (x_{\lfloor\frac{D}{2}\rfloor + 1}, \cdots, x_D)$,
154
+ $h_1(\mathbf{x}_I, t) = \cos(0.5\pi t)$ and $h_2(\mathbf{x}_I, t) = G(t) + x_1^{H(t)}$,
155
+ $\mathbf{R}_{II,1}(t)$ and $\mathbf{R}_{II,2}(t)$ are symmetric positive semidefinite matrices in the $t$-th environment,
156
+ the search space is $[0,1] \times [-1,1]^{\lfloor\frac{D}{2}\rfloor -1} \times [-1, 2]^{\lceil\frac{D}{2}\rceil}$.
157
+
158
+ The PF and PS at time t can be described as:
159
+
160
+ \begin{equation*}
161
+ \begin{aligned}
162
+ & \text{PS(t): }0 \leq x_1 \leq 1, x_i = h_1(\mathbf{x}_I, t), x_i \in \mathbf{x}_{II,1}, x_j = h_2(\mathbf{x}_I, t), \in \mathbf{x}_{II,2} \\
163
+ & \text{PF(t): a part of }f_2 = 1 - f_1^{H(t)}, 0 \leq f_1 \leq 1
164
+ \end{aligned}
165
+ \end{equation*}
166
+
167
+ ![GTS1 PS](../figs/PS/GTS1.png)
168
+
169
+ ![GTS1 PF](../figs/PF/GTS1.png)
170
+ """
171
+ def __init__(self, **kwargs):
172
+ super().__init__(part_idx=1, bounds=((0, 1), (-1, 1), (-1, 2)), **kwargs)
173
+
174
+ def _evaluate(self, x, out, *args, **kwargs):
175
+ xi = np.cos(0.5 * np.pi * self.time)
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 = x[:, 0]
186
+ f2 = g * (1 - np.power(x[:, 0] / 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
+ x = np.linspace(0, 1, n_pareto_points)
192
+ f1 = x
193
+ f2 = 1 - np.power(x, H_t(self.time))
194
+ return np.array([f1, f2]).T
195
+
196
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
197
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
198
+ x_vec2 = np.full(len(x_vec1), np.cos(0.5 * np.pi * self.time))
199
+ x_vec3 = G_t(self.time) + np.power(x_vec1, H_t(self.time))
200
+ X, Y, Z = x_vec1, x_vec2, x_vec3
201
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
202
+
203
+
204
+ class GTS2(GTS):
205
+ r"""
206
+ \begin{equation}
207
+ \text{min}
208
+ \begin{cases}
209
+ f_1(\mathbf{x},t) = 0.5x_1+x_2 \\
210
+ f_2(\mathbf{x},t) = g(\mathbf{x},t)(2.8 - (\frac{0.5x_1+x_2}{g(\mathbf{x},t)})^{H(t)})
211
+ \end{cases}
212
+ \end{equation}
213
+
214
+ with
215
+
216
+ \begin{equation*}
217
+ \begin{split}
218
+ g(\mathbf{x},t) = 1
219
+ &+ \Bigl(\bigl(\mathbf{x}_{II,1} - h_1(\mathbf{x}_I)\bigr)^T \mathbf{R}_{II,1}(t) \bigl(\mathbf{x}_{II,1} - h_1(\mathbf{x}_I)\bigr)\Bigr)^{\frac{1}{p}} \\
220
+ &+ \Bigl(\bigl(\mathbf{x}_{II,2} - h_2(\mathbf{x}_I)\bigr)^T \mathbf{R}_{II,2}(t) \bigl(\mathbf{x}_{II,2} - h_2(\mathbf{x}_I)\bigr)\Bigr)^{\frac{1}{p}}
221
+ \end{split}
222
+ \end{equation*}
223
+
224
+ where $p \geq 1$, $\mathbf{x}_I = (x_1, x_2)$, $\mathbf{x}_{II,1} = (x_3, \cdots, x_{\lfloor\frac{D}{2}\rfloor + 1})$ and $\mathbf{x}_{II,2} = (x_{\lfloor\frac{D}{2}\rfloor + 2}, \cdots, x_D)$, $c = \cot(3\pi t^2), \text{when } t^2 \neq \frac{n}{3}, n \in \mathbb{Z}, c = 1e-32, \text{otherwise}$,
225
+ $h_1(\mathbf{x}_I, t) = \frac{1}{\pi}\left\vert{\arctan(c)}\right\vert$ and $h_2(\mathbf{x}_I, t) = G(t) + x_1^{H(t)}$,
226
+ $\mathbf{R}_{II,1}(t)$ and $\mathbf{R}_{II,2}(t)$ are symmetric positive semidefinite matrices in the $t$-th environment,
227
+ the search space is $[0,1]^2 \times [0,1]^{\lfloor\frac{D}{2}\rfloor -1} \times [-1, 2]^{\lceil\frac{D}{2}\rceil-1}$.
228
+
229
+ The PF and PS at time t can be described as:
230
+
231
+ \begin{equation*}
232
+ \begin{aligned}
233
+ & \text{PS(t): }0 \leq x_{1,2} \leq 1, x_i = h_1(\mathbf{x}_I, t), x_i \in \mathbf{x}_{II,1}, x_j = h_2(\mathbf{x}_I, t), \in \mathbf{x}_{II,2} \\
234
+ & \text{PF(t): }f_2 = 2.8 - f_1^{H(t)}, 0 \leq f_1 \leq 1.5
235
+ \end{aligned}
236
+ \end{equation*}
237
+
238
+ ![GTS2 PS](../figs/PS/GTS2.png)
239
+
240
+ ![GTS2 PF](../figs/PF/GTS2.png)
241
+ """
242
+ def __init__(self, **kwargs):
243
+ super().__init__(part_idx=2, bounds=((0, 1), (0, 1), (-1, 2)), **kwargs)
244
+
245
+ def _evaluate(self, x, out, *args, **kwargs):
246
+ t = 3 * np.pi * self.time ** 2
247
+ cot = np.cos(t) / (np.sin(t) + (np.sin(t) == 0) * 1e-32)
248
+
249
+ xi = (1 / np.pi) * np.abs(np.arctan(cot))
250
+ xj = G_t(self.time) + np.power(x[:, 0], H_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
+ f1 = 0.5 * x[:, 0] + x[:, 1]
260
+ f2 = g * (2.8 - np.power(f1 / g, H_t(self.time)))
261
+
262
+ out["F"] = np.column_stack([f1, f2])
263
+
264
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
265
+ H = 20
266
+ x1, x2 = np.meshgrid(np.linspace(0, 1, H), np.linspace(0, 1, H), indexing='xy')
267
+
268
+ f1 = 0.5 * x1 + x2
269
+ f2 = 2.8 - np.power(f1, H_t(self.time))
270
+ return get_PF(np.array([f1, f2]), False)
271
+
272
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
273
+ t = 3 * np.pi * self.time ** 2
274
+ cot = np.cos(t) / (np.sin(t) + (np.sin(t) == 0) * 1e-32)
275
+
276
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
277
+ x_vec2 = np.full(len(x_vec1), (1 / np.pi) * np.abs(np.arctan(cot)))
278
+ x_vec3 = G_t(self.time) + np.power(x_vec1, H_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 GTS3(GTS):
284
+ def __init__(self, **kwargs):
285
+ super().__init__(part_idx=1, bounds=((0, 1), (-1, 1), (-1, 2)), **kwargs)
286
+
287
+ def _evaluate(self, x, out, *args, **kwargs):
288
+ xi = (G_t(self.time) * np.sin(4 * np.pi * x[:, 0])) / (1 + np.abs(G_t(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
+ f1 = g * np.power(x[:, 0] + 0.1 * np.sin(3 * np.pi * x[:, 0]), beta_t(self.time))
299
+ f2 = g * np.power(1 - x[:, 0] + 0.1 * np.sin(3 * np.pi * x[:, 0]), beta_t(self.time))
300
+
301
+ out["F"] = np.column_stack([f1, f2])
302
+
303
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
304
+ x = np.linspace(0, 1, n_pareto_points)
305
+ f1 = np.power(x + 0.1 * np.sin(3 * np.pi * x), beta_t(self.time))
306
+ f2 = np.power(1 - x + 0.1 * np.sin(3 * np.pi * x), beta_t(self.time))
307
+
308
+ return get_PF(np.array([f1, f2]), True)
309
+
310
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
311
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
312
+ x_vec2 = (G_t(self.time) * np.sin(4 * np.pi * x_vec1)) / (1 + np.abs(G_t(self.time)))
313
+ x_vec3 = G_t(self.time) + np.power(x_vec1, H_t(self.time))
314
+ X, Y, Z = x_vec1, x_vec2, x_vec3
315
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
316
+
317
+
318
+ class GTS4(GTS):
319
+ def __init__(self, **kwargs):
320
+ super().__init__(part_idx=1, bounds=((0, 1), (0, 1), (-1, 1)), **kwargs)
321
+
322
+ def _evaluate(self, x, out, *args, **kwargs):
323
+ xi = np.abs(G_t(self.time))
324
+ xj = (G_t(self.time) * np.sin(4 * np.pi * x[:, 0])) / (1 + np.abs(G_t(self.time)))
325
+
326
+ x2, x3 = (x[:, self.sub_vec_2] - xi.reshape(-1, 1)), (x[:, self.sub_vec_3] - xj.reshape(-1, 1))
327
+
328
+ # quadratic form
329
+ diag_x2_R2_x2T = np.einsum('ij,jk,ik->i', x2, self.R_2, x2)
330
+ diag_x3_R3_x3T = np.einsum('ij,jk,ik->i', x3, self.R_3, x3)
331
+ g = 1 + np.power(diag_x2_R2_x2T, self.p) + np.power(diag_x3_R3_x3T, self.p)
332
+
333
+ g += (-0.5 + 0.25 * np.sin(0.3 * np.pi * self.time))
334
+
335
+ f1 = g * ((1 + self.time) / (x[:, 0] + 3))
336
+ f2 = g * ((x[:, 0] + 3) / (1 + self.time))
337
+
338
+ out["F"] = np.column_stack([f1, f2])
339
+
340
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
341
+ x = np.linspace(0, 1, n_pareto_points)
342
+ g = 1 + (-0.5 + 0.25 * np.sin(0.3 * np.pi * self.time))
343
+
344
+ f1 = g * ((1 + self.time) / (x + 3))
345
+ f2 = g * ((x + 3) / (1 + self.time))
346
+
347
+ return np.array([f1, f2]).T
348
+
349
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
350
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
351
+ x_vec2 = np.full(len(x_vec1), np.abs(G_t(self.time)))
352
+ x_vec3 = (G_t(self.time) * np.sin(4 * np.pi * x_vec1)) / (1 + np.abs(G_t(self.time)))
353
+ X, Y, Z = x_vec1, x_vec2, x_vec3
354
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
355
+
356
+
357
+ class GTS5(GTS):
358
+ def __init__(self, **kwargs):
359
+ super().__init__(part_idx=2, bounds=((0, 1), (-1, 1), (-1, 2)), **kwargs)
360
+
361
+ def _evaluate(self, x, out, *args, **kwargs):
362
+ xi = np.cos(0.5 * np.pi * self.time)
363
+ xj = G_t(self.time) + np.power(x[:, 0], H_t(self.time))
364
+
365
+ x2, x3 = (x[:, self.sub_vec_2] - xi.reshape(-1, 1)), (x[:, self.sub_vec_3] - xj.reshape(-1, 1))
366
+
367
+ # quadratic form
368
+ diag_x2_R2_x2T = np.einsum('ij,jk,ik->i', x2, self.R_2, x2)
369
+ diag_x3_R3_x3T = np.einsum('ij,jk,ik->i', x3, self.R_3, x3)
370
+ g = 1 + np.power(diag_x2_R2_x2T, self.p) + np.power(diag_x3_R3_x3T, self.p)
371
+
372
+ g += 0.5 + 0.5 * G_t(self.time)
373
+
374
+ x12 = 0.5 * x[:, 0] + x[:, 1]
375
+ _sin = 0.02 * np.sin(omega_t(self.time) * np.pi * x12)
376
+ f1 = g * (x12 + _sin)
377
+ f2 = g * (1.6 - x12 + _sin)
378
+
379
+ out["F"] = np.column_stack([f1, f2])
380
+
381
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
382
+ H = 20
383
+ x1, x2 = np.meshgrid(np.linspace(0, 1, H), np.linspace(0, 1, H), indexing='xy')
384
+ g = 1 + 0.5 + 0.5 * G_t(self.time)
385
+
386
+ x12 = 0.5 * x1 + x2
387
+ _sin = 0.02 * np.sin(omega_t(self.time) * np.pi * x12)
388
+ f1 = g * (x12 + _sin)
389
+ f2 = g * (1.6 - x12 + _sin)
390
+
391
+ return get_PF(np.array([f1, f2]), True)
392
+
393
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
394
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
395
+ x_vec2 = np.full(len(x_vec1), np.cos(0.5 * np.pi * self.time))
396
+ x_vec3 = G_t(self.time) + np.power(x_vec1, H_t(self.time))
397
+ X, Y, Z = x_vec1, x_vec2, x_vec3
398
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
399
+
400
+
401
+ class GTS6(GTS):
402
+ def __init__(self, **kwargs):
403
+ super().__init__(part_idx=1, bounds=((0, 1), (-1, 1), (-1, 2)), **kwargs)
404
+
405
+ def _evaluate(self, x, out, *args, **kwargs):
406
+ xi = self.time_linkage * np.cos(0.5 * np.pi * self.time)
407
+ xj = self.time_linkage * (G_t(self.time) + np.power(x[:, 0], H_t(self.time)))
408
+
409
+ x2, x3 = (x[:, self.sub_vec_2] - xi.reshape(-1, 1)), (x[:, self.sub_vec_3] - xj.reshape(-1, 1))
410
+
411
+ # quadratic form
412
+ diag_x2_R2_x2T = np.einsum('ij,jk,ik->i', x2, self.R_2, x2)
413
+ diag_x3_R3_x3T = np.einsum('ij,jk,ik->i', x3, self.R_3, x3)
414
+ g = 1 + np.power(diag_x2_R2_x2T, self.p) + np.power(diag_x3_R3_x3T, self.p)
415
+
416
+ f1 = x[:, 0]
417
+ f2 = g * (1 - np.power(f1 / g, H_t(self.time)))
418
+
419
+ out["F"] = np.column_stack([f1, f2])
420
+
421
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
422
+ f1 = np.linspace(0, 1, n_pareto_points)
423
+ f2 = 1 - np.power(f1, H_t(self.time))
424
+ return np.array([f1, f2]).T
425
+
426
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
427
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
428
+ x_vec2 = np.full(len(x_vec1), np.cos(0.5 * np.pi * self.time))
429
+ x_vec3 = G_t(self.time) + np.power(x_vec1, H_t(self.time))
430
+ X, Y, Z = x_vec1, x_vec2, x_vec3
431
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
432
+
433
+
434
+ class GTS7(GTS):
435
+ def __init__(self, **kwargs):
436
+ super().__init__(part_idx=1, bounds=((-1, 2.5), (-1, 1), (0, 1)), **kwargs)
437
+
438
+ def _evaluate(self, x, out, *args, **kwargs):
439
+ xi = self.time_linkage * np.cos(0.5 * np.pi * self.time)
440
+ xj = self.time_linkage * 1 / (1 + np.exp(alpha_t(self.time) * (x[:, 0] - 0.5)))
441
+
442
+ x2, x3 = (x[:, self.sub_vec_2] - xi.reshape(-1, 1)), (x[:, self.sub_vec_3] - xj.reshape(-1, 1))
443
+
444
+ # quadratic form
445
+ diag_x2_R2_x2T = np.einsum('ij,jk,ik->i', x2, self.R_2, x2)
446
+ diag_x3_R3_x3T = np.einsum('ij,jk,ik->i', x3, self.R_3, x3)
447
+ g = 1 + np.power(diag_x2_R2_x2T, self.p) + np.power(diag_x3_R3_x3T, self.p)
448
+
449
+ f1 = g * np.power(np.abs(x[:, 0] - a_t(self.time)), H_t(self.time))
450
+ f2 = g * np.power(np.abs(x[:, 0] - a_t(self.time) - b_t(self.time)), H_t(self.time))
451
+
452
+ out["F"] = np.column_stack([f1, f2])
453
+
454
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
455
+ x = np.linspace(a_t(self.time), a_t(self.time) + b_t(self.time), n_pareto_points)
456
+
457
+ f1 = np.power(np.abs(x - a_t(self.time)), H_t(self.time))
458
+ f2 = np.power(np.abs(x - a_t(self.time) - b_t(self.time)), H_t(self.time))
459
+
460
+ return np.array([f1, f2]).T
461
+
462
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
463
+ x_vec1 = np.linspace(a_t(self.time), a_t(self.time) + b_t(self.time), n_pareto_points)
464
+ x_vec2 = np.full(len(x_vec1), np.cos(0.5 * np.pi * self.time))
465
+ x_vec3 = 1 / (1 + np.exp(alpha_t(self.time) * (x_vec1 - 0.5)))
466
+ X, Y, Z = x_vec1, x_vec2, x_vec3
467
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
468
+
469
+
470
+ class GTS8(GTS):
471
+ def __init__(self, **kwargs):
472
+ super().__init__(part_idx=2, bounds=((0, 1), (0, 1), (-1, 2)), **kwargs)
473
+
474
+ def _evaluate(self, x, out, *args, **kwargs):
475
+ xi = self.time_linkage * 1 / (1 + np.exp(alpha_t(self.time) * (x[:, 0] - 0.5)))
476
+ xj = self.time_linkage * (G_t(self.time) + np.power(x[:, 0], H_t(self.time)))
477
+
478
+ x2, x3 = (x[:, self.sub_vec_2] - xi.reshape(-1, 1)), (x[:, self.sub_vec_3] - xj.reshape(-1, 1))
479
+
480
+ # quadratic form
481
+ diag_x2_R2_x2T = np.einsum('ij,jk,ik->i', x2, self.R_2, x2)
482
+ diag_x3_R3_x3T = np.einsum('ij,jk,ik->i', x3, self.R_3, x3)
483
+ g = 1 + np.power(diag_x2_R2_x2T, self.p) + np.power(diag_x3_R3_x3T, self.p)
484
+
485
+ g += 0.25 * np.abs(np.cos(0.3 * np.pi * self.time))
486
+
487
+ f1 = 0.5 * x[:, 0] + x[:, 1]
488
+ f2 = g * (2.8 - np.power(f1 / g, H_t(self.time)))
489
+
490
+ out["F"] = np.column_stack([f1, f2])
491
+
492
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
493
+ H = 20
494
+ x1, x2 = np.meshgrid(np.linspace(0, 1, H), np.linspace(0, 1, H), indexing='xy')
495
+
496
+ f1 = 0.5 * x1 + x2
497
+ g = 1 + 0.25 * np.abs(np.cos(0.3 * np.pi * self.time))
498
+ f2 = g * (2.8 - np.power(f1 / g, H_t(self.time)))
499
+ return get_PF(np.array([f1, f2]), False)
500
+
501
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
502
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
503
+ x_vec2 = 1 / (1 + np.exp(alpha_t(self.time) * (x_vec1 - 0.5)))
504
+ x_vec3 = G_t(self.time) + np.power(x_vec1, H_t(self.time))
505
+ X, Y, Z = x_vec1, x_vec2, x_vec3
506
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
507
+
508
+
509
+ # modified DF12
510
+ class GTS9(GTS):
511
+ def __init__(self, **kwargs):
512
+ super().__init__(part_idx=2, bounds=((0, 1), (0, 1), (-1, 1)), **kwargs)
513
+ self.n_obj = 3
514
+
515
+ def _evaluate(self, x, out, *args, **kwargs):
516
+ xi = 1 / (1 + np.exp(alpha_t(self.time) * (x[:, 0] - 0.5)))
517
+ xj = np.sin(self.time * x[:, 0])
518
+
519
+ x2, x3 = (x[:, self.sub_vec_2] - xi.reshape(-1, 1)), (x[:, self.sub_vec_3] - xj.reshape(-1, 1))
520
+
521
+ # quadratic form
522
+ diag_x2_R2_x2T = np.einsum('ij,jk,ik->i', x2, self.R_2, x2)
523
+ diag_x3_R3_x3T = np.einsum('ij,jk,ik->i', x3, self.R_3, x3)
524
+ g = 1 + np.power(diag_x2_R2_x2T, self.p) + np.power(diag_x3_R3_x3T, self.p)
525
+
526
+ g += np.abs(np.cos(0.27 * np.pi * self.time))
527
+
528
+ f1 = g * np.cos(0.5 * np.pi * x[:, 1]) * np.cos(0.5 * np.pi * x[:, 0])
529
+ f2 = g * np.sin(0.5 * np.pi * x[:, 1]) * np.cos(0.5 * np.pi * x[:, 0])
530
+ f3 = g * np.sin(0.5 * np.pi * x[:, 0])
531
+
532
+ out["F"] = np.column_stack([f1, f2, f3])
533
+
534
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
535
+ H = 20
536
+ x1, x2 = np.meshgrid(np.linspace(0, 1, H), np.linspace(0, 1, H), indexing='xy')
537
+
538
+ g = 1
539
+ g += np.abs(np.cos(0.27 * np.pi * self.time))
540
+
541
+ f1 = np.multiply(np.multiply(g, np.cos(0.5 * np.pi * x2)), np.cos(0.5 * np.pi * x1))
542
+ f2 = np.multiply(np.multiply(g, np.sin(0.5 * np.pi * x2)), np.cos(0.5 * np.pi * x1))
543
+ f3 = np.multiply(g, np.sin(0.5 * np.pi * x1))
544
+
545
+ return get_PF(np.array([f1, f2, f3]), True)
546
+
547
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
548
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
549
+ x_vec2 = 1 / (1 + np.exp(alpha_t(self.time) * (x_vec1 - 0.5)))
550
+ x_vec3 = np.sin(self.time * x_vec1)
551
+ X, Y, Z = x_vec1, x_vec2, x_vec3
552
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
553
+
554
+
555
+ # modified DF13
556
+ class GTS10(GTS):
557
+ def __init__(self, **kwargs):
558
+ super().__init__(part_idx=2, bounds=((0, 1), (0, 1), (-1, 1)), **kwargs)
559
+ self.n_obj = 3
560
+
561
+ def _evaluate(self, x, out, *args, **kwargs):
562
+ xi = np.abs(G_t(self.time))
563
+ 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))))
564
+
565
+ x2, x3 = (x[:, self.sub_vec_2] - xi.reshape(-1, 1)), (x[:, self.sub_vec_3] - xj.reshape(-1, 1))
566
+
567
+ # quadratic form
568
+ diag_x2_R2_x2T = np.einsum('ij,jk,ik->i', x2, self.R_2, x2)
569
+ diag_x3_R3_x3T = np.einsum('ij,jk,ik->i', x3, self.R_3, x3)
570
+ g = 1 + np.power(diag_x2_R2_x2T, self.p) + np.power(diag_x3_R3_x3T, self.p)
571
+
572
+ f1 = g * np.cos(0.5 * np.pi * x[:, 0]) ** 2
573
+ f2 = g * np.cos(0.5 * np.pi * x[:, 1]) ** 2
574
+
575
+ _sin1 = np.sin(0.5 * np.pi * x[:, 0])
576
+ _sin2 = np.sin(0.5 * np.pi * x[:, 1])
577
+ _cos1 = np.cos(p_t(self.time) * np.pi * x[:, 0])
578
+ _cos2 = np.cos(p_t(self.time) * np.pi * x[:, 1])
579
+ f3 = g * (_sin1 ** 2 + _sin1 * _cos1 ** 2 + _sin2 ** 2 + _sin2 * _cos2 ** 2)
580
+
581
+ out["F"] = np.column_stack([f1, f2, f3])
582
+
583
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
584
+ H = 20
585
+ x1, x2 = np.meshgrid(np.linspace(0, 1, H), np.linspace(0, 1, H), indexing='xy')
586
+ G = np.sin(0.5 * np.pi * self.time)
587
+ p = np.floor(6 * G)
588
+
589
+ f1 = np.cos(0.5 * np.pi * x1) ** 2
590
+ f2 = np.cos(0.5 * np.pi * x2) ** 2
591
+ 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(
592
+ 0.5 * np.pi * x2) ** 2 + np.sin(0.5 * np.pi * x2) * np.cos(p * np.pi * x2) ** 2
593
+
594
+ return get_PF(np.array([f1, f2, f3]), True)
595
+
596
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
597
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
598
+ x_vec2 = np.full(len(x_vec1), np.abs(G_t(self.time)))
599
+ 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))))
600
+ X, Y, Z = x_vec1, x_vec2, x_vec3
601
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
602
+
603
+
604
+ # modified DF14
605
+ class GTS11(GTS):
606
+ def __init__(self, **kwargs):
607
+ super().__init__(part_idx=2, bounds=((0, 1), (0, 1), (-1, 2)), **kwargs)
608
+ self.n_obj = 3
609
+
610
+ def _evaluate(self, x, out, *args, **kwargs):
611
+ xi = np.abs(G_t(self.time))
612
+ xj = G_t(self.time) + np.power(x[:, 0], H_t(self.time))
613
+
614
+ x2, x3 = (x[:, self.sub_vec_2] - xi.reshape(-1, 1)), (x[:, self.sub_vec_3] - xj.reshape(-1, 1))
615
+
616
+ # quadratic form
617
+ diag_x2_R2_x2T = np.einsum('ij,jk,ik->i', x2, self.R_2, x2)
618
+ diag_x3_R3_x3T = np.einsum('ij,jk,ik->i', x3, self.R_3, x3)
619
+ g = 1 + np.power(diag_x2_R2_x2T, self.p) + np.power(diag_x3_R3_x3T, self.p)
620
+
621
+ y = y_t(x[:, 0], self.time)
622
+ f1 = g * (1.05 - y + 0.05 * np.sin(6 * np.pi * y))
623
+ f2 = g * (1.05 - x[:, 1] + 0.05 * np.sin(6 * np.pi * x[:, 1])) * (y + 0.05 * np.sin(6 * np.pi * y))
624
+ f3 = g * (x[:, 1] + 0.05 * np.sin(6 * np.pi * x[:, 1])) * (y + 0.05 * np.sin(6 * np.pi * y))
625
+
626
+ out["F"] = np.column_stack([f1, f2, f3])
627
+
628
+ def _calc_pareto_front(self, *args, n_pareto_points=100, **kwargs):
629
+ H = 20
630
+ x1, x2 = np.meshgrid(np.linspace(0, 1, H), np.linspace(0, 1, H), indexing='xy')
631
+
632
+ y = y_t(x1, self.time)
633
+ f1 = 1.05 - y + 0.05 * np.sin(6 * np.pi * y)
634
+ f2 = np.multiply(1.05 - x2 + 0.05 * np.sin(6 * np.pi * x2), y + 0.05 * np.sin(6 * np.pi * y))
635
+ f3 = np.multiply(x2 + 0.05 * np.sin(6 * np.pi * x2), y + 0.05 * np.sin(6 * np.pi * y))
636
+
637
+ return get_PF(np.array([f1, f2, f3]), False)
638
+
639
+ def _calc_pareto_set(self, *args, n_pareto_points=100, **kwargs):
640
+ x_vec1 = np.linspace(0, 1, n_pareto_points)
641
+ x_vec2 = np.full(len(x_vec1), np.abs(G_t(self.time)))
642
+ x_vec3 = G_t(self.time) + np.power(x_vec1, H_t(self.time))
643
+ X, Y, Z = x_vec1, x_vec2, x_vec3
644
+ return np.array([X.flatten(order='F'), Y.flatten(order='F'), Z.flatten(order='F')]).T
645
+
646
+
647
+ class GTS1_2(GTS1):
648
+ def __init__(self, R_case="two", **kwargs):
649
+ super().__init__(R_case=R_case, **kwargs)
650
+
651
+
652
+ class GTS2_2(GTS1):
653
+ def __init__(self, R_case="two", **kwargs):
654
+ super().__init__(R_case=R_case, **kwargs)
655
+
656
+
657
+ class GTS3_2(GTS1):
658
+ def __init__(self, R_case="two", **kwargs):
659
+ super().__init__(R_case=R_case, **kwargs)
660
+
661
+
662
+ class GTS4_2(GTS1):
663
+ def __init__(self, R_case="two", **kwargs):
664
+ super().__init__(R_case=R_case, **kwargs)
665
+
666
+
667
+ class GTS5_2(GTS1):
668
+ def __init__(self, R_case="two", **kwargs):
669
+ super().__init__(R_case=R_case, **kwargs)
670
+
671
+
672
+ class GTS6_2(GTS1):
673
+ def __init__(self, R_case="two", **kwargs):
674
+ super().__init__(R_case=R_case, **kwargs)
675
+
676
+
677
+ class GTS7_2(GTS1):
678
+ def __init__(self, R_case="two", **kwargs):
679
+ super().__init__(R_case=R_case, **kwargs)
680
+
681
+
682
+ class GTS8_2(GTS1):
683
+ def __init__(self, R_case="two", **kwargs):
684
+ super().__init__(R_case=R_case, **kwargs)
685
+
686
+
687
+ class GTS9_2(GTS1):
688
+ def __init__(self, R_case="two", **kwargs):
689
+ super().__init__(R_case=R_case, **kwargs)
690
+
691
+
692
+ class GTS10_2(GTS1):
693
+ def __init__(self, R_case="two", **kwargs):
694
+ super().__init__(R_case=R_case, **kwargs)
695
+
696
+
697
+ class GTS11_2(GTS1):
698
+ def __init__(self, R_case="two", **kwargs):
699
+ super().__init__(R_case=R_case, **kwargs)
700
+
701
+
702
+ class GTS1_3(GTS1):
703
+ def __init__(self, R_case="three", **kwargs):
704
+ super().__init__(R_case=R_case, **kwargs)
705
+
706
+
707
+ class GTS2_3(GTS1):
708
+ def __init__(self, R_case="three", **kwargs):
709
+ super().__init__(R_case=R_case, **kwargs)
710
+
711
+
712
+ class GTS3_3(GTS1):
713
+ def __init__(self, R_case="three", **kwargs):
714
+ super().__init__(R_case=R_case, **kwargs)
715
+
716
+
717
+ class GTS4_3(GTS1):
718
+ def __init__(self, R_case="three", **kwargs):
719
+ super().__init__(R_case=R_case, **kwargs)
720
+
721
+
722
+ class GTS5_3(GTS1):
723
+ def __init__(self, R_case="three", **kwargs):
724
+ super().__init__(R_case=R_case, **kwargs)
725
+
726
+
727
+ class GTS6_3(GTS1):
728
+ def __init__(self, R_case="three", **kwargs):
729
+ super().__init__(R_case=R_case, **kwargs)
730
+
731
+
732
+ class GTS7_3(GTS1):
733
+ def __init__(self, R_case="three", **kwargs):
734
+ super().__init__(R_case=R_case, **kwargs)
735
+
736
+
737
+ class GTS8_3(GTS1):
738
+ def __init__(self, R_case="three", **kwargs):
739
+ super().__init__(R_case=R_case, **kwargs)
740
+
741
+
742
+ class GTS9_3(GTS1):
743
+ def __init__(self, R_case="three", **kwargs):
744
+ super().__init__(R_case=R_case, **kwargs)
745
+
746
+
747
+ class GTS10_3(GTS1):
748
+ def __init__(self, R_case="three", **kwargs):
749
+ super().__init__(R_case=R_case, **kwargs)
750
+
751
+
752
+ class GTS11_3(GTS1):
753
+ def __init__(self, R_case="three", **kwargs):
754
+ super().__init__(R_case=R_case, **kwargs)