Go to the documentation of this file.00001 #include "MOTestFunctions.h"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 void MOTestFunctions::DTLZ1(Individual* I, double* xreal, int n, double* inputNoise)
00015 {
00016 #ifdef DEBUG
00017 cout << "MOTestFunctions::DTLZ1()" << endl;
00018 #endif
00019
00020 if (n < 7)
00021 {
00022 cerr << "DTLZ1: number of decision variables, n = " << n << ", but should be n >= 7 (then k >= 5)! Exiting." << endl;
00023 exit(1);
00024 }
00025
00026 int M = 3;
00027 int k = n - M + 1;
00028
00029 F.assign(M, 0);
00030
00031 double g = 0;
00032 for (int i = M; i <= n; i++)
00033 g += pow(((I != NULL) ? I->R[i-1] : xreal[i-1]) + ((inputNoise != NULL) ? inputNoise[i-1] : 0)
00034 - 0.5, 2) - cos(20 * PI * (((I != NULL) ? I->R[i] : xreal[i]) - 0.5));
00035 g = 100 * (k + g);
00036
00037 for (int i = 1; i <= M; i++)
00038 {
00039 double f = 0.5 * (1 + g);
00040 for (int j = M - i; j >= 1; j--)
00041 f *= ((I != NULL) ? I->R[j-1] : xreal[j-1]) + ((inputNoise != NULL) ? inputNoise[j-1] : 0);
00042
00043 if (i > 1)
00044 {
00045 int index = (M - i + 1) - 1;
00046 f *= 1 - ((I != NULL) ? I->R[index] : xreal[index]) + ((inputNoise != NULL) ? inputNoise[index] : 0);
00047 }
00048
00049 F[i-1] = f;
00050 }
00051 }
00052
00053
00054
00055
00056
00057
00058
00059 void MOTestFunctions::DTLZ2(Individual* I, double* xreal, int n, double* inputNoise)
00060 {
00061 #ifdef DEBUG
00062 cout << "MOTestFunctions::DTLZ2()" << endl;
00063 #endif
00064
00065 if (n < 12)
00066 {
00067 cerr << "DTLZ2: number of decision variables, n = " << n << ", but should be n >= 12 (then k >= 10)! Exiting." << endl;
00068 exit(1);
00069 }
00070
00071 int M = 3;
00072
00073
00074 F.assign(M, 0);
00075
00076 double g = 0;
00077 for (int i = M; i <= n; i++)
00078 g += pow(((I != NULL) ? I->R[i-1] : xreal[i-1]) + ((inputNoise != NULL) ? inputNoise[i-1] : 0) - 0.5, 2);
00079
00080 for (int i = 1; i <= M; i++)
00081 {
00082 double f = (1 + g);
00083 for (int j = M - i; j >= 1; j--)
00084 f *= cos((((I != NULL) ? I->R[j-1] : xreal[j-1]) + ((inputNoise != NULL) ? inputNoise[j-1] : 0)) * PI / 2);
00085
00086 if (i > 1)
00087 {
00088 int index = (M - i + 1) - 1;
00089 f *= sin((((I != NULL) ? I->R[index] : xreal[index]) + ((inputNoise != NULL) ? inputNoise[index] : 0)) * PI / 2);
00090 }
00091
00092 F[i-1] = f;
00093 }
00094 }