summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tests/binary.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/tests/binary.cpp b/src/tests/binary.cpp
new file mode 100644
index 0000000..717c171
--- /dev/null
+++ b/src/tests/binary.cpp
@@ -0,0 +1,37 @@
1#include "genetic/phenotypebinary.h"
2#include "genetic/operatorbasic.h"
3
4#include <bu/sio.h>
5#include <bu/random.h>
6#include <bu/randomcmwc.h>
7#include <time.h>
8
9using namespace Bu;
10
11int main( int argc, char *argv[] )
12{
13 Bu::Random::setGenerator<Bu::RandomCmwc>();
14 Bu::Random::seed( time( NULL ) );
15
16 Genetic::OperatorBasic op( new Genetic::PhenotypeBinary( 45 ), 0.1 );
17 Genetic::Phenotype *pPb1 = op.random();
18 Genetic::Phenotype *pPb2 = op.random();
19 Genetic::Phenotype *pPb3;
20
21 sio << pPb1->toString() << sio.nl;
22 sio << pPb2->toString() << sio.nl;
23
24 Genetic::PhenotypeList lParents;
25 lParents.append( pPb1 );
26 lParents.append( pPb2 );
27 pPb3 = op.mate( lParents );
28
29 sio << pPb3->toString() << sio.nl;
30
31 delete pPb1;
32 delete pPb2;
33 delete pPb3;
34
35 return 0;
36}
37