-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest_Functions.py
More file actions
67 lines (32 loc) · 1.09 KB
/
Copy pathTest_Functions.py
File metadata and controls
67 lines (32 loc) · 1.09 KB
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
#!/usr/bin/env python
# coding: utf-8
# In[46]:
import numpy as np
import math
from abc import ABC, abstractmethod
# Class Test_function_strategy, is a abstract class that helps to develop subclasss for function evaluation
class Test_function_strategy(ABC):
@abstractmethod
def Test_function(self, x) -> "test function evaluation" :
pass
class dtlz3(Test_function_strategy):
def Test_function(self, x) -> 'Function_evaluation':
#x = [0.3386, 0.6485, 0.5079] #only for testing the code below
yy = [0, 0, 0]
vec_x = np.array(x)
vec_y = np.array(yy)
g = (vec_x[-1] - 0.5)**2
yy[0] = (1+g) * math.cos(vec_x[0]*math.pi/2) * math.cos(vec_x[1]*math.pi/2)
yy[1] = (1+g) * math.cos(vec_x[0]*math.pi/2) * math.sin(vec_x[1]*math.pi/2)
yy[2] = (1+g) * math.sin(vec_x[0]*math.pi/2)
y = np.array([[round(yy[0],4), round(yy[1],4), round(yy[2],4)]]).T
return y
# In[ ]:
# In[43]:
# test
#x = [0.3386, 0.6485, 0.5079]
#eren = dtlz3()
# leo = eren.Test_function(x)
#print(leo)
# In[44]:
# In[45]: