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/main.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/tests/maxima/main.cpp (limited to 'src/tests/maxima/main.cpp') diff --git a/src/tests/maxima/main.cpp b/src/tests/maxima/main.cpp new file mode 100644 index 0000000..ab90e0b --- /dev/null +++ b/src/tests/maxima/main.cpp @@ -0,0 +1,39 @@ +#include "genetic/population.h" +#include "genetic/phenotypebinary.h" +#include "genetic/operatorbasic.h" +#include "genetic/explicitsimulation.h" +#include "fitnessfunctioneq.h" + +#include + +#include +#include +using namespace Bu; + +int main( int argc, char *argv[] ) +{ + Bu::Random::seed( time( NULL ) ); + sio << "Global maxima equation test" << sio.nl + << " - -1.8*x^4 + 0.86*x^3 + 4.0*x^2 == 3.53518 (approx)" << sio.nl + << sio.nl; + + Genetic::ExplicitSimulation ex( + new Genetic::OperatorBasic( + new Genetic::PhenotypeBinary( 32 ), + 0.01 + ), + new FitnessFunctionEq(), + 100, + .1, .05 + ); + + for( int j = 0; j < 100; j++ ) + { + ex.timestep(); + sio << ex.getMinFitness() << " - " << ex.getMaxFitness() << + sio.nl; + } + + return 0; +} + -- cgit v1.2.3