-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathF8.cpp
More file actions
135 lines (104 loc) · 3.16 KB
/
F8.cpp
File metadata and controls
135 lines (104 loc) · 3.16 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
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
#include "F8.h"
#include <stdio.h>
/**
* Single-group Shifted m-dimensional Rosenbrock¡¯s Function
*
* as defined in "Benchmark Functions for the CEC'2010 Special Session
* and Competition on Large-Scale Global Optimization" by Ke Tang,
* Xiaodong Li, P. N. Suganthan, Zhenyu Yang, and Thomas Weise
* published as technical report on January 8, 2010 at Nature Inspired
* Computation and Applications Laboratory (NICAL), School of Computer
* Science and Technology, University of Science and Technology of China,
* Hefei, Anhui, China.
*/
F8::F8():Benchmarks(){
m_havenextGaussian=0;
Ovector = NULL;
minX = -100;
maxX = 100;
ID = 8;
}
F8::~F8(){
delete[] Ovector;
delete[] Pvector;
}
double F8::compute(double* x){
int m = nonSeparableGroupSize;
int i;
double result;
if(Ovector == NULL) {
Ovector = createShiftVector(dimension,minX,maxX-1);
// printf("\n\n\nO vector\n\n\n");
// for (i = 0; i<dimension; i++){
// printf("%f\t",Ovector[i]);
// }
Pvector = createPermVector(dimension);
//TODO: Neeed to change back to random one ****************************************************************************
// Pvector = (int*)malloc(sizeof(int) * dimension);
// for (i = 0; i<dimension; i++){
// Pvector[i] = i;
// }
/*
printf("\n\n\nP vector\n\n\n");
for (i = 0; i<dimension; i++){
printf("%d\t",Pvector[i]);
}
*/
}
for(i = 0; i < dimension; i++) {
anotherz[i] = x[i] - Ovector[i];
}
for(i = 0; i < m; i++) {
anotherz1[i] = anotherz[Pvector[i]];
}
for(i = m; i < dimension; i++) {
anotherz2[i - m] = anotherz[Pvector[i]];
}
// printf("\n\n\nanotherz1\n\n\n");
// for (i = 0; i<m; i++){
// printf("%f\t",anotherz1[i]);
// }
result = rosenbrock(anotherz1,m) * 1e6 + sphere(anotherz2,dimension - m);
// printf("Rosenbrock Part = %1.16E\n", rosenbrock(anotherz1,m) * 1e6);
// printf("Sphere Part = %1.16E\n", sphere(anotherz2,dimension - m));
return(result);
}
double F8::compute(vector<double> x){
int m = nonSeparableGroupSize;
int i;
double result;
if(Ovector == NULL) {
Ovector = createShiftVector(dimension,minX,maxX-1);
// printf("\n\n\nO vector\n\n\n");
// for (i = 0; i<dimension; i++){
// printf("%f\t",Ovector[i]);
// }
Pvector = createPermVector(dimension);
// //TODO: Neeed to change back to random one ****************************************************************************
// Pvector = (int*)malloc(sizeof(int) * dimension);
// for (i = 0; i<dimension; i++){
// Pvector[i] = i;
// }
// printf("\n\n\nP vector\n\n\n");
// for (i = 0; i<dimension; i++){
// printf("%d\t",Pvector[i]);
// }
// printf ( "\n" );
//
// printf ( "dimension = %d\n", dimension );
// printf ( "m = %d\n", m );
}
for(i = 0; i < dimension; i++) {
anotherz[i] = x[i] - Ovector[i];
}
for(i = 0; i < m; i++) {
anotherz1[i] = anotherz[Pvector[i]];
}
for(i = m; i < dimension; i++) {
anotherz2[i - m] = anotherz[Pvector[i]];
}
result = rosenbrock(anotherz1,m) * 1e6 + sphere(anotherz2,dimension - m);
// printf("Rosenbrock Part = %1.16E\n", rosenbrock(anotherz1,m) * 1e6);
// printf("Sphere Part = %1.16E\n", sphere(anotherz2,dimension - m));
return(result);
}