From c60f80b4801d76dc1a640f391e07609d3fe4f6f2 Mon Sep 17 00:00:00 2001 From: jhumeau Date: Wed, 12 May 2010 15:10:32 +0000 Subject: [PATCH] test added git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1809 331e1502-861f-0410-8da2-ba01fb791d7f --- .../src/comparator/moComparator.h | 7 -- .../src/continuator/moNeighborBestStat.h | 1 + trunk/paradiseo-mo/src/continuator/moStat.h | 12 +- .../paradiseo-mo/src/continuator/moStatBase.h | 6 - .../src/continuator/moVectorMonitor.h | 15 ++- .../src/explorer/moNeighborhoodExplorer.h | 6 +- .../src/neighborhood/moIndexNeighborhood.h | 6 +- .../src/sampling/moAutocorrelationSampling.h | 7 +- .../src/sampling/moDensityOfStatesSampling.h | 4 +- .../paradiseo-mo/src/sampling/moFDCsampling.h | 2 +- .../src/sampling/moFitnessCloudSampling.h | 4 +- .../src/sampling/moHillClimberSampling.h | 3 +- trunk/paradiseo-mo/src/sampling/moSampling.h | 15 ++- .../paradiseo-mo/src/sampling/moStatistics.h | 11 +- trunk/paradiseo-mo/test/CMakeLists.txt | 9 ++ trunk/paradiseo-mo/test/moTestClass.h | 18 ++- .../test/t-moAutocorrelationSampling.cpp | 58 +++++++++ .../test/t-moDensityOfStatesSampling.cpp | 54 +++++++++ trunk/paradiseo-mo/test/t-moFDCsampling.cpp | 61 ++++++++++ .../test/t-moFitnessCloudSampling.cpp | 75 ++++++++++++ .../test/t-moHillClimberSampling.cpp | 57 +++++++++ .../test/t-moNeighborVectorTabuList.cpp | 3 +- .../test/t-moNeighborhoodStat.cpp | 1 + .../test/t-moNeutralDegreeSampling.cpp | 64 ++++++++++ .../test/t-moNeutralWalkSampling.cpp | 62 ++++++++++ trunk/paradiseo-mo/test/t-moSampling.cpp | 81 +++++++++++++ .../test/t-moSimpleHCexplorer.cpp | 1 + trunk/paradiseo-mo/test/t-moStatistics.cpp | 111 ++++++++++++++++++ 28 files changed, 701 insertions(+), 53 deletions(-) create mode 100644 trunk/paradiseo-mo/test/t-moAutocorrelationSampling.cpp create mode 100644 trunk/paradiseo-mo/test/t-moDensityOfStatesSampling.cpp create mode 100644 trunk/paradiseo-mo/test/t-moFDCsampling.cpp create mode 100644 trunk/paradiseo-mo/test/t-moFitnessCloudSampling.cpp create mode 100644 trunk/paradiseo-mo/test/t-moHillClimberSampling.cpp create mode 100644 trunk/paradiseo-mo/test/t-moNeutralDegreeSampling.cpp create mode 100644 trunk/paradiseo-mo/test/t-moNeutralWalkSampling.cpp create mode 100644 trunk/paradiseo-mo/test/t-moSampling.cpp create mode 100644 trunk/paradiseo-mo/test/t-moStatistics.cpp diff --git a/trunk/paradiseo-mo/src/comparator/moComparator.h b/trunk/paradiseo-mo/src/comparator/moComparator.h index bd788a4ca..ad040d2ff 100644 --- a/trunk/paradiseo-mo/src/comparator/moComparator.h +++ b/trunk/paradiseo-mo/src/comparator/moComparator.h @@ -60,13 +60,6 @@ class moComparator : public eoBF public: virtual bool equals(const T1&, const T2&) = 0; - /** - * Return the class id. - * @return the class name as a std::string - */ - virtual std::string className() const { - return "moComparator"; - } }; #endif diff --git a/trunk/paradiseo-mo/src/continuator/moNeighborBestStat.h b/trunk/paradiseo-mo/src/continuator/moNeighborBestStat.h index fa5dd16f4..51bcfc54c 100644 --- a/trunk/paradiseo-mo/src/continuator/moNeighborBestStat.h +++ b/trunk/paradiseo-mo/src/continuator/moNeighborBestStat.h @@ -61,6 +61,7 @@ public : * @param _eval an evaluation function * @param _neighborComparator a neighbor Comparator * @param _solNeighborComparator a comparator between a solution and a neighbor + * @param _k number of neighbors visited */ moNeighborBestStat(Neighborhood& _neighborhood, moEval& _eval, moNeighborComparator& _neighborComparator, moSolNeighborComparator& _solNeighborComparator, unsigned int _k = 0): moStat(true, "neighborhood"), diff --git a/trunk/paradiseo-mo/src/continuator/moStat.h b/trunk/paradiseo-mo/src/continuator/moStat.h index 3c4f0dfc2..809383a96 100644 --- a/trunk/paradiseo-mo/src/continuator/moStat.h +++ b/trunk/paradiseo-mo/src/continuator/moStat.h @@ -55,12 +55,12 @@ public: moStat(T _value, std::string _description): eoValueParam(_value, _description) {} - /** - * @return name of the class - */ - virtual std::string className(void) const { - return "moStat"; - } +// /** +// * @return name of the class +// */ +// virtual std::string className(void) const { +// return "moStat"; +// } }; diff --git a/trunk/paradiseo-mo/src/continuator/moStatBase.h b/trunk/paradiseo-mo/src/continuator/moStatBase.h index 8852f15b0..eff9ddaed 100644 --- a/trunk/paradiseo-mo/src/continuator/moStatBase.h +++ b/trunk/paradiseo-mo/src/continuator/moStatBase.h @@ -56,12 +56,6 @@ public: */ virtual void init(EOT &){} - /** - * @return name of the class - */ - virtual std::string className(void) const { - return "moStatBase"; - } }; #endif diff --git a/trunk/paradiseo-mo/src/continuator/moVectorMonitor.h b/trunk/paradiseo-mo/src/continuator/moVectorMonitor.h index c0c651fea..ad45909a6 100644 --- a/trunk/paradiseo-mo/src/continuator/moVectorMonitor.h +++ b/trunk/paradiseo-mo/src/continuator/moVectorMonitor.h @@ -35,6 +35,7 @@ #ifndef moVectorMonitor_h #define moVectorMonitor_h +#include #include #include @@ -69,6 +70,14 @@ public: moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(NULL), eotParam(&_param) { } + /** + * Default Constructor + * @param _param the parameter of type EOT to save in the vector + */ + template + moVectorMonitor(eoValueParam > & _param) : doubleParam( & (eoValueParam&)_param), intParam(NULL), eotParam(NULL) + { } + /** * Default Constructor * @param _param the parameter of type EOT to save in the vector @@ -163,11 +172,11 @@ public: */ void fileExport(std::string _filename) { // create file - ofstream os(_filename.c_str()); + std::ofstream os(_filename.c_str()); if (!os) { - string str = "moVectorMonitor: Could not open " + _filename; - throw runtime_error(str); + std::string str = "moVectorMonitor: Could not open " + _filename; + throw std::runtime_error(str); } for(unsigned int i = 0; i < size(); i++) { diff --git a/trunk/paradiseo-mo/src/explorer/moNeighborhoodExplorer.h b/trunk/paradiseo-mo/src/explorer/moNeighborhoodExplorer.h index 0e67d3f4a..e2701ddd1 100644 --- a/trunk/paradiseo-mo/src/explorer/moNeighborhoodExplorer.h +++ b/trunk/paradiseo-mo/src/explorer/moNeighborhoodExplorer.h @@ -123,9 +123,9 @@ public: * Return the class id. * @return the class name as a std::string */ - virtual std::string className() const { - return "moNeighborhoodExplorer"; - } +// virtual std::string className() const { +// return "moNeighborhoodExplorer"; +// } protected: moDummyNeighborhood dummyNeighborhood; diff --git a/trunk/paradiseo-mo/src/neighborhood/moIndexNeighborhood.h b/trunk/paradiseo-mo/src/neighborhood/moIndexNeighborhood.h index d6129f92f..8d0c0f379 100644 --- a/trunk/paradiseo-mo/src/neighborhood/moIndexNeighborhood.h +++ b/trunk/paradiseo-mo/src/neighborhood/moIndexNeighborhood.h @@ -59,9 +59,9 @@ public: * Return the class id. * @return the class name as a std::string */ - virtual std::string className() const { - return "moIndexNeighborhood"; - } +// virtual std::string className() const { +// return "moIndexNeighborhood"; +// } protected: unsigned int neighborhoodSize; diff --git a/trunk/paradiseo-mo/src/sampling/moAutocorrelationSampling.h b/trunk/paradiseo-mo/src/sampling/moAutocorrelationSampling.h index 3b2d2c615..636ac7508 100644 --- a/trunk/paradiseo-mo/src/sampling/moAutocorrelationSampling.h +++ b/trunk/paradiseo-mo/src/sampling/moAutocorrelationSampling.h @@ -67,11 +67,10 @@ public: */ moAutocorrelationSampling(eoInit & _init, moNeighborhood & _neighborhood, - eoEvalFunc& _fullEval, moEval& _eval, + eoEvalFunc& _fullEval, + moEval& _eval, unsigned int _nbStep) : - moSampling(_init, * new moRandomWalk(_neighborhood, _fullEval, _eval, _nbStep), fitnessStat) - { - } + moSampling(_init, * new moRandomWalk(_neighborhood, _fullEval, _eval, _nbStep), fitnessStat){} /** * default destructor diff --git a/trunk/paradiseo-mo/src/sampling/moDensityOfStatesSampling.h b/trunk/paradiseo-mo/src/sampling/moDensityOfStatesSampling.h index 2e18c6eb2..b0696ae6c 100644 --- a/trunk/paradiseo-mo/src/sampling/moDensityOfStatesSampling.h +++ b/trunk/paradiseo-mo/src/sampling/moDensityOfStatesSampling.h @@ -64,9 +64,7 @@ public: moDensityOfStatesSampling(eoInit & _init, eoEvalFunc& _fullEval, unsigned int _nbSol) : - moSampling(_init, * new moRandomSearch(_init, _fullEval, _nbSol), fitnessStat) - { - } + moSampling(_init, * new moRandomSearch(_init, _fullEval, _nbSol), fitnessStat){} /** * default destructor diff --git a/trunk/paradiseo-mo/src/sampling/moFDCsampling.h b/trunk/paradiseo-mo/src/sampling/moFDCsampling.h index 59eef9411..3d8342fca 100644 --- a/trunk/paradiseo-mo/src/sampling/moFDCsampling.h +++ b/trunk/paradiseo-mo/src/sampling/moFDCsampling.h @@ -83,7 +83,7 @@ public: */ ~moFDCsampling() { // delete the pointer on the local search which has been constructed in the constructor - delete &localSearch; + delete localSearch; } protected: diff --git a/trunk/paradiseo-mo/src/sampling/moFitnessCloudSampling.h b/trunk/paradiseo-mo/src/sampling/moFitnessCloudSampling.h index b5459ce0c..bd222ee25 100644 --- a/trunk/paradiseo-mo/src/sampling/moFitnessCloudSampling.h +++ b/trunk/paradiseo-mo/src/sampling/moFitnessCloudSampling.h @@ -77,9 +77,7 @@ public: fullEval(_fullEval), eval(_eval), nbSol(_nbSol) - { - // std::cout << "moFitnessCloudSampling: Warming to nothing will be sample." << std::endl; - } + {} /** * default destructor diff --git a/trunk/paradiseo-mo/src/sampling/moHillClimberSampling.h b/trunk/paradiseo-mo/src/sampling/moHillClimberSampling.h index 7fbc02e39..6be444755 100644 --- a/trunk/paradiseo-mo/src/sampling/moHillClimberSampling.h +++ b/trunk/paradiseo-mo/src/sampling/moHillClimberSampling.h @@ -70,7 +70,8 @@ public: */ moHillClimberSampling(eoInit & _init, moNeighborhood & _neighborhood, - eoEvalFunc& _fullEval, moEval& _eval, + eoEvalFunc& _fullEval, + moEval& _eval, unsigned int _nbAdaptWalk) : moSampling(initHC, * new moRandomSearch(initHC, _fullEval, _nbAdaptWalk), copyStat), copyStat(lengthStat), diff --git a/trunk/paradiseo-mo/src/sampling/moSampling.h b/trunk/paradiseo-mo/src/sampling/moSampling.h index 48034ed7c..d4179577c 100644 --- a/trunk/paradiseo-mo/src/sampling/moSampling.h +++ b/trunk/paradiseo-mo/src/sampling/moSampling.h @@ -36,6 +36,8 @@ #define moSampling_h #include +#include +#include #include #include #include @@ -44,6 +46,7 @@ #include #include + /** * To sample the search space: * A local search is used to sample the search space @@ -97,7 +100,7 @@ public: monitorVec.push_back(monitor); checkpoint->add(*monitor); } - } + } /** * To sample the search and get the statistics @@ -131,11 +134,11 @@ public: */ void fileExport(std::string _filename, std::string _delim = " ") { // create file - ofstream os(_filename.c_str()); + std::ofstream os(_filename.c_str()); if (!os) { - string str = "moSampling: Could not open " + _filename; - throw runtime_error(str); + std::string str = "moSampling: Could not open " + _filename; + throw std::runtime_error(str); } // all vector have the same size @@ -160,8 +163,8 @@ public: */ void fileExport(unsigned int _col, std::string _filename) { if (_col >= monitorVec.size()) { - string str = "moSampling: Could not export into file the vector. The index does not exists (too large)"; - throw runtime_error(str); + std::string str = "moSampling: Could not export into file the vector. The index does not exists (too large)"; + throw std::runtime_error(str); } monitorVec[_col]->fileExport(_filename); diff --git a/trunk/paradiseo-mo/src/sampling/moStatistics.h b/trunk/paradiseo-mo/src/sampling/moStatistics.h index ec0ea5f46..2dd461067 100644 --- a/trunk/paradiseo-mo/src/sampling/moStatistics.h +++ b/trunk/paradiseo-mo/src/sampling/moStatistics.h @@ -36,6 +36,7 @@ #define moStatistics_h #include +#include #include /** @@ -61,7 +62,7 @@ public: * @param avg average to compute * @param std standard deviation to compute */ - void basic(const vector & data, + void basic(const std::vector & data, double & min, double & max, double & avg, double & std) { if (data.size() == 0) { @@ -104,8 +105,8 @@ public: * @param matrix matrix of distances between solutions */ template - void distances(const vector & data, eoDistance & distance, - vector< vector > & matrix) { + void distances(const std::vector & data, eoDistance & distance, + std::vector< std::vector > & matrix) { if (data.size() == 0) { matrix.resize(0); } else { @@ -134,8 +135,8 @@ public: * @param rho autocorrelation coefficients * @param phi partial autocorrelation coefficients */ - void autocorrelation(const vector & data, unsigned int nbS, - vector & rho, vector & phi) { + void autocorrelation(const std::vector & data, unsigned int nbS, + std::vector & rho, std::vector & phi) { if (data.size() == 0) { rho.resize(0); phi.resize(0); diff --git a/trunk/paradiseo-mo/test/CMakeLists.txt b/trunk/paradiseo-mo/test/CMakeLists.txt index 8cf5f5565..cd0d0c91b 100644 --- a/trunk/paradiseo-mo/test/CMakeLists.txt +++ b/trunk/paradiseo-mo/test/CMakeLists.txt @@ -104,6 +104,15 @@ SET (TEST_LIST t-moMinusOneCounterStat t-moVectorMonitor t-moRandomSearchExplorer + t-moSampling + t-moDensityOfStatesSampling + t-moAutocorrelationSampling + t-moHillClimberSampling + t-moFDCsampling + t-moNeutralDegreeSampling + t-moFitnessCloudSampling + t-moNeutralWalkSampling + t-moStatistics ) FOREACH (test ${TEST_LIST}) diff --git a/trunk/paradiseo-mo/test/moTestClass.h b/trunk/paradiseo-mo/test/moTestClass.h index a3f6663dd..b31b15d7c 100644 --- a/trunk/paradiseo-mo/test/moTestClass.h +++ b/trunk/paradiseo-mo/test/moTestClass.h @@ -57,7 +57,7 @@ typedef eoBit bitVector; typedef moBitNeighbor bitNeighbor; -class moDummyRndNeighborhood: public moOrderNeighborhood/*, public moRndNeighborhood*/ { +class moDummyRndNeighborhood: public moOrderNeighborhood, public moRndNeighborhood { public: moDummyRndNeighborhood(unsigned int a): moOrderNeighborhood(a) {} }; @@ -205,8 +205,24 @@ private: }; class dummyInit: public eoInit{ +public: void operator()(bitVector& sol){ } }; +class dummyInit2: public eoInit{ + +public: + dummyInit2(unsigned int _size):size(_size){} + + void operator()(bitVector& sol){ + sol.resize(0); + for(unsigned int i=0; i< size; i++) + sol.push_back(true); + } + +private: + unsigned int size; +}; + #endif diff --git a/trunk/paradiseo-mo/test/t-moAutocorrelationSampling.cpp b/trunk/paradiseo-mo/test/t-moAutocorrelationSampling.cpp new file mode 100644 index 000000000..0019d7959 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moAutocorrelationSampling.cpp @@ -0,0 +1,58 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can ue, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr +*/ + +#include +#include +#include + +#include +#include "moTestClass.h" +#include + +int main(){ + + std::cout << "[t-moAutocorrelationSampling] => START" << std::endl; + + bitNeighborhood nh(4); + oneMaxEval fullEval; + evalOneMax eval(4); + dummyInit2 init(4); + + moAutocorrelationSampling test(init, nh, fullEval, eval, 3); + + test(); + + test.fileExport("outputTestAutocorrelationSampling"); + + + std::cout << "[t-moAutocorrelationSampling] => OK" << std::endl; + + return EXIT_SUCCESS; +} + diff --git a/trunk/paradiseo-mo/test/t-moDensityOfStatesSampling.cpp b/trunk/paradiseo-mo/test/t-moDensityOfStatesSampling.cpp new file mode 100644 index 000000000..a4d35273f --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moDensityOfStatesSampling.cpp @@ -0,0 +1,54 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can ue, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr +*/ + +#include +#include +#include + +#include +#include "moTestClass.h" +#include + +int main(){ + + std::cout << "[t-moDensityOfStatesSampling] => START" << std::endl; + + oneMaxEval fullEval; + dummyInit2 init(4); + + moDensityOfStatesSampling test(init, fullEval, 3); + test(); + + test.fileExport("outputTestDensityOfState"); + + std::cout << "[t-moDensityOfStatesSampling] => OK" << std::endl; + + return EXIT_SUCCESS; +} + diff --git a/trunk/paradiseo-mo/test/t-moFDCsampling.cpp b/trunk/paradiseo-mo/test/t-moFDCsampling.cpp new file mode 100644 index 000000000..94455582a --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moFDCsampling.cpp @@ -0,0 +1,61 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can ue, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr +*/ + +#include +#include +#include + + +#include +#include "moTestClass.h" +#include +#include + +int main(){ + + std::cout << "[t-moFDCsampling] => START" << std::endl; + + oneMaxEval fullEval; + dummyInit2 init(4); + eoHammingDistance dist; + bitVector sol(4, false); + sol.fitness(0); + + + moFDCsampling test(init, fullEval, dist, sol, 3); + + test(); + + test.fileExport("outputTestFDCsampling"); + + std::cout << "[t-moFDCsampling] => OK" << std::endl; + + return EXIT_SUCCESS; +} + diff --git a/trunk/paradiseo-mo/test/t-moFitnessCloudSampling.cpp b/trunk/paradiseo-mo/test/t-moFitnessCloudSampling.cpp new file mode 100644 index 000000000..378c689bc --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moFitnessCloudSampling.cpp @@ -0,0 +1,75 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can ue, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr +*/ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include "moTestClass.h" +#include + + +int main(){ + + std::cout << "[t-moFitnessCloudSampling] => START" << std::endl; + + bitNeighborhood nh(4); + oneMaxEval fullEval; + evalOneMax eval(4); + dummyInit2 init(4); + + moFitnessCloudSampling test1(init, nh, fullEval, eval, 3); + + moRndRndFitnessCloudSampling test2(init, nh, fullEval, eval, 3); + + moRndBestFitnessCloudSampling test3(init, nh, fullEval, eval, 3); + + moMHRndFitnessCloudSampling test4(init, nh, fullEval, eval, 3); + + moMHBestFitnessCloudSampling test5(init, nh, fullEval, eval, 3); + + test1(); + test2(); + test3(); + test4(); + test5(); + + test1.fileExport("outputTestFitnessCloudSampling"); + + + std::cout << "[t-moFitnessCloudSampling] => OK" << std::endl; + + return EXIT_SUCCESS; +} + diff --git a/trunk/paradiseo-mo/test/t-moHillClimberSampling.cpp b/trunk/paradiseo-mo/test/t-moHillClimberSampling.cpp new file mode 100644 index 000000000..eb15f52b3 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moHillClimberSampling.cpp @@ -0,0 +1,57 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can ue, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr +*/ + +#include +#include +#include + +#include +#include "moTestClass.h" +#include + +int main(){ + + std::cout << "[t-moHillClimberSampling] => START" << std::endl; + + bitNeighborhood nh(4); + oneMaxEval fullEval; + evalOneMax eval(4); + dummyInit2 init(4); + + moHillClimberSampling test(init, nh, fullEval, eval, 3); + + test(); + + test.fileExport("outputTestHillClimberSampling"); + + std::cout << "[t-moHillClimberSampling] => OK" << std::endl; + + return EXIT_SUCCESS; +} + diff --git a/trunk/paradiseo-mo/test/t-moNeighborVectorTabuList.cpp b/trunk/paradiseo-mo/test/t-moNeighborVectorTabuList.cpp index 5f4e37215..2b53ee190 100644 --- a/trunk/paradiseo-mo/test/t-moNeighborVectorTabuList.cpp +++ b/trunk/paradiseo-mo/test/t-moNeighborVectorTabuList.cpp @@ -42,7 +42,8 @@ int main(){ moNeighborVectorTabuList test(2,0); - bitVector sol; + bitVector sol(4,true); + sol.fitness(0); bitNeighbor n1; bitNeighbor n2; bitNeighbor n3; diff --git a/trunk/paradiseo-mo/test/t-moNeighborhoodStat.cpp b/trunk/paradiseo-mo/test/t-moNeighborhoodStat.cpp index f75c12694..f34320c74 100644 --- a/trunk/paradiseo-mo/test/t-moNeighborhoodStat.cpp +++ b/trunk/paradiseo-mo/test/t-moNeighborhoodStat.cpp @@ -136,6 +136,7 @@ int main() { //test of moSecondMomentNeighborStat.h std::cout << "[t-moSecondMomentNeighborStat] => START" << std::endl; moSecondMomentNeighborStat test7(test); + test7.init(sol); test7(sol); assert(test7.value().first==6.6); assert(test7.value().second > 0.966 && test7.value().second < 0.967); diff --git a/trunk/paradiseo-mo/test/t-moNeutralDegreeSampling.cpp b/trunk/paradiseo-mo/test/t-moNeutralDegreeSampling.cpp new file mode 100644 index 000000000..3bf56deda --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moNeutralDegreeSampling.cpp @@ -0,0 +1,64 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can ue, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr +*/ + +#include +#include +#include + +#include +#include "moTestClass.h" +#include +#include +#include + + +int main(){ + + std::cout << "[t-moNeutralDegreeSampling] => START" << std::endl; + + bitNeighborhood nh(4); + oneMaxEval fullEval; + evalOneMax eval(4); + dummyInit2 init(4); + + moSolNeighborComparator sncomp; + moNeighborComparator ncomp; + + moNeutralDegreeSampling test1(init, nh, fullEval, eval, 3); + moNeutralDegreeSampling test2(init, nh, fullEval, eval, ncomp, sncomp, 3); + + test1(); + + test1.fileExport("outputNeutralDegreeSampling"); + + std::cout << "[t-moNeutralDegreeSampling] => OK" << std::endl; + + return EXIT_SUCCESS; +} + diff --git a/trunk/paradiseo-mo/test/t-moNeutralWalkSampling.cpp b/trunk/paradiseo-mo/test/t-moNeutralWalkSampling.cpp new file mode 100644 index 000000000..14e92d69d --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moNeutralWalkSampling.cpp @@ -0,0 +1,62 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can ue, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr +*/ + +#include +#include +#include + + +#include +#include "moTestClass.h" +#include +#include + +int main(){ + + std::cout << "[t-moNeutralWalkSampling] => START" << std::endl; + + bitNeighborhood nh(4); + oneMaxEval fullEval; + evalOneMax eval(4); + dummyInit2 init(4); + bitVector sol(4, true); + sol.fitness(4); + eoHammingDistance dist; + + moNeutralWalkSampling test(sol, nh, fullEval, eval, dist, 3); + + test(); + + test.fileExport("outputTestNeutralWalkSampling"); + + std::cout << "[t-moNeutralWalkSampling] => OK" << std::endl; + + return EXIT_SUCCESS; +} + diff --git a/trunk/paradiseo-mo/test/t-moSampling.cpp b/trunk/paradiseo-mo/test/t-moSampling.cpp new file mode 100644 index 000000000..334e82701 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moSampling.cpp @@ -0,0 +1,81 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can ue, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr +*/ + +#include +#include +#include + +#include +#include "moTestClass.h" +#include +#include +#include +#include +#include + +int main(){ + + std::cout << "[t-moSampling] => START" << std::endl; + + bitNeighborhood nh(4); + oneMaxEval fullEval; + evalOneMax eval(4); + dummyInit2 init(4); + moIterContinuator cont(3); + + moFirstImprHC hc(nh, fullEval, eval, cont); + moSolutionStat stat1; + moCounterStat stat2; + moSampling test(init, hc, stat1); + + test.add(stat2); + + test(); + + std::vector res; + std::vector res2; + res = test.getValues(1); + res2= test.getSolutions(0); + + for(unsigned int i=0; i OK" << std::endl; + + return EXIT_SUCCESS; +} + diff --git a/trunk/paradiseo-mo/test/t-moSimpleHCexplorer.cpp b/trunk/paradiseo-mo/test/t-moSimpleHCexplorer.cpp index 0209c3df1..9767ce600 100644 --- a/trunk/paradiseo-mo/test/t-moSimpleHCexplorer.cpp +++ b/trunk/paradiseo-mo/test/t-moSimpleHCexplorer.cpp @@ -55,6 +55,7 @@ int main() { moNeighborComparator comp; moSolNeighborComparator solNeighborComp; + //verif constructor moSimpleHCexplorer test(nh, fulleval, comp, solNeighborComp); diff --git a/trunk/paradiseo-mo/test/t-moStatistics.cpp b/trunk/paradiseo-mo/test/t-moStatistics.cpp new file mode 100644 index 000000000..6459f4326 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moStatistics.cpp @@ -0,0 +1,111 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can ue, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr +*/ + +#include +#include +#include + +#include +#include "moTestClass.h" +#include + +int main(){ + + std::cout << "[t-moStatistics] => START" << std::endl; + + moStatistics test; + + double min; + double max; + double avg; + double std; + + //test des stats basic + std::vector sampling; + sampling.push_back(3); + sampling.push_back(5); + sampling.push_back(2); + sampling.push_back(4); + + + test.basic(sampling, min, max, avg, std); + assert(min==2); + assert(max==5); + assert(avg==3.5); + assert(std==sqrt(1.25)); + + sampling.resize(0); + test.basic(sampling, min, max, avg, std); + assert(min==0); + assert(max==0); + assert(avg==0); + assert(std==0); + + //test de la distance + std::vector data; + eoHammingDistance dist; + bitVector tmp(4,true); + data.push_back(tmp); + tmp[0]=false; + data.push_back(tmp); + tmp[2]=false; + data.push_back(tmp); + + std::vector< std::vector > matrix; + + test.distances(data, dist, matrix); + + assert(matrix[0][0]==0.0); + assert(matrix[0][1]==1.0); + assert(matrix[0][2]==2.0); + + assert(matrix[1][0]==1.0); + assert(matrix[1][1]==0.0); + assert(matrix[1][2]==1.0); + + assert(matrix[2][0]==2.0); + assert(matrix[2][1]==1.0); + assert(matrix[2][2]==0.0); + + //test de l'autocorrelation + std::vector rho, phi; + test.autocorrelation(sampling, 2, rho, phi); + + sampling.push_back(3); + sampling.push_back(5); + sampling.push_back(2); + sampling.push_back(4); + + test.autocorrelation(sampling, 2, rho, phi); + + std::cout << "[t-moStatistics] => OK" << std::endl; + + return EXIT_SUCCESS; +} +