From f2e1e40c30b9ac466019e2e84d6383a04cddb063 Mon Sep 17 00:00:00 2001 From: Caner Candan Date: Tue, 12 Oct 2010 10:09:56 +0200 Subject: [PATCH] I have fixed some bugs and added some tests for doDistrib classes --- src/TODO | 1 - src/doDistrib.h | 4 +++- src/doSamplerUniform.h | 7 +++---- test/CMakeLists.txt | 2 ++ test/t-bounderno.cpp | 5 ----- test/t-continue.cpp | 17 +++++++++++++++++ test/t-uniform.cpp | 16 ++++++++++++++++ 7 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 test/t-continue.cpp create mode 100644 test/t-uniform.cpp diff --git a/src/TODO b/src/TODO index bed1db02a..e69de29bb 100644 --- a/src/TODO +++ b/src/TODO @@ -1 +0,0 @@ -* integrer ACP diff --git a/src/doDistrib.h b/src/doDistrib.h index 15b051f8f..f150e8e0e 100644 --- a/src/doDistrib.h +++ b/src/doDistrib.h @@ -8,8 +8,10 @@ #ifndef _doDistrib_h #define _doDistrib_h +#include + template < typename EOT > -class doDistrib +class doDistrib : public eoFunctorBase { public: //! Alias for the type diff --git a/src/doSamplerUniform.h b/src/doSamplerUniform.h index 1d62b903c..6f79c1387 100644 --- a/src/doSamplerUniform.h +++ b/src/doSamplerUniform.h @@ -18,15 +18,14 @@ * This class uses the Uniform distribution parameters (bounds) to return * a random position used for population sampling. */ -template < typename EOT, class D=doUniform > +template < typename EOT, class D=doUniform > // FIXME: D template name is there really used ?!? class doSamplerUniform : public doSampler< doUniform< EOT > > { public: - typedef D Distrib; - + doSamplerUniform(doBounder< EOT > & bounder) - : doSampler< doUniform >(bounder) + : doSampler< doUniform >(bounder) // FIXME: Why D is not used here ? {} /* diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4e8bffc72..74ad84ac6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -36,6 +36,8 @@ SET(SOURCES t-doEstimatorNormalMulti t-mean-distance t-bounderno + t-uniform + t-continue ) FOREACH(current ${SOURCES}) diff --git a/test/t-bounderno.cpp b/test/t-bounderno.cpp index 1a1571632..0898520b4 100644 --- a/test/t-bounderno.cpp +++ b/test/t-bounderno.cpp @@ -1,12 +1,7 @@ #include #include -#include - -#include -#include #include "Rosenbrock.h" -#include "Sphere.h" typedef eoReal< eoMinimizingFitness > EOT; diff --git a/test/t-continue.cpp b/test/t-continue.cpp new file mode 100644 index 000000000..5cae79ff3 --- /dev/null +++ b/test/t-continue.cpp @@ -0,0 +1,17 @@ +#include +#include + +#include "Rosenbrock.h" + +typedef eoReal< eoMinimizingFitness > EOT; +typedef doUniform< EOT > Distrib; + +int main(void) +{ + eoState state; + + doContinue< Distrib >* continuator = new doDummyContinue< Distrib >(); + state.storeFunctor(continuator); + + return 0; +} diff --git a/test/t-uniform.cpp b/test/t-uniform.cpp new file mode 100644 index 000000000..d7aedfea6 --- /dev/null +++ b/test/t-uniform.cpp @@ -0,0 +1,16 @@ +#include +#include + +#include "Rosenbrock.h" + +typedef eoReal< eoMinimizingFitness > EOT; + +int main(void) +{ + eoState state; + + doUniform< EOT >* distrib = new doUniform< EOT >( EOT(3, -1), EOT(3, 1) ); + state.storeFunctor(distrib); + + return 0; +}