-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblems.pde
More file actions
107 lines (88 loc) · 1.99 KB
/
Copy pathproblems.pde
File metadata and controls
107 lines (88 loc) · 1.99 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
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
String problemName(int problem){
String problemName = "unknown";
switch(problem){
// stepbots peaks
case 0:
problemName = "stepbots peaks";
break;
// Schwefel function
case 1:
problemName = "Schwefel function";
break;
// Rastrigin function
case 2:
problemName = "Rastrigin function";
break;
// Michalewicz function
case 3:
problemName = "Michalewicz function";
break;
}
return problemName;
}
float problemValue(int problem, float x, float y){
float functionValue = -1e33;
switch(problem){
// stepbots peaks
case 0:
functionValue = (pow(cos(8*(x-2))*cos(8*(y)),1)-(abs(x-2)+abs(y)));
break;
// Schwefel function
case 1:
functionValue = (418.9829*(2))-((-x*sin(sqrt(abs(-x))))+(-y*sin(sqrt(abs(-y)))));
break;
// Rastrigin function
case 2:
functionValue = -(10*(2)+((pow(x,2)-10*cos(2*PI*x))+(pow(y,2)-10*cos(2*PI*y))));
break;
// Michalewicz function
case 3:
functionValue = (sin(x)*pow((sin((1*pow(x,2))/PI)),2*(10)))+(sin(y)*pow((sin((2*pow(y,2))/PI)),2*(10)));
break;
}
return functionValue;
}
float minRange(int problem){
float minRange = 0;
switch(problem){
// stepbots peaks
case 0:
minRange = -5;
break;
// Schwefel function
case 1:
minRange = -500;
break;
// Rastrigin function
case 2:
minRange = -5.14;
break;
// Michalewicz function
case 3:
minRange = 0;
break;
}
return minRange;
}
float maxRange(int problem){
float maxRange = 0;
switch(problem){
// stepbots peaks
case 0:
maxRange = 5;
break;
// Schwefel function
case 1:
maxRange = 500;
break;
// Rastrigin function
case 2:
maxRange = 5.14;
break;
// Michalewicz function
case 3:
maxRange = PI;
break;
}
return maxRange;
}