diff --git a/eo/test/binary_value.h b/eo/test/binary_value.h index e36ad50c7..793e9de62 100644 --- a/eo/test/binary_value.h +++ b/eo/test/binary_value.h @@ -1,25 +1,16 @@ -#include +#include //----------------------------------------------------------------------------- -/** Just a simple function that takes binary value of a chromosome and sets +/** Just the simple function that takes binary value of a chromosome and sets the fitnes. @param _chrom A binary chromosome */ -template float binary_value(const Chrom& _chrom) +template double binary_value(const Chrom& _chrom) { - float sum = 0; - for (unsigned i = 0; i < _chrom.size(); i++) - if (_chrom[i]) - sum += pow(2, _chrom.size() - i - 1); - return sum; + double sum = 0.0; + for (unsigned i=0; i<_chrom.size(); i++) + sum += _chrom[i]; + return sum; } - -struct BinaryValue -{ - template void operator()(Chrom& _chrom) - { - _chrom.fitness(binary_value(_chrom)); - } -}; diff --git a/eo/test/t-eoGA.cpp b/eo/test/t-eoGA.cpp index 31a22ae3c..6763edea7 100644 --- a/eo/test/t-eoGA.cpp +++ b/eo/test/t-eoGA.cpp @@ -1,6 +1,7 @@ #include #include +#include #include "binary_value.h" #include @@ -21,7 +22,7 @@ int main(int argc, char* argv[]) ////////////////////////////////////////////////////// // The evaluation fn - encapsulated into an eval counter for output - eoEvalFuncPtr mainEval( binary_value ); + eoEvalFuncPtr mainEval( binary_value ); eoEvalFuncCounter eval(mainEval); // the genotype - through a genotype initializer diff --git a/eo/test/t-eoPBIL.cpp b/eo/test/t-eoPBIL.cpp index 70efa6085..c546bc6bc 100644 --- a/eo/test/t-eoPBIL.cpp +++ b/eo/test/t-eoPBIL.cpp @@ -66,7 +66,7 @@ int main(int argc, char* argv[]) ////////////////////////////////////////////////////// // The evaluation fn - encapsulated into an eval counter for output - eoEvalFuncPtr mainEval( binary_value); + eoEvalFuncPtr mainEval( binary_value); eoEvalFuncCounter eval(mainEval); // COnstruction of the distribution diff --git a/eo/test/t-eobin.cpp b/eo/test/t-eobin.cpp index c2e9b058d..691f86b48 100644 --- a/eo/test/t-eobin.cpp +++ b/eo/test/t-eobin.cpp @@ -32,7 +32,7 @@ //----------------------------------------------------------------------------- -typedef eoBit Chrom; +typedef eoBit Chrom; //-----------------------------------------------------------------------------