blob: 56945078292428d98a06d96d1e18699eb4f0fd87 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#include "fitnessfunctioneq.h"
#include "genetic/phenotypebinary.h"
FitnessFunctionEq::FitnessFunctionEq()
{
}
FitnessFunctionEq::~FitnessFunctionEq()
{
}
double FitnessFunctionEq::operator()( Genetic::Phenotype *pTest )
{
Genetic::PhenotypeBinary *pbTest =
dynamic_cast<Genetic::PhenotypeBinary *>( 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);
}
|