blob: ab90e0b1bd14a380164c915973b66e5fd12bc061 (
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include "genetic/population.h"
#include "genetic/phenotypebinary.h"
#include "genetic/operatorbasic.h"
#include "genetic/explicitsimulation.h"
#include "fitnessfunctioneq.h"
#include <time.h>
#include <bu/random.h>
#include <bu/sio.h>
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;
}
|