• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

MOTestFunctions.cpp

Go to the documentation of this file.
00001 #include "MOTestFunctions.h"
00002 
00003 //------------------------------------------------------------------------------
00004 // Class MOTestFunctions
00005 //-------------------------------------------------
00006 // Protected Members
00007 
00008 /* (Slightly adjusted) DTLZ1 implementation from PISA (www.tik.ee.ethz.ch/pisa/),
00009  * dtlz_c_source by Marco Laumanns, laumanns@tik.ee.ethz.ch
00010  *
00011  * Domain: [0,1]^n, n >=7, (see Deb, 2002: Scalable MO Test Problems)
00012  * reference point (0.7,0.7,0.7) (see Deb, 2005: Evaluating the e-Domination Based MOEA)
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)  // Number of decision variables, recommended value for k >= 5 (see Deb, 2002: Scalable MO Test Problems), 
00021   {           // hence n >= 7
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;         // Problem dimension, i.e., M-objective
00027   int k = n - M + 1; // Length of xM input vector of g(xM), i.e., xM = (xM_0,...,xM_k-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 /* (Slightly adjusted) DTLZ2 implementation from PISA (www.tik.ee.ethz.ch/pisa/),
00054  * dtlz_c_source by Marco Laumanns, laumanns@tik.ee.ethz.ch
00055  *
00056  * Domain: [0,1]^n, n >= 12, (see Deb, 2002: Scalable MO Test Problems)
00057  * reference point (1.1,1.1,1.1) (see Naujoks, 2005: Multi-objective Optimisation Using S-Metric) 
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)  // Number of decision variables, recommended value for k >= 10 (see Deb, 2002: Scalable MO Test Problems), 
00066   {            // hence n >= 12
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; // Problem dimension, i.e., M-objective
00072   //int k = n - M + 1; // Length of xM input vector of g(xM), i.e., xM = (xM_0,...,xM_k-1)
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 }

Generated on Tue Oct 4 2011 16:25:19 for WDN by  doxygen 1.7.2