00001 #include <cmath> 00002 #include "F7-F11.h" 00003 #include "f7f11data.h" 00004 00005 tFitness f_Schwefel2_22(int dim, double *s) 00006 { 00007 tFitness sum, currentGen, prod; 00008 00009 sum = 0.0; 00010 prod = 1.0; 00011 00012 for (int i = 0; i < dim; i++) 00013 { 00014 currentGen = fabs(s[i]-f7[i]); 00015 sum += currentGen; 00016 prod *= currentGen; 00017 } 00018 00019 return sum + prod; 00020 } 00021 00022 tFitness f_Schwefel1_2(int dim, double *s) 00023 { 00024 tFitness Sum=0.0, Val=0.0; 00025 00026 for (int i = 0; i < dim; i++) 00027 { 00028 Val += s[i]-f8[i]; 00029 Sum += Val * Val; 00030 } 00031 00032 return Sum; 00033 } 00034 00035 tFitness f_10(double x, double y) 00036 { 00037 double p, z, t; 00038 00039 p=(x*x+y*y); 00040 00041 z=pow(p, 0.25); 00042 t=sin(50.0*pow(p, 0.1)); 00043 t=t*t+1.0; 00044 00045 return z*t; 00046 } 00047 00048 tFitness Extended_f_10(int dim, double *x) 00049 { 00050 double suma=0.0; 00051 00052 for(int i=0; i<dim-1; i++) 00053 suma+=f_10(x[i]-f9[i], x[i+1]-f9[i+1]); 00054 00055 suma+=f_10(x[dim-1]-f9[dim-1], x[0]-f9[0]); 00056 00057 return suma; 00058 } 00059 00060 tFitness f_Bohachevsky(int dim, double *s) 00061 { 00062 const double PI = 3.141592653589793; 00063 tFitness sum = 0.0; 00064 int i; 00065 double currentGen; 00066 double nextGen; 00067 00068 currentGen = s[0]-f10[0]; 00069 00070 for (i = 1; i < dim; i++) 00071 { 00072 nextGen = s[i]-f10[i]; 00073 sum += currentGen * currentGen + 2.0 * nextGen * nextGen; 00074 sum += -0.3 * cos(3.0 * PI * currentGen) -0.4 * cos(4.0 * PI * nextGen) + 0.7; 00075 currentGen = nextGen; 00076 } 00077 00078 return sum; 00079 } 00080 00081 tFitness f_Schaffer(int dim, double *s) 00082 { 00083 int i; 00084 tFitness sum; 00085 double aux, aux2; 00086 double currentGen, nextGen; 00087 00088 sum = 0.0; 00089 currentGen = s[0]-f11[i]; 00090 currentGen = currentGen * currentGen; 00091 00092 for (i = 1; i < dim; i++) 00093 { 00094 nextGen = s[i]-f11[i]; 00095 nextGen = nextGen * nextGen; 00096 aux = currentGen + nextGen; 00097 currentGen = nextGen; 00098 aux2 = sin(50. * pow(aux, 0.1)); 00099 sum += pow(aux, 0.25) * (aux2 * aux2 + 1.0); 00100 } 00101 00102 return sum; 00103 }