From 40ee7ad5aeadeb9823e1cd6e1218a1999c608a65 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 9 Jul 2012 08:39:37 -0600 Subject: New libgenetic. Genetic algorithms, only good. --- src/tests/binary.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/tests/binary.cpp (limited to 'src/tests/binary.cpp') 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 @@ +#include "genetic/phenotypebinary.h" +#include "genetic/operatorbasic.h" + +#include +#include +#include +#include + +using namespace Bu; + +int main( int argc, char *argv[] ) +{ + Bu::Random::setGenerator(); + Bu::Random::seed( time( NULL ) ); + + Genetic::OperatorBasic op( new Genetic::PhenotypeBinary( 45 ), 0.1 ); + Genetic::Phenotype *pPb1 = op.random(); + Genetic::Phenotype *pPb2 = op.random(); + Genetic::Phenotype *pPb3; + + sio << pPb1->toString() << sio.nl; + sio << pPb2->toString() << sio.nl; + + Genetic::PhenotypeList lParents; + lParents.append( pPb1 ); + lParents.append( pPb2 ); + pPb3 = op.mate( lParents ); + + sio << pPb3->toString() << sio.nl; + + delete pPb1; + delete pPb2; + delete pPb3; + + return 0; +} + -- cgit v1.2.3