00001
00024 #define _ALL
00025
00026 #include <assert.h>
00027 #include "../../common/define.h"
00028 #include "global.h"
00029 #include "sub.h"
00030 #include "rand.h"
00031
00032 #include "aux.cc"
00033 #include "def1.cc"
00034 #include "def2.cc"
00035 #include "def3.cc"
00036 #include "def4.cc"
00037 #include "rand.cc"
00038
00039 using namespace realea;
00040
00041 bool isBound_cec2005(void) {
00042 if (nfunc != 7 && nfunc != 25) {
00043 return true;
00044 }
00045 else {
00046 return false;
00047 }
00048 }
00049
00050 void init_cec2005(Random *random, int fun, int dim) {
00051
00052 m_random = random;
00053 nfunc = fun;
00054 nreal = dim;
00055
00056 if (nfunc<1)
00057 {
00058 fprintf(stderr,"\n Wrong value of 'nfun' entered\n");
00059 exit(0);
00060 }
00061 if (nreal!=2 && nreal!=10 && nreal!=30 && nreal!=50)
00062 {
00063 fprintf(stderr,"\n Wrong value of 'nreal' entered, only 2, 10, 30, 50 variables are supported\n");
00064 exit(0);
00065 }
00066
00067
00068
00069 randomize();
00070 initrandomnormaldeviate();
00071
00072
00073
00074 allocate_memory();
00075
00076
00077 initialize();
00078 }
00079
00080
00081
00082 void finish_cec2005(void) {
00083 free_memory();
00084 }
00085
00086 struct CECFUNCTION {
00087 int ident;
00088 string name;
00089 double range[2];
00090 double optime;
00091 };
00092
00093 static CECFUNCTION cec2005Fun[] = {
00094 {1, "Shifted Sphere Function", {-100, 100}, -450},
00095 {2, "Shifted Schwefel's Problem 1.2", {-100, 100}, -450},
00096 {3, "Shifted Rotated High Conditioned Elliptic Function", {-100, 100}, -450},
00097 {4, "Shifted Schwefel's Problem 1.2 with Noise in Fitness", {-100, 100}, -450},
00098 {5, "Schwefel's Problem 2.6 with Global Optimum on Bounds", {-100, 100}, -310},
00099 {6, "Shifted Rosenbrock's Function", {-100, 100}, 390},
00100 {7, "Shifted Rotated Griewnk's Function without Bounds", {0, 600}, -180},
00101 {8, "Shifted Rotated Ackley's Function with Global Optimum on Bounds", {-32, 32}, -140},
00102 {9, "Shifted Rastrigin's Function", {-5, 5}, -330},
00103 {10, "Shifted Rotated Rastrigin's Function", {-5, 5}, -330},
00104 {11, "Shifted Rotated Weierstrass Function", {-0.5, 0.5}, 90},
00105 {12, "Schwefel's Problem 2.13", {-PI, PI}, -460},
00106 {13, "Expanded Functions", {-5, 5}, -130},
00107 {14, "Shifted Rotated Expanded Scaffer's F6 Function", {-100, 100}, -300},
00108 {15, "Hybrid Composition Function 1", {-5, 5}, 120},
00109 {16, "Rotated Hybrid Composition Function 1", {-5, 5}, 120},
00110 {17, "Rotated Hybrid Composition Function 1 with Noise in Fitness", {-5, 5}, 120},
00111 {18, "Rotated Hybrid Composition Function 2", {-5, 5}, 10},
00112 {19, "Rotated Hybrid Composition Function 2 with Narrow Basin Global Optimum", {-5, 5}, 10},
00113 {20, "Rotated Hybrid Composition Function 2 with Global Optimum on the Bounds", {-5, 5}, 10},
00114 {21, "Rotated Hybrid Composition Function 3", {-5, 5}, 360},
00115 {22, "Rotated Hybrid Composition Function 3 with High Condition Number Matrix", {-5, 5}, 360},
00116 {23, "Non-Continuous Rotated Hybrid Composition Function 3", {-5, 5}, 360},
00117 {24, "Rotated Hybrid Composition Function 4", {-5, 5}, 260},
00118 {25, "Rotated Hybrid Composition Function 4 without Bounds", {2, 5}, 260},
00119 };
00120
00121 static int cec2005FunSize = 25;
00122
00126 void getInfo_cec2005(int fun, string &name, double &min, double &max, double &optime) {
00127 int id;
00128
00129
00130 assert(fun >= 0 && fun <= cec2005FunSize);
00131
00132 id = fun-1;
00133
00134 name = cec2005Fun[id].name;
00135 min = cec2005Fun[id].range[0];
00136 max = cec2005Fun[id].range[1];
00137 optime = cec2005Fun[id].optime;
00138 }
00139
00143 double eval_cec2005(const long double *x, int ndim) {
00144 double optime = cec2005Fun[nfunc-1].optime;
00145 long double *y = (long double*) x;
00146 double fit = calc_benchmark_func(y)-optime;
00147 assert(fit >= 0);
00148 return fit;
00149 }
00150
00151 double eval_cec2005(const double *x, int ndim) {
00152 double optime = cec2005Fun[nfunc-1].optime;
00153 long double y[ndim];
00154
00155 for (int i = 0; i < ndim; ++i) {
00156 y[i] = x[i];
00157 }
00158
00159 double fit = calc_benchmark_func(y)-optime;
00160
00161 if (fit < 0) {
00162 fprintf(stderr, "Value: %e\tOptime: %e\n", fit, optime);
00163 }
00164
00165 assert(fit >= 0);
00166 return fit;
00167 }