diff --git a/branches/newMo/src/continuator/moCheckpoint.h b/branches/newMo/src/continuator/moCheckpoint.h index eb6af2d2b..69e879e8f 100644 --- a/branches/newMo/src/continuator/moCheckpoint.h +++ b/branches/newMo/src/continuator/moCheckpoint.h @@ -38,6 +38,7 @@ #include #include #include +#include /** * Continuator allowing to add others (continuators, stats, monitors or updaters) @@ -100,9 +101,11 @@ public : } /** - * @return the name of the class + * @return class name */ - virtual std::string className(void) const { return "moCheckPoint"; } + virtual std::string className(void) const { + return "moCheckpoint"; + } /** * apply operator of checkpoint's containers diff --git a/branches/newMo/test/CMakeLists.txt b/branches/newMo/test/CMakeLists.txt index b28e9b50c..10c2c7bd1 100644 --- a/branches/newMo/test/CMakeLists.txt +++ b/branches/newMo/test/CMakeLists.txt @@ -47,6 +47,7 @@ SET (TEST_LIST t-moNeighborhoodStat t-moCounterMonitorSaver t-moSolutionStat + t-moCheckpoint ) FOREACH (test ${TEST_LIST}) diff --git a/branches/newMo/test/moTestClass.h b/branches/newMo/test/moTestClass.h index 52e02459e..a18d15952 100644 --- a/branches/newMo/test/moTestClass.h +++ b/branches/newMo/test/moTestClass.h @@ -47,6 +47,9 @@ #include #include +#include +#include + typedef eoBit bitVector; typedef moBitNeighbor bitNeighbor ; typedef moOrderNeighborhood bitNeighborhood ; @@ -120,4 +123,59 @@ public: } }; +class monitor1 : public eoMonitor +{ +public: + + monitor1(unsigned int& _a): a(_a){} + + eoMonitor& operator()(){ + a++; + return *this; + } + + void lastCall(){ + a++; + } + +private: + unsigned int& a; +}; + +class monitor2 : public eoMonitor +{ +public: + + monitor2(unsigned int& _a): a(_a){} + + eoMonitor& operator()(){ + a++; + return *this; + } + + void lastCall(){ + a++; + } + +private: + unsigned int& a; +}; + +class updater1: public eoUpdater +{ +public: + updater1(unsigned int& _a): a(_a){} + + void operator()(){ + a++; + } + + void lastCall(){ + a++; + } + +private: + unsigned int& a; +}; + #endif diff --git a/branches/newMo/test/t-moCheckpoint.cpp b/branches/newMo/test/t-moCheckpoint.cpp new file mode 100644 index 000000000..524f75121 --- /dev/null +++ b/branches/newMo/test/t-moCheckpoint.cpp @@ -0,0 +1,120 @@ +/* + +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 "moTestClass.h" + +#include +#include +#include + +int main(){ + + std::cout << "[t-moCheckpoint] => START" << std::endl; + + unsigned int a=2; + unsigned int b=15; + unsigned int c= 10; + unsigned int d= 47; + + eoBit s(3); + s[0]=true; + s[1]=true; + s[2]=false; + + s.fitness(17); + + moSolutionStat< eoBit< eoMinimizingFitness > > stat; + updater1 up1(a); + updater1 up2(b); + monitor1 mon1(c); + monitor2 mon2(d); + moTrueContinuator< bitNeighborhood > cont; + + moCheckpoint< bitNeighborhood> test1(cont); + moCheckpoint< bitNeighborhood> test2(cont, 3); + + test1.add(up1); + test1.add(up2); + test1.add(mon1); + test1.add(mon2); + test1.add(stat); + + test2.add(up1); + test2.add(up2); + test2.add(mon1); + test2.add(mon2); + test2.add(stat); + + test1.init(s); + test1(s); + assert(a==3 && b==16 && c==11 && d==48); + assert(stat.value()[0]); + assert(stat.value()[1]); + assert(!stat.value()[2]); + assert(stat.value().fitness()==17); + + test1(s); + assert(a==4 && b==17 && c==12 && d==49); + assert(stat.value()[0]); + assert(stat.value()[1]); + assert(!stat.value()[2]); + assert(stat.value().fitness()==17); + + s.fitness(4); + + test2.init(s); + test2(s); + assert(a==5 && b==18 && c==13 && d==50); + assert(stat.value()[0]); + assert(stat.value()[1]); + assert(!stat.value()[2]); + assert(stat.value().fitness()==4); + + s.fitness(6); + test2(s); + assert(stat.value().fitness()==4); + test2(s); + assert(stat.value().fitness()==4); + test2(s); + assert(stat.value().fitness()==6); + + test1.lastCall(s); + assert(a==9 && b==22 && c==17 && d==54); + test2.lastCall(s); + assert(a==10 && b==23 && c==18 && d==55); + + assert(test1.className()=="moCheckpoint"); + std::cout << "[t-moCheckpoint] => OK" << std::endl; + + return EXIT_SUCCESS; +} + diff --git a/branches/newMo/test/t-moCounterMonitorSaver.cpp b/branches/newMo/test/t-moCounterMonitorSaver.cpp index 740b76eb9..39b4cb9e2 100644 --- a/branches/newMo/test/t-moCounterMonitorSaver.cpp +++ b/branches/newMo/test/t-moCounterMonitorSaver.cpp @@ -28,51 +28,13 @@ Contact: paradiseo-help@lists.gforge.inria.fr */ #include -#include +#include "moTestClass.h" #include #include #include -class monitor1 : public eoMonitor -{ -public: - - monitor1(unsigned int& _a): a(_a){} - - eoMonitor& operator()(){ - a++; - return *this; - } - - void lastCall(){ - a++; - } - -private: - unsigned int& a; -}; - -class monitor2 : public eoMonitor -{ -public: - - monitor2(unsigned int& _a): a(_a){} - - eoMonitor& operator()(){ - a++; - return *this; - } - - void lastCall(){ - a++; - } - -private: - unsigned int& a; -}; - int main(){ std::cout << "[t-moCounterMonitorSaver] => START" << std::endl;