diff options
author | Mike Buland <mike@xagasoft.com> | 2012-08-04 16:59:49 -0600 |
---|---|---|
committer | Mike Buland <mike@xagasoft.com> | 2012-08-04 16:59:49 -0600 |
commit | aaa733d789612289396d69bb6cf3a0e5de1798a8 (patch) | |
tree | 9004c335d19bad5357737d34615572e002d583ee /src/tests | |
parent | 3cdf68e08d438a0ced0f5f8d957a6aafd68cb43a (diff) | |
download | libgenetic-aaa733d789612289396d69bb6cf3a0e5de1798a8.tar.gz libgenetic-aaa733d789612289396d69bb6cf3a0e5de1798a8.tar.bz2 libgenetic-aaa733d789612289396d69bb6cf3a0e5de1798a8.tar.xz libgenetic-aaa733d789612289396d69bb6cf3a0e5de1798a8.zip |
Optomized the mating / mutation setup.
It should work the same, but it selects the number of bits to mutate
first, then selects the individual bits instead of testing a random
number on each bit. For very large phenotypes this will be
significantly faster while producing about the same result.
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/binary.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/tests/binary.cpp b/src/tests/binary.cpp index 727feec..3e2cbc7 100644 --- a/src/tests/binary.cpp +++ b/src/tests/binary.cpp | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <bu/sio.h> | 4 | #include <bu/sio.h> |
5 | #include <bu/random.h> | 5 | #include <bu/random.h> |
6 | #include <bu/randomcmwc.h> | 6 | #include <bu/randomcmwc.h> |
7 | #include <bu/randomsystem.h> | ||
7 | #include <time.h> | 8 | #include <time.h> |
8 | 9 | ||
9 | using namespace Bu; | 10 | using namespace Bu; |
@@ -13,7 +14,7 @@ int main( int argc, char *argv[] ) | |||
13 | Bu::Random::setGenerator<Bu::RandomCmwc>(); | 14 | Bu::Random::setGenerator<Bu::RandomCmwc>(); |
14 | Bu::Random::seed( time( NULL ) ); | 15 | Bu::Random::seed( time( NULL ) ); |
15 | 16 | ||
16 | Genetic::OperatorBasic op( new Genetic::PhenotypeBinary( 422*1024 ), 0.0 ); | 17 | Genetic::OperatorBasic op( new Genetic::PhenotypeBinary( 3453120 ), 0.000125 ); |
17 | Genetic::Phenotype *pPb1 = op.random(); | 18 | Genetic::Phenotype *pPb1 = op.random(); |
18 | Genetic::Phenotype *pPb2 = op.random(); | 19 | Genetic::Phenotype *pPb2 = op.random(); |
19 | Genetic::Phenotype *pPb3; | 20 | Genetic::Phenotype *pPb3; |