-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_problems.py
621 lines (565 loc) · 21 KB
/
test_problems.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
#!/usr/bin/env python
import numpy as np
import time
from mo_utils import ND_Front
import math
class ZDT1:
# Details: http://www.cs.unm.edu/~neal.holts/dga/benchmarkFunction/ackley.html
# Global optimum: f(0,0,...,0)=0
def __init__(self, dim=8, nobj=2):
self.xlow = np.zeros(dim)
self.xup = np.ones(dim)
self.dim = dim
self.nobj = nobj
self.info = str(dim)+"-dimensional Ackley function \n" +\
"Global optimum: f(0,0,...,0) = 0"
self.integer = []
self.continuous = np.arange(0, dim)
self.pf = self.paretofront()
def objfunction(self, x):
if len(x) != self.dim:
raise ValueError('Dimension mismatch')
J = np.zeros(2)
J[0] = x[0]
t = 0
for i in range(1, self.dim):
t = t + x[i]
g = 1 + 9 * (t / (self.dim - 1))
J[1] = g * (1 - np.sqrt(J[0] / g))
return J
def paretofront(self):
g = 1
J = np.zeros([1001, 2])
for i in range(1001): # true pareto front if known
J[i, 0] = np.double(i) / 1000
J[i, 1] = g * (1 - np.sqrt(J[i, 0] / g))
return J
class ZDT2:
# Details: http://www.cs.unm.edu/~neal.holts/dga/benchmarkFunction/ackley.html
# Global optimum: f(0,0,...,0)=0
def __init__(self, dim=8, nobj=2):
self.xlow = np.zeros(dim)
self.xup = np.ones(dim)
self.dim = dim
self.nobj = nobj
self.info = str(dim)+"-dimensional Ackley function \n" +\
"Global optimum: f(0,0,...,0) = 0"
self.integer = []
self.continuous = np.arange(0, dim)
self.pf = self.paretofront()
def objfunction(self, x):
if len(x) != self.dim:
raise ValueError('Dimension mismatch')
J = np.zeros(2)
J[0] = x[0]
t = 0
for i in range(1, self.dim):
t = t + x[i]
g = 1 + 9 * (t / (self.dim - 1))
J[1] = g * (1 - (J[0] / g)**2)
return J
def paretofront(self):
g = 1
J = np.zeros([1001, 2])
for i in range(1001): # true pareto front if known
J[i, 0] = np.double(i) / 1000
J[i, 1] = g * (1 - (J[i, 0] / g)**2)
return J
class ZDT3:
# Details: http://www.cs.unm.edu/~neal.holts/dga/benchmarkFunction/ackley.html
# Global optimum: f(0,0,...,0)=0
def __init__(self, dim=8, nobj=2):
self.xlow = np.zeros(dim)
self.xup = np.ones(dim)
self.dim = dim
self.nobj = nobj
self.info = str(dim)+"-dimensional Ackley function \n" +\
"Global optimum: f(0,0,...,0) = 0"
self.integer = []
self.continuous = np.arange(0, dim)
self.pf = self.paretofront()
def objfunction(self, x):
if len(x) != self.dim:
raise ValueError('Dimension mismatch')
J = np.zeros(2)
J[0] = x[0]
t = 0
for i in range(1, self.dim):
t = t + x[i]
g = 1 + 9 * (t / (self.dim - 1))
J[1] = g * (1 - np.sqrt(J[0] / g) - (J[0] / g) * np.sin(10 * np.pi * J[0]))
return J
def paretofront(self):
g = 1
J = np.zeros([1001, 2])
for i in range(1001):
J[i, 0] = np.double(i) / 1000
J[i, 1] = g * (1 - np.sqrt(J[i, 0] / g) - (J[i, 0] / g) * np.sin(10 * np.pi * J[i, 0]))
(ndf_index, df_index) = ND_Front(np.transpose(J))
return J[ndf_index, :]
class ZDT4:
# Details: http://www.cs.unm.edu/~neal.holts/dga/benchmarkFunction/ackley.html
# Global optimum: f(0,0,...,0)=0
def __init__(self, dim=8, nobj=2):
self.xlow = np.zeros(dim)
self.xup = np.ones(dim)
self.dim = dim
self.nobj = nobj
self.info = str(dim)+"-dimensional Ackley function \n" +\
"Global optimum: f(0,0,...,0) = 0"
self.integer = []
self.continuous = np.arange(0, dim)
self.pf = self.paretofront()
def objfunction(self, x):
if len(x) != self.dim:
raise ValueError('Dimension mismatch')
J = np.zeros(2)
J[0] = x[0]
t = 0
xnew = np.copy(x)
for i in range(1, self.dim):
xnew[i] = -5 + 10*x[i]
t = t + (xnew[i]**2 - 10*np.cos(4*np.pi*xnew[i]))
g = 1 + 10*(self.dim-1) + t
J[1] = g * (1 - np.sqrt(J[0] / g))
return J
def paretofront(self):
g = 1
J = np.zeros([1001, 2])
for i in range(1001): # true pareto front if known
J[i, 0] = np.double(i) / 1000
J[i, 1] = g * (1 - np.sqrt(J[i, 0] / g))
return J
class ZDT6:
# Details: http://www.cs.unm.edu/~neal.holts/dga/benchmarkFunction/ackley.html
# Global optimum: f(0,0,...,0)=0
def __init__(self, dim=8, nobj=2):
self.xlow = np.zeros(dim)
self.xup = np.ones(dim)
self.dim = dim
self.nobj = nobj
self.info = str(dim)+"-dimensional Ackley function \n" +\
"Global optimum: f(0,0,...,0) = 0"
self.integer = []
self.continuous = np.arange(0, dim)
self.pf = self.paretofront()
def objfunction(self, x):
if len(x) != self.dim:
raise ValueError('Dimension mismatch')
J = np.zeros(2)
J[0] = 1 - np.exp(-4 * x[0]) * (np.sin(6 * np.pi * x[0]))**6
t = 0
for i in range(1, self.dim):
t = t + x[i]
g = 1 + 9 * ((t / (self.dim - 1))**0.25)
h = 1 - (J[0] / g)**2
J[1] = g * h
return J
def paretofront(self):
g = 1
J = np.zeros([1001, 2])
for i in range(1001):
J[i, 0] = np.double(i) / 1000
J[i, 1] = g * (1 - (J[i, 0] / g)**2)
return J
class LZF1:
# Details: http://www.cs.unm.edu/~neal.holts/dga/benchmarkFunction/ackley.html
# Global optimum: f(0,0,...,0)=0
def __init__(self, dim=8, nobj=2):
self.xlow = np.zeros(dim)
self.xup = np.ones(dim)
self.dim = dim
self.nobj = nobj
self.info = str(dim)+"-dimensional UF1 function (CEC 2009) and F2 in Zhang 2009 \n" +\
"Global optimum: f(0,0,...,0) = 0"
self.integer = []
self.continuous = np.arange(0, dim)
self.pf = self.paretofront()
def objfunction(self, x):
if len(x) != self.dim:
raise ValueError('Dimension mismatch')
J = np.zeros(2)
t_even = 0
count_even = 0
t_odd = 0
count_odd = 0
i = 2
xnew = np.copy(x)
while(i <= self.dim):
xnew[i-1] = -1 + 2 * xnew[i - 1]
if((i % 2) == 0):
t_even = t_even + (xnew[i - 1] - np.sin(6 * np.pi * xnew[0] + i * np.pi / self.dim))**2
count_even = count_even + 1
else:
t_odd = t_odd + (xnew[i - 1] - np.sin(6 * np.pi * xnew[0] + i * np.pi / self.dim))**2
count_odd = count_odd + 1
i = i + 1
J[0] = xnew[0] + 2 * t_odd / count_odd
J[1] = 1 - np.sqrt(xnew[0]) + 2 * t_even / float(count_even)
return J
def paretofront(self):
J = np.zeros([1001, 2])
for i in range(1001):
J[i, 0] = np.double(i) / 1000
J[i, 1] = 1 - np.sqrt(J[i, 0])
return J
class LZF2:
# Details: http://www.cs.unm.edu/~neal.holts/dga/benchmarkFunction/ackley.html
# Global optimum: f(0,0,...,0)=0
def __init__(self, dim=8, nobj=2):
self.xlow = np.zeros(dim)
self.xup = np.ones(dim)
self.dim = dim
self.nobj = nobj
self.info = str(dim)+"-dimensional UF2 function (CEC 2009) and F5 in Zhang 2009 \n" +\
"Global optimum: f(0,0,...,0) = 0"
self.integer = []
self.continuous = np.arange(0, dim)
self.pf = self.paretofront()
def objfunction(self, x):
if len(x) != self.dim:
raise ValueError('Dimension mismatch')
J = np.zeros(2)
t_even = 0
count_even = 0
t_odd = 0
count_odd = 0
i = 2
xnew = np.copy(x)
while(i <= self.dim):
xnew[i - 1] = -1 + 2 * xnew[i - 1]
if((i % 2) == 0):
t_even = t_even + (xnew[i - 1] - (0.3 * xnew[0]**2 * np.cos(24 * np.pi * xnew[0] + 4 * i * np.pi / self.dim) + 0.6 * xnew[0]) * np.sin(6 * np.pi * xnew[0] + i * np.pi / self.dim))**2
count_even = count_even+1
else:
t_odd = t_odd + (xnew[i-1] -(0.3 * xnew[0]**2 * np.cos(24 * np.pi * xnew[0] + 4 * i * np.pi / self.dim) + 0.6 * xnew[0]) * np.cos(6 * np.pi * xnew[0] + i * np.pi / self.dim))**2
count_odd = count_odd + 1
i = i + 1
J[0] = xnew[0] + 2 * t_odd / float(count_odd)
J[1] = 1 - np.sqrt(xnew[0]) + 2 * t_even / float(count_even)
return J
def paretofront(self):
J = np.zeros([1001, 2])
for i in range(1001):
J[i, 0] = np.double(i) / 1000
J[i, 1] = 1 - np.sqrt(J[i, 0])
return J
class LZF3:
# Details: http://www.cs.unm.edu/~neal.holts/dga/benchmarkFunction/ackley.html
# Global optimum: f(0,0,...,0)=0
def __init__(self, dim=8, nobj=2):
self.xlow = np.zeros(dim)
self.xup = np.ones(dim)
self.dim = dim
self.nobj = nobj
self.info = str(dim)+"-dimensional UF3 function (CEC 2009) and F8 in Zhang 2009 \n" +\
"Global optimum: f(0,0,...,0) = 0"
self.integer = []
self.continuous = np.arange(0, dim)
self.pf = self.paretofront()
def objfunction(self, x):
if len(x) != self.dim:
raise ValueError('Dimension mismatch')
J = np.zeros(2)
sum_even = 0
prod_even = 1
count_even = 0
sum_odd = 0
prod_odd = 1
count_odd = 0
i = 2
xnew = np.copy(x)
while(i <= self.dim):
if((i % 2) == 0):
y = xnew[i-1] - xnew[0]**(0.5 * (1.0 + 3.0 * (i-2.0) / (self.dim-2)))
sum_even = sum_even + (y)**2
prod_even = prod_even * (np.cos(20 * y * np.pi / np.sqrt(i)))
count_even = count_even + 1
else:
y = xnew[i - 1] - xnew[0]**(0.5 * (1.0 + 3.0 * (i-2.0) / (self.dim-2)))
sum_odd = sum_odd + (y)**2
prod_odd = prod_odd * (np.cos(20 * y * np.pi / np.sqrt(i)))
count_odd = count_odd + 1
i = i+1
J[0] = xnew[0] + 2 * (4 * sum_odd - 2 * prod_odd + 2) / float(count_odd)
J[1] = 1 - np.sqrt(xnew[0]) + 2 * (4 * sum_even - 2 * prod_even + 2) / float(count_even)
return J
def paretofront(self):
J = np.zeros([1001, 2])
for i in range(1001):
J[i, 0] = np.double(i) / 1000
J[i, 1] = 1 - np.sqrt(J[i, 0])
return J
class LZF4:
# Details: http://www.cs.unm.edu/~neal.holts/dga/benchmarkFunction/ackley.html
# Global optimum: f(0,0,...,0)=0
def __init__(self, dim=8, nobj=2):
self.xlow = np.zeros(dim)
self.xup = np.ones(dim)
self.dim = dim
self.nobj = nobj
self.info = str(dim)+"-dimensional UF4 function (CEC 2009) \n" +\
"Global optimum: f(0,0,...,0) = 0"
self.integer = []
self.continuous = np.arange(0, dim)
self.pf = self.paretofront()
def objfunction(self, x):
if len(x) != self.dim:
raise ValueError('Dimension mismatch')
J = np.zeros(2)
sum_even = 0
count_even = 0
sum_odd = 0
count_odd = 0
i = 2
xnew = np.copy(x)
while(i <= self.dim):
xnew[i - 1] = -2 + 4 * xnew[i - 1]
if((i % 2) == 0):
y = xnew[i-1] - np.sin(6*np.pi*xnew[0] + i*np.pi/self.dim)
h = np.abs(y)/(1.0 + np.exp(2*np.abs(y)))
sum_even = sum_even + h
count_even = count_even + 1
else:
y = xnew[i-1] - np.sin(6*np.pi*xnew[0] + i*np.pi/self.dim)
h = np.abs(y)/(1.0 + np.exp(2*np.abs(y)))
sum_odd = sum_odd + h
count_odd = count_odd + 1
i = i+1
J[0] = xnew[0] + 2 * sum_odd / float(count_odd)
J[1] = 1 - xnew[0]**2 + 2 * sum_even / float(count_even)
return J
def paretofront(self):
J = np.zeros([1001, 2])
for i in range(1001):
J[i, 0] = np.double(i) / 1000
J[i, 1] = 1 - J[i, 0]**2
return J
class LZF5:
# Details: http://www.cs.unm.edu/~neal.holts/dga/benchmarkFunction/ackley.html
# Global optimum: f(0,0,...,0)=0
def __init__(self, dim=8, nobj=2):
self.xlow = np.zeros(dim)
self.xup = np.ones(dim)
self.dim = dim
self.nobj = nobj
self.info = str(dim)+"-dimensional F3 Function in Zhang 2009 \n" +\
"Global optimum: f(0,0,...,0) = 0"
self.integer = []
self.continuous = np.arange(0, dim)
self.pf = self.paretofront()
def objfunction(self, x):
if len(x) != self.dim:
raise ValueError('Dimension mismatch')
J = np.zeros(2)
t_even = 0
count_even = 0
t_odd = 0
count_odd = 0
i = 2
xnew = np.copy(x)
while(i <= self.dim):
xnew[i - 1] = -1 + 2 * xnew[i - 1]
if((i % 2) == 0):
t_even = t_even + (xnew[i-1] - 0.8*xnew[0]*np.sin(6*np.pi*xnew[0] + i*np.pi/self.dim))**2
count_even = count_even + 1
else:
t_odd = t_odd + (xnew[i-1] - 0.8*xnew[0]*np.cos(6*np.pi*xnew[0] + i*np.pi/self.dim))**2
count_odd = count_odd + 1
i = i + 1
J[0] = xnew[0] + 2 * t_odd / float(count_odd)
J[1] = 1 - np.sqrt(xnew[0]) + 2 * t_even / float(count_even)
return J
def paretofront(self):
J = np.zeros([1001, 2])
for i in range(1001):
J[i, 0] = np.double(i) / 1000
J[i, 1] = 1 - np.sqrt(J[i, 0])
return J
class LZF6:
# Details: http://www.cs.unm.edu/~neal.holts/dga/benchmarkFunction/ackley.html
# Global optimum: f(0,0,...,0)=0
def __init__(self, dim=8, nobj=2):
self.xlow = np.zeros(dim)
self.xup = np.ones(dim)
self.dim = dim
self.nobj = nobj
self.info = str(dim)+"-dimensional F4 Function in Zhang 2009 \n" +\
"Global optimum: f(0,0,...,0) = 0"
self.integer = []
self.continuous = np.arange(0, dim)
self.pf = self.paretofront()
def objfunction(self, x):
if len(x) != self.dim:
raise ValueError('Dimension mismatch')
J = np.zeros(2)
t_even = 0
count_even = 0
t_odd = 0
count_odd = 0
i = 2
xnew = np.copy(x)
while(i <= self.dim):
xnew[i - 1] = -1 + 2 * xnew[i - 1]
if((i % 2) == 0):
t_even = t_even + (xnew[i-1] - 0.8*xnew[0]*np.sin(6*np.pi*xnew[0] + i*np.pi/self.dim))**2
count_even = count_even + 1
else:
t_odd = t_odd + (xnew[i-1] - 0.8*xnew[0]*np.cos((6*np.pi*xnew[0] + i*np.pi/self.dim)/3.0))**2
count_odd = count_odd + 1
i = i + 1
J[0] = xnew[0] + 2 * t_odd / float(count_odd)
J[1] = 1 - np.sqrt(xnew[0]) + 2 * t_even / float(count_even)
return J
def paretofront(self):
J = np.zeros([1001, 2])
for i in range(1001):
J[i, 0] = np.double(i) / 1000
J[i, 1] = 1 - np.sqrt(J[i, 0])
return J
################################################################################
# DTLZ Problems
################################################################################
class DTLZ1:
def __init__(self, nobj = 2):
dim = nobj + 4
self.xlow = np.zeros(dim)
self.xup = np.ones(dim)
self.dim = dim
self.nobj = nobj
self.info = str(dim)+"-dimensional DTLZ Function \n" +\
"Global optimum: f(0,0,...,0) = 0"
self.integer = []
self.continuous = np.arange(0, dim)
self.pf = None
def objfunction(self, solution):
if len(solution) != self.dim:
raise ValueError('Dimension mismatch')
k = self.dim - self.nobj + 1
solution = list(solution)
g = 100.0 * (k + sum([math.pow(x - 0.5, 2.0) - math.cos(20.0 * math.pi * (x - 0.5)) for x in solution[self.dim-k:]]))
f = [0.5 * (1.0 + g)]*self.nobj
for i in range(self.nobj):
for j in range(self.nobj-i-1):
f[i] *= solution[j]
if i > 0:
f[i] *= 1 - solution[self.nobj-i-1]
f = np.asarray(f)
return f
class DTLZ2:
def __init__(self, nobj = 2):
dim = nobj + 9
self.xlow = np.zeros(dim)
self.xup = np.ones(dim)
self.dim = dim
self.nobj = nobj
self.info = str(dim)+"-dimensional DTLZ Function \n" +\
"Global optimum: f(0,0,...,0) = 0"
self.integer = []
self.continuous = np.arange(0, dim)
self.pf = None
def objfunction(self, solution):
if len(solution) != self.dim:
raise ValueError('Dimension mismatch')
k = self.dim - self.nobj + 1
solution = list(solution)
g = sum([math.pow(x - 0.5, 2.0) for x in solution[self.dim-k:]])
f = [1.0 + g]*self.nobj
for i in range(self.nobj):
for j in range(self.nobj-i-1):
f[i] *= math.cos(0.5 * math.pi * solution[j])
if i > 0:
f[i] *= math.sin(0.5 * math.pi *solution[self.nobj-i-1])
f = np.asarray(f)
return f
class DTLZ3:
def __init__(self, nobj = 2):
dim = nobj + 9
self.xlow = np.zeros(dim)
self.xup = np.ones(dim)
self.dim = dim
self.nobj = nobj
self.info = str(dim)+"-dimensional DTLZ Function \n" +\
"Global optimum: f(0,0,...,0) = 0"
self.integer = []
self.continuous = np.arange(0, dim)
self.pf = None
def objfunction(self, solution):
if len(solution) != self.dim:
raise ValueError('Dimension mismatch')
k = self.dim - self.nobj + 1
solution = list(solution)
g = 100.0 * (k + sum([math.pow(x - 0.5, 2.0) - math.cos(20.0 * math.pi * (x - 0.5)) for x in solution[self.dim-k:]]))
f = [1.0 + g]*self.nobj
for i in range(self.nobj):
for j in range(self.nobj-i-1):
f[i] *= math.cos(0.5 * math.pi * solution[j])
if i > 0:
f[i] *= math.sin(0.5 * math.pi *solution[self.nobj-i-1])
f = np.asarray(f)
return f
class DTLZ4:
def __init__(self, nobj = 2):
dim = nobj + 9
self.xlow = np.zeros(dim)
self.xup = np.ones(dim)
self.dim = dim
self.nobj = nobj
self.info = str(dim)+"-dimensional DTLZ Function \n" +\
"Global optimum: f(0,0,...,0) = 0"
self.integer = []
self.continuous = np.arange(0, dim)
self.pf = None
def objfunction(self, solution):
if len(solution) != self.dim:
raise ValueError('Dimension mismatch')
k = self.dim - self.nobj + 1
solution = list(solution)
alpha = 100.0
g = sum([math.pow(x - 0.5, 2.0) for x in solution[self.dim-k:]])
f = [1.0 + g]*self.nobj
for i in range(self.nobj):
for j in range(self.nobj-i-1):
f[i] *= math.cos(0.5 * math.pi * math.pow(solution[j], alpha))
if i > 0:
f[i] *= math.sin(0.5 * math.pi *math.pow(solution[self.nobj-i-1],alpha))
f = np.asarray(f)
return f
# class DTLZ7:
# def __init__(self, nobj = 2):
# dim = nobj + 19
# self.xlow = np.zeros(dim)
# self.xup = np.ones(dim)
# self.dim = dim
# self.nobj = nobj
# self.info = str(dim)+"-dimensional DTLZ Function \n" +\
# "Global optimum: f(0,0,...,0) = 0"
# self.integer = []
# self.continuous = np.arange(0, dim)
# self.pf = None
#
# def objfunction(self, solution):
# if len(solution) != self.dim:
# raise ValueError('Dimension mismatch')
# k = self.dim - self.nobj + 1
# solution = list(solution)
#
# g = 1.0 + (sum([math.pow(x - 0.5, 2.0) for x in solution[self.dim-k:]]))
# f = [1.0 + g]*self.nobj
#
# for i in range(self.nobj):
# for j in range(self.nobj-i-1):
# f[i] *= math.cos(0.5 * math.pi * solution[j])
# if i > 0:
# f[i] *= math.sin(0.5 * math.pi *solution[self.nobj-i-1])
# f = np.asarray(f)
# return f
# data = DTLZ2()
# sol = 0.5*np.ones((13))
# print(sol)
# f = data.objfunction(sol)
# print(f)
#sol = [0.5, 0.57143, 0.35714, 0.64286, 0.21429, 0.64286]
# sol = [1, 0.0, 0.0, 0.0, 0.0, 0.0]
# f = data.objfunction(sol)
# print(f)