From 1f7c135934b6604c5409d4b6f34861105c0a64cb Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 9 Jul 2012 12:01:50 -0600 Subject: It works well enough to solve polynomial maxima. --- src/tests/maxima/fitnessfunctioneq.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/tests/maxima/fitnessfunctioneq.cpp (limited to 'src/tests/maxima/fitnessfunctioneq.cpp') diff --git a/src/tests/maxima/fitnessfunctioneq.cpp b/src/tests/maxima/fitnessfunctioneq.cpp new file mode 100644 index 0000000..5694507 --- /dev/null +++ b/src/tests/maxima/fitnessfunctioneq.cpp @@ -0,0 +1,25 @@ +#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); +} + -- cgit v1.2.3