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

Water.cpp

Go to the documentation of this file.
00001 
00009 #include <Water.h>
00010 
00014 Water::Water(VariableType variableType) {
00015   problemName_ = "Water" ;
00016 
00017   numberOfVariables_   = 3 ;
00018   numberOfFunctions_   = 5 ;
00019   numberOfConstraints_ = 7 ;
00020 
00021   const double upperLimit[] = {0.45, 0.10, 0.10} ;
00022   const double lowerLimit[] = {0.01, 0.01, 0.01} ;
00023   const int precision[]     = {5, 5, 5} ;
00024 
00025   upperLimit_      = new double[numberOfVariables_] ;
00026   lowerLimit_      = new double[numberOfVariables_] ;
00027   precision_       = new int[numberOfVariables_]    ;
00028   bitsPerVariable_ = new int[numberOfVariables_]    ;
00029   
00030   memcpy(upperLimit_, upperLimit, numberOfVariables_ * sizeof(double)) ;
00031   memcpy(lowerLimit_, lowerLimit, numberOfVariables_ * sizeof(double)) ;
00032   memcpy(precision_, precision, numberOfVariables_ * sizeof(int)) ;
00033 
00034   variableType_ = new VariableType[numberOfVariables_] ;
00035 
00036   initializeVariableType(variableType) ;
00037   cout << "Created a " << problemName_ << " problem" << endl ;
00038 
00039 } // Water::Water
00040 
00045 void Water::evaluate(Individual * individual) {
00046   double x[3] ;
00047 
00048   x[0] = (individual->chromosome_->gene_[0])->getRealAllele() ;
00049   x[1] = (individual->chromosome_->gene_[1])->getRealAllele() ;
00050   x[2] = (individual->chromosome_->gene_[2])->getRealAllele() ;
00051   
00052   // First function
00053   individual->fitness_[0] = 106780.37 * (x[1] + x[2]) + 61704.67 ;
00054   // Second function
00055   individual->fitness_[1] = 3000 * x[0] ;
00056   // Third function
00057   individual->fitness_[2] = 305700 * 2289 * x[1] / pow(0.06*2289, 0.65) ;
00058   // Fourth function
00059   individual->fitness_[3] = 250 * 2289 * exp(-39.75*x[1]+9.9*x[2]+2.74) ;
00060   // Third function
00061   individual->fitness_[4] = 25 * (1.39 /(x[0]*x[1]) + 4940*x[2] -80) ;
00062 } // Water::evaluate
00063 
00064 
00073 void Water::evaluateConstraints(Individual * individual) {
00074   double x[3]               ;
00075   double constraintValue[7] ;
00076 
00077   individual->numberOfViolatedConstraints_ = 0 ;
00078   individual->overallConstraintViolation_  = 0 ;
00079 
00080   x[0] = (individual->chromosome_->gene_[0])->getRealAllele() ;
00081   x[1] = (individual->chromosome_->gene_[1])->getRealAllele() ;
00082   x[2] = (individual->chromosome_->gene_[2])->getRealAllele() ;
00083  
00084   constraintValue[0] = 1 - (0.00139/(x[0]*x[1])+4.94*x[2]-0.08)             ;
00085   constraintValue[1] = 1 - (0.000306/(x[0]*x[1])+1.082*x[2]-0.0986)         ;
00086   constraintValue[2] = 50000 - (12.307/(x[0]*x[1]) + 49408.24*x[2]+4051.02) ;
00087   constraintValue[3] = 16000 - (2.098/(x[0]*x[1])+8046.33*x[2]-696.71)      ;
00088   constraintValue[4] = 10000 - (2.138/(x[0]*x[1])+7883.39*x[2]-705.04)      ;
00089   constraintValue[5] = 2000 - (0.417*x[0]*x[1] + 1721.26*x[2]-136.54)       ;
00090   constraintValue[6] = 550 - (0.164/(x[0]*x[1])+631.13*x[2]-54.48) ;
00091 
00092 
00093   int i ;
00094   for (i = 0 ; i < 7; i++) 
00095     if (constraintValue[i] < 0) {
00096       individual->overallConstraintViolation_ -= constraintValue[i] ;
00097       individual->numberOfViolatedConstraints_ ++ ;
00098     } // if
00099 } // Water::evaluateConstraints
00100 
00101 

Our Software

orangebox Mallba

orangebox ssGA

orangebox JGDS

orangebox xxGA

orangebox JCell

orangebox MHTB

orangebox DEME

orangebox JMetal

orangebox More...

orangebox Go Back