00001
00010 #include <Poloni.h>
00011
00012
00016 Poloni::Poloni(VariableType variableType) {
00017
00018 problemName_ = "Poloni-MOP3" ;
00019
00020 numberOfVariables_ = 2 ;
00021 numberOfFunctions_ = 2 ;
00022 numberOfConstraints_ = 0 ;
00023
00024 const double upperLimit[] = {3.1416, 3.1416} ;
00025 const double lowerLimit[] = {-3.1416, -3.1416} ;
00026 const int partitions[] = {700, 700} ;
00027 const int precision[] = {5, 5, 5} ;
00028
00029 upperLimit_ = new double[numberOfVariables_] ;
00030 lowerLimit_ = new double[numberOfVariables_] ;
00031 partitions_ = new int[numberOfVariables_] ;
00032 precision_ = new int[numberOfVariables_] ;
00033 bitsPerVariable_ = new int[numberOfVariables_] ;
00034
00035 memcpy(upperLimit_, upperLimit, numberOfVariables_ * sizeof(double)) ;
00036 memcpy(lowerLimit_, lowerLimit, numberOfVariables_ * sizeof(double)) ;
00037 memcpy(partitions_, partitions_, numberOfVariables_ * sizeof(int)) ;
00038 memcpy(precision_, precision, numberOfVariables_ * sizeof(int)) ;
00039
00040 variable_ = new VariableType[numberOfVariables_] ;
00041
00042 initializeRealVariableType(variableType) ;
00043 cout << "Created a " << problemName_ << " problem" << endl ;
00044
00045 }
00046
00047
00048 static const double A1 = 0.5 * sin(1.0) - 2 * cos(1.0) +
00049 sin(2.0) - 1.5 * cos(2.0) ;
00050 static const double A2 = 1.5 * sin(1.0) - cos(1.0) +
00051 2 * sin(2.0) - 0.5 * cos(2.0) ;
00052
00053 void Poloni::evaluate(Individual * individual) {
00054
00055 double result ;
00056 double x[2] ;
00057
00058 x[0] = (individual->chromosome_->gene_[0])->getRealAllele() ;
00059 x[1] = (individual->chromosome_->gene_[1])->getRealAllele() ;
00060
00061 double B1 = 0.5 * sin(x[0]) - 2 * cos(x[0]) + sin(x[1]) - 1.5 * cos(x[1]) ;
00062 double B2 = 1.5 * sin(x[0]) - cos(x[0]) + 2 * sin(x[1]) - 0.5 * cos(x[1]) ;
00063 result = -(1 + pow(A1 - B1, 2) + pow(A2 - B2, 2)) ;
00064
00065 individual->fitness_[0] = - result ;
00066
00067
00068 result = -(pow(x[0]+3,2) + pow(x[1]+1,2)) ;
00069
00070 individual->fitness_[1] = - result ;
00071 }
00072