forked from qzcwx/CEC2010SS-LSGO-Benchmarks-CPP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathF9.cpp
110 lines (91 loc) · 2.65 KB
/
F9.cpp
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
#include "F9.h"
#include <stdio.h>
/**
* D/2m-group Shifted and m-rotated Elliptic 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.
*/
F9::F9():Benchmarks(){
m_havenextGaussian=0;
Ovector = NULL;
minX = -100;
maxX = 100;
ID = 9;
lookup = lookupprepare(nonSeparableGroupSize);
lookup2 = lookupprepare(dimension/2);
}
F9::~F9(){
delete[] Ovector;
delete[] Pvector;
delete[] lookup;
delete[] lookup2;
delete[] RotMatrix;
}
double F9::compute(double*x){
int k, i;
double result=0.0;
if(Ovector==NULL){
Ovector=createShiftVector(dimension,minX,maxX);
Pvector=createPermVector(dimension);
RotMatrix=createRotMatrix1D(nonSeparableGroupSize);
/*
* print the multi rotated matrix
printf("\n\n\n print the multi rotated matrix\n\n\n");
for (k = 0; k<dimension/(2*nonSeparableGroupSize); k++){
printf("\n matrix %d: \n", k+1);
for (i = 0; i<nonSeparableGroupSize*nonSeparableGroupSize; i++){
printf("%1.20E\t", MultiRotMatrix1D[k][i]);
}
}
*/
}
for( i=0;i<dimension;i++){
anotherz[i]=x[i]-Ovector[i];
}
//
// printf ( "Pvector\n" );
// for(i=0;i<dimension;i++){
// printf ( "%d\n", Pvector[i] );
// }
for(k=1;k<=dimension/(2*nonSeparableGroupSize);k++){
result+=rot_elliptic(anotherz,nonSeparableGroupSize,k);
}
// printf("Rotated Part = %1.20E\n", result);
// printf("Non-Rotated Part = %1.20E\n", elliptic(anotherz, dimension, 2));
result+=elliptic(anotherz, dimension, 2);
return(result);
}
double F9::compute(vector<double> x){
int i,k;
double result=0.0;
if(Ovector==NULL){
Ovector=createShiftVector(dimension,minX,maxX);
Pvector=createPermVector(dimension);
RotMatrix=createRotMatrix1D(nonSeparableGroupSize);
/*
* print the multi rotated matrix
printf("\n\n\n print the multi rotated matrix\n\n\n");
for (k = 0; k<dimension/(2*nonSeparableGroupSize); k++){
printf("\n matrix %d: \n", k+1);
for (i = 0; i<nonSeparableGroupSize*nonSeparableGroupSize; i++){
printf("%1.20E\t", MultiRotMatrix1D[k][i]);
}
}
*/
}
for(i=0;i<dimension;i++){
anotherz[i]=x[i]-Ovector[i];
}
for(k=1;k<=dimension/(2*nonSeparableGroupSize);k++){
result+=rot_elliptic(anotherz,nonSeparableGroupSize,k);
}
// printf("Rotated Part = %1.20E\n", result);
result+=elliptic(anotherz, dimension, 2);
return(result);
}