#include "fitnessfunctioneq.h" #include "genetic/phenotypebinary.h" FitnessFunctionEq::FitnessFunctionEq() { } FitnessFunctionEq::~FitnessFunctionEq() { } double FitnessFunctionEq::operator()( Genetic::Phenotype *pTest ) { Genetic::PhenotypeBinary *pbTest = dynamic_cast( pTest ); if( pbTest == NULL ) return 0.0; uint32_t uRaw; pbTest->extractBits( uRaw, 0, 32 ); double x = ((double)uRaw / (double)(0xfffffffful))*5.0 - 2.5; return -1.8*(x*x*x*x) + 0.86*(x*x*x) + 4.0*(x*x); }