-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestFunctions.py
More file actions
82 lines (44 loc) · 2.09 KB
/
testFunctions.py
File metadata and controls
82 lines (44 loc) · 2.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from math import *
def ackley_function(x):
return -exp(-sqrt(0.5*sum([i**2 for i in x]))) - \
exp(0.5*sum([cos(i) for i in x])) + 1 + exp(1)
def bukin_function(x):
return 100*sqrt(abs(x[1]-0.01*x[0]**2)) + 0.01*abs(x[0] + 10)
def cross_in_tray_function(x):
return round(-0.0001*(abs(sin(x[0])*sin(x[1])*exp(abs(100 -
sqrt(sum([i**2 for i in x]))/pi))) + 1)**0.1, 7)
def sphere_function(x):
return sum([i**2 for i in x])
def bohachevsky_function(x):
return x[0]**2 + 2*x[1]**2 - 0.3*cos(3*pi*x[0]) - 0.4*cos(4*pi*x[1]) + 0.7
def sum_squares_function(x):
return sum([(i+1)*x[i]**2 for i in range(len(x))])
def sum_of_different_powers_function(x):
return sum([abs(x[i])**(i+2) for i in range(len(x))])
def booth_function(x):
return (x[0] + 2*x[1] - 7)**2 + (2*x[0] + x[1] - 5)**2
def matyas_function(x):
return 0.26*sphere_function(x) - 0.48*x[0]*x[1]
def mccormick_function(x):
return sin(x[0] + x[1]) + (x[0] - x[1])**2 - 1.5*x[0] + 2.5*x[1] + 1
def dixon_price_function(x):
return (x[0] - 1)**2 + sum([(i+1)*(2*x[i]**2 - x[i-1])**2
for i in range(1, len(x))])
def six_hump_camel_function(x):
return (4 - 2.1*x[0]**2 + x[0]**4/3)*x[0]**2 + x[0]*x[1]\
+ (-4 + 4*x[1]**2)*x[1]**2
def three_hump_camel_function(x):
return 2*x[0]**2 - 1.05*x[0]**4 + x[0]**6/6 + x[0]*x[1] + x[1]**2
def easom_function(x):
return -cos(x[0])*cos(x[1])*exp(-(x[0] - pi)**2 - (x[1] - pi)**2)
def michalewicz_function(x):
return -sum([sin(x[i])*sin((i+1)*x[i]**2/pi)**20 for i in range(len(x))])
def beale_function(x):
return (1.5 - x[0] + x[0]*x[1])**2 + (2.25 - x[0] + x[0]*x[1]**2)**2 + \
(2.625 - x[0] + x[0]*x[1]**3)**2
def drop_wave_function(x):
return -(1 + cos(12*sqrt(sphere_function(x))))/(0.5*sphere_function(x) + 2)
def rosenbrock(x):
return 100*(x[1] - x[0]**2)**2 + (1 - x[0])**2
def colville(x):
return 100*(x[0]**2 - x[1])**2 + (x[0] - 1)**2 + (x[2] - 1)**2 + 90*(x[2]**2 - x[3])**2 + 10.1*(x[1] - 1)**2 + (x[3] - 1)**2 + 19.8*(x[1] - 1)*(x[3] - 1)