diff options
Diffstat (limited to 'src/tests/maxima/main.cpp')
-rw-r--r-- | src/tests/maxima/main.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
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 @@ | |||
1 | #include "genetic/population.h" | ||
2 | #include "genetic/phenotypebinary.h" | ||
3 | #include "genetic/operatorbasic.h" | ||
4 | #include "genetic/explicitsimulation.h" | ||
5 | #include "fitnessfunctioneq.h" | ||
6 | |||
7 | #include <time.h> | ||
8 | |||
9 | #include <bu/random.h> | ||
10 | #include <bu/sio.h> | ||
11 | using namespace Bu; | ||
12 | |||
13 | int main( int argc, char *argv[] ) | ||
14 | { | ||
15 | Bu::Random::seed( time( NULL ) ); | ||
16 | sio << "Global maxima equation test" << sio.nl | ||
17 | << " - -1.8*x^4 + 0.86*x^3 + 4.0*x^2 == 3.53518 (approx)" << sio.nl | ||
18 | << sio.nl; | ||
19 | |||
20 | Genetic::ExplicitSimulation ex( | ||
21 | new Genetic::OperatorBasic( | ||
22 | new Genetic::PhenotypeBinary( 32 ), | ||
23 | 0.01 | ||
24 | ), | ||
25 | new FitnessFunctionEq(), | ||
26 | 100, | ||
27 | .1, .05 | ||
28 | ); | ||
29 | |||
30 | for( int j = 0; j < 100; j++ ) | ||
31 | { | ||
32 | ex.timestep(); | ||
33 | sio << ex.getMinFitness() << " - " << ex.getMaxFitness() << | ||
34 | sio.nl; | ||
35 | } | ||
36 | |||
37 | return 0; | ||
38 | } | ||
39 | |||