diff --git a/trunk/paradiseo-mo/src/moBestImprSelect.h b/trunk/paradiseo-mo/src/moBestImprSelect.h index 6442ecc46..2bb6c9bd0 100755 --- a/trunk/paradiseo-mo/src/moBestImprSelect.h +++ b/trunk/paradiseo-mo/src/moBestImprSelect.h @@ -58,7 +58,8 @@ class moBestImprSelect:public moMoveSelect < M > void init (const Fitness & _fitness) { //Code only used to avoid warning because _fitness is not used in this procedure. - Fitness fitness=(Fitness)_fitness; + Fitness fitness; + fitness=(Fitness)_fitness; first_time = true; } diff --git a/trunk/paradiseo-mo/src/moGenSolContinue.h b/trunk/paradiseo-mo/src/moGenSolContinue.h index cacbe8071..f838e5447 100755 --- a/trunk/paradiseo-mo/src/moGenSolContinue.h +++ b/trunk/paradiseo-mo/src/moGenSolContinue.h @@ -66,7 +66,7 @@ class moGenSolContinue:public moSolContinue < EOT > bool operator () (const EOT & _solution) { //code only used for avoiding warning because _sol is not used in this function. - EOT solution=(EOT)_solution; + const EOT solution(_solution); return (++generationNumber < generationMaximumNumber); } diff --git a/trunk/paradiseo-mo/src/moImprBestFitAspirCrit.h b/trunk/paradiseo-mo/src/moImprBestFitAspirCrit.h index 562319f0f..5f98dca38 100755 --- a/trunk/paradiseo-mo/src/moImprBestFitAspirCrit.h +++ b/trunk/paradiseo-mo/src/moImprBestFitAspirCrit.h @@ -53,10 +53,8 @@ class moImprBestFitAspirCrit:public moAspirCrit < M > typedef typename M::EOType::Fitness Fitness; //! Contructor - moImprBestFitAspirCrit () - { - first_time = true; - } + moImprBestFitAspirCrit (): first_time(true) + {} //! Initialisation procedure void init () @@ -74,6 +72,9 @@ class moImprBestFitAspirCrit:public moAspirCrit < M > */ bool operator () (const M & _move, const Fitness & _fitness) { + //code only used for avoiding warning because _move is not used in this function. + const M move(_move); + if (first_time) { best_fitness = _fitness; diff --git a/trunk/paradiseo-mo/src/moItRandNextMove.h b/trunk/paradiseo-mo/src/moItRandNextMove.h index 9d91af3e0..0bb3ef155 100755 --- a/trunk/paradiseo-mo/src/moItRandNextMove.h +++ b/trunk/paradiseo-mo/src/moItRandNextMove.h @@ -73,9 +73,9 @@ class moItRandNextMove:public moNextMove < M > bool operator () (M & _move, const EOT & _solution) { //code only used to avoid warning because _solution is not used in this function. - EOT solution=(EOT)_solution; + const EOT solution(_solution); - if (iteration_number++ > iteration_maximum_number) + if (iteration_number > iteration_maximum_number) { iteration_number = 0; return false; diff --git a/trunk/paradiseo-mo/src/moMoveExpl.h b/trunk/paradiseo-mo/src/moMoveExpl.h index 6b3a4b788..3fb266f7a 100755 --- a/trunk/paradiseo-mo/src/moMoveExpl.h +++ b/trunk/paradiseo-mo/src/moMoveExpl.h @@ -42,8 +42,8 @@ /*! Only a description...See moMoveLoopExpl. */ -template < class M > class -moMoveExpl : public eoBF < const typename M::EOType &, typename M::EOType &, void > +template < class M > +class moMoveExpl : public eoBF < const typename M::EOType &, typename M::EOType &, void > {}; #endif diff --git a/trunk/paradiseo-mo/src/moNoAspirCrit.h b/trunk/paradiseo-mo/src/moNoAspirCrit.h index 137fbc5db..cbff69ec7 100755 --- a/trunk/paradiseo-mo/src/moNoAspirCrit.h +++ b/trunk/paradiseo-mo/src/moNoAspirCrit.h @@ -46,6 +46,8 @@ template < class M > class moNoAspirCrit:public moAspirCrit < M > { + public: + //! Function which describes the aspiration criterion behaviour /*! Does nothing. @@ -56,6 +58,11 @@ class moNoAspirCrit:public moAspirCrit < M > */ bool operator () (const M & _move, const typename M::EOType::Fitness & _fitness) { + //Code only used to avoid warning because _move and _fitness are not used in this procedure. + const M move(_move); + typename M::EOType::Fitness fitness; + fitness=(typename M::EOType::Fitness)_fitness; + return false; } diff --git a/trunk/paradiseo-mo/src/moSimpleMoveTabuList.h b/trunk/paradiseo-mo/src/moSimpleMoveTabuList.h index 7f88f5bc9..e7f51c032 100755 --- a/trunk/paradiseo-mo/src/moSimpleMoveTabuList.h +++ b/trunk/paradiseo-mo/src/moSimpleMoveTabuList.h @@ -86,7 +86,7 @@ class moSimpleMoveTabuList: public moTabuList < M > void add(const M & _move, const EOT & _solution) { //code only used to avoid warning because _solution is not used in this function. - EOT solution=(EOT)_solution; + const EOT solution(_solution); if (memory_size!=0) { diff --git a/trunk/paradiseo-mo/src/moSimpleSolutionTabuList.h b/trunk/paradiseo-mo/src/moSimpleSolutionTabuList.h index 2865f9973..9b5a7797f 100755 --- a/trunk/paradiseo-mo/src/moSimpleSolutionTabuList.h +++ b/trunk/paradiseo-mo/src/moSimpleSolutionTabuList.h @@ -68,10 +68,10 @@ class moSimpleSolutionTabuList: public moTabuList < M > */ bool operator () (const M & _move, const EOT & _solution) { - solutionIterator it; + M move((M)_move); + EOT solution((EOT)_solution); - M move=(M)_move; - EOT solution=(EOT) _solution; + solutionIterator it; move(solution); diff --git a/trunk/paradiseo-mo/test/CMakeLists.txt b/trunk/paradiseo-mo/test/CMakeLists.txt index 1b69ae868..973673579 100644 --- a/trunk/paradiseo-mo/test/CMakeLists.txt +++ b/trunk/paradiseo-mo/test/CMakeLists.txt @@ -39,7 +39,28 @@ ENDIF(WIN32 AND NOT CYGWIN) ### 3) Define your targets and link the librairies ###################################################################################### -SET (TEST_LIST t-mo) +SET (TEST_LIST t-moBestImprSelect + t-moExponentialCoolingSchedule + t-moFirstImprSelect + t-moFitComparator + t-moFitSolContinue + t-moGenSolContinue + t-moHC + t-moHCMoveLoopExpl + t-moILS + t-moImprBestFitAspirCrit + t-moItRandNextMove + t-moLinearCoolingSchedule + t-moLSCheckPoint + t-moNoAspirCrit + t-moNoFitImprSolContinue + t-moRandImprSelect + t-moSA + t-moSimpleMoveTabuList + t-moSimpleSolutionTabuList + t-moSteadyFitSolContinue + t-moTS + t-moTSMoveLoopExpl ) FOREACH (test ${TEST_LIST}) SET ("T_${test}_SOURCES" "${test}.cpp") diff --git a/trunk/paradiseo-mo/test/t-moBestImprSelect.cpp b/trunk/paradiseo-mo/test/t-moBestImprSelect.cpp new file mode 100644 index 000000000..d964cf85b --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moBestImprSelect.cpp @@ -0,0 +1,101 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moBestImprSelect.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + +typedef EO solution; + +class testMove : public moMove +{ +public : + void operator () (solution & _solution) + { + _solution=_solution; + } +} ; + +//----------------------------------------------------------------------------- + +int +main() +{ + unsigned int i, fitness; + + moBestImprSelect selection; + + solution sol; + + testMove move; + + cout << "[ moBestImprSelect ] ==> "; + + i=fitness=0; + + selection.init(0); + + for(i=1;i<10;i++) + { + if(! selection.update(move, i) ) + { + cout << "KO" << endl; + cout << "update is false" << endl; + return EXIT_FAILURE; + } + } + + selection(move, fitness); + + if(fitness!=9) + { + cout << "KO" << endl; + cout << "fitness = " << fitness << endl; + return EXIT_FAILURE; + } + + cout << "OK" << endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moExponentialCoolingSchedule.cpp b/trunk/paradiseo-mo/test/t-moExponentialCoolingSchedule.cpp new file mode 100644 index 000000000..6b916ea84 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moExponentialCoolingSchedule.cpp @@ -0,0 +1,80 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moExponentialCoolingSchedule.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + + +//----------------------------------------------------------------------------- + +int +main() +{ + unsigned int i; + double temperature; + + moExponentialCoolingSchedule coolingSchedule( 4.0, 0.5 ); + + temperature=10.0; + + cout << "[ moExponentialCoolingSchedule ] ==> "; + + i=0; + while( coolingSchedule(temperature) ) + { + i++; + } + + if(i!=1) + { + cout << "KO" << endl; + cout << "i = " << i << endl; + return EXIT_FAILURE; + } + + cout << "OK" << endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moFirstImprSelect.cpp b/trunk/paradiseo-mo/test/t-moFirstImprSelect.cpp new file mode 100644 index 000000000..6bcb9e7bb --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moFirstImprSelect.cpp @@ -0,0 +1,96 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moFirstImprSelect.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + +typedef EO solution; + +class testMove : public moMove +{ +public : + void operator () (solution & _solution) + { + _solution=_solution; + } +} ; + +//----------------------------------------------------------------------------- + +int +main() +{ + unsigned int i, fitness; + + moFirstImprSelect selection; + + solution sol; + + testMove move; + + cout << "[ moFirstImprSelect ] ==> "; + + i=fitness=0; + + selection.init(10); + + while ( selection.update(move, i) && i<15 ) + { + i++; + } + + selection(move, fitness); + + if(fitness!=11) + { + cout << "KO" << endl; + cout << "fitness = " << fitness << endl; + return EXIT_FAILURE; + } + + cout << "OK" << std::endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-mo.cpp b/trunk/paradiseo-mo/test/t-moFitComparator.cpp similarity index 81% rename from trunk/paradiseo-mo/test/t-mo.cpp rename to trunk/paradiseo-mo/test/t-moFitComparator.cpp index 64d0211c5..22fc1975b 100644 --- a/trunk/paradiseo-mo/test/t-mo.cpp +++ b/trunk/paradiseo-mo/test/t-moFitComparator.cpp @@ -1,7 +1,7 @@ /* -* +* * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 +* (C) OPAC Team, LIFL, 2002-2008 * * Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) * @@ -34,26 +34,41 @@ * */ //----------------------------------------------------------------------------- -// t-mo.cpp +// t-moFitComparator.cpp //----------------------------------------------------------------------------- #include // EO -#include // MO +#include // MO + +using std::cout; +using std::endl; //----------------------------------------------------------------------------- -typedef EO Chrom; +typedef EO solution; //----------------------------------------------------------------------------- -int main() +int +main() { - Chrom chrom1, chrom2; + solution sol1, sol2; - std::cout << "chrom1 = " << chrom1 << std::endl - << "chrom2 = " << chrom2 << std::endl; + moFitComparator comparator; - return 0; + sol1.fitness(0); + sol2.fitness(1); + + cout << "[ moFitComparator ] ==> "; + + if( comparator(sol1,sol2) ) + { + cout << "KO" << endl; + return EXIT_FAILURE; + } + + cout << "OK" << endl; + return EXIT_SUCCESS; } //----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moFitSolContinue.cpp b/trunk/paradiseo-mo/test/t-moFitSolContinue.cpp new file mode 100644 index 000000000..c0e3feffc --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moFitSolContinue.cpp @@ -0,0 +1,81 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moFitSolContinue.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + +typedef EO solution; + +//----------------------------------------------------------------------------- + +int +main() +{ + unsigned int i; + solution sol; + + moFitSolContinue continu(10); + + cout << "[ moFitSolContinue ] ==> "; + + i=0; + sol.fitness(i); + while( continu(sol) ) + { + i++; + sol.fitness(i); + } + + if(i!=10) + { + cout << "KO" << endl; + cout << "i = " << i << endl; + return EXIT_FAILURE; + } + + cout << "OK" << endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moGenSolContinue.cpp b/trunk/paradiseo-mo/test/t-moGenSolContinue.cpp new file mode 100644 index 000000000..24e8a568b --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moGenSolContinue.cpp @@ -0,0 +1,94 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moGenSolContinue.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + +typedef EO solution; + +//----------------------------------------------------------------------------- + +int +main() +{ + unsigned int i; + solution sol; + + moGenSolContinue continu(10); + + cout << "[ moGenSolContinue ] ==> "; + + i=0; + while( continu(sol) ) + { + i++; + } + + if(i!=9) + { + cout << "KO" << endl; + cout << "before init: i = " << i << endl; + return EXIT_FAILURE; + } + + continu.init(); + + i=0; + while( continu(sol) ) + { + i++; + } + + if(i!=9) + { + cout << "KO" << endl; + cout << "after init: i = " << i << endl; + return EXIT_FAILURE; + } + + cout << "OK" << endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moHC.cpp b/trunk/paradiseo-mo/test/t-moHC.cpp new file mode 100644 index 000000000..3e98c0d65 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moHC.cpp @@ -0,0 +1,164 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moHC.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + +typedef EO solution; + +class testMove : public moMove +{ +public : + void operator () (solution & _solution) + { + solution sol=_solution; + } +} ; + +class testMoveInit : public moMoveInit +{ +public : + void operator () (testMove & _move, const solution & _solution) + { + testMove move=_move; + const solution sol(_solution); + } +} ; + +class testMoveNext : public moNextMove +{ +public : + bool operator () (testMove & _move, const solution & _solution) + { + testMove move=_move; + const solution sol(_solution); + + return false; + } +} ; + +class testMoveIncrEval : public moMoveIncrEval +{ +public : + unsigned int operator () (const testMove & _move, const solution & _solution) + { + const testMove move(_move); + const solution solution(_solution); + + return 2; + } +} ; + +class testMoveSelect : public moMoveSelect +{ +public : + void operator () (testMove & _move, unsigned int & _fitness) + { + testMove move; + + move=_move; + + _fitness=2; + } + + void init(const unsigned int & _fitness) + { + unsigned int fitness; + fitness=(unsigned int)_fitness; + } + + bool update(const testMove & _move, const unsigned int & _fitness) + { + testMove move; + unsigned int fitness; + + move=(testMove)_move; + fitness=(unsigned int)_fitness; + + return true; + } +} ; + +class solutionEval : public eoEvalFunc +{ +public : + void operator () (solution & _solution) + { + _solution.fitness(2); + } +} ; + + +//----------------------------------------------------------------------------- + +int +main() +{ + cout << "[ moHC ] ==> "; + + solution sol; + + sol.fitness(0); + + testMoveInit init; + testMoveNext next; + testMoveIncrEval incrEval; + testMoveSelect select; + solutionEval eval; + + moHC hc(init, next, incrEval, select, eval); + + hc(sol); + + if(sol.fitness()!=2) + { + cout << "KO" << endl; + return EXIT_FAILURE; + } + + cout << "OK" << endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moHCMoveLoopExpl.cpp b/trunk/paradiseo-mo/test/t-moHCMoveLoopExpl.cpp new file mode 100644 index 000000000..a742946e2 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moHCMoveLoopExpl.cpp @@ -0,0 +1,154 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moHCMoveLoopExpl.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + +typedef EO solution; + +class testMove : public moMove +{ +public : + void operator () (solution & _solution) + { + solution sol=_solution; + } +} ; + +class testMoveInit : public moMoveInit +{ +public : + void operator () (testMove & _move, const solution & _solution) + { + testMove move=_move; + const solution sol(_solution); + } +} ; + +class testMoveNext : public moNextMove +{ +public : + bool operator () (testMove & _move, const solution & _solution) + { + testMove move=_move; + const solution sol(_solution); + + return false; + } +} ; + +class testMoveIncrEval : public moMoveIncrEval +{ +public : + unsigned int operator () (const testMove & _move, const solution & _solution) + { + const testMove move(_move); + const solution solution(_solution); + + return 2; + } +} ; + +class testMoveSelect : public moMoveSelect +{ +public : + void operator () (testMove & _move, unsigned int & _fitness) + { + testMove move; + + move=_move; + + _fitness=2; + } + + void init(const unsigned int & _fitness) + { + unsigned int fitness; + fitness=(unsigned int)_fitness; + } + + bool update(const testMove & _move, const unsigned int & _fitness) + { + testMove move; + unsigned int fitness; + + move=(testMove)_move; + fitness=(unsigned int)_fitness; + + return true; + } +} ; + +//----------------------------------------------------------------------------- + +int +main() +{ + cout << "[ moHCMoveLoopExpl ] ==> "; + + solution sol1, sol2; + + sol1.fitness(0); + sol2.fitness(0); + + testMoveInit init; + testMoveNext next; + testMoveIncrEval incrEval; + testMoveSelect select; + + moHCMoveLoopExpl explorer(init, next, incrEval, select); + + explorer(sol1, sol2); + + if(sol2.fitness()!=2) + { + cout << "KO" << endl; + return EXIT_FAILURE; + } + + cout << "OK" << endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moILS.cpp b/trunk/paradiseo-mo/test/t-moILS.cpp new file mode 100644 index 000000000..99e9375d7 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moILS.cpp @@ -0,0 +1,206 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moILS.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + +typedef EO solution; + +class testMove : public moMove +{ +public : + void operator () (solution & _solution) + { + solution sol=_solution; + } +} ; + +class testMoveInit : public moMoveInit +{ +public : + void operator () (testMove & _move, const solution & _solution) + { + testMove move=_move; + const solution sol(_solution); + } +} ; + +class testMoveNext : public moNextMove +{ +public : + bool operator () (testMove & _move, const solution & _solution) + { + testMove move=_move; + const solution sol(_solution); + + return false; + } +} ; + +class testMoveIncrEval : public moMoveIncrEval +{ +public : + unsigned int operator () (const testMove & _move, const solution & _solution) + { + const testMove move(_move); + const solution solution(_solution); + + return 2; + } +} ; + +class testMoveSelect : public moMoveSelect +{ +public : + void operator () (testMove & _move, unsigned int & _fitness) + { + testMove move; + + move=_move; + + _fitness=2; + } + + void init(const unsigned int & _fitness) + { + unsigned int fitness; + fitness=(unsigned int)_fitness; + } + + bool update(const testMove & _move, const unsigned int & _fitness) + { + testMove move; + unsigned int fitness; + + move=(testMove)_move; + fitness=(unsigned int)_fitness; + + return true; + } +} ; + +class solutionEval : public eoEvalFunc +{ +public : + void operator () (solution & _solution) + { + _solution.fitness(2); + } +} ; + +class solutionContinue : public moSolContinue +{ +public : + bool operator () (const solution & _solution) + { + const solution sol(_solution); + + return false; + } + + void init() + {} +} ; + +class solutionComparator : public moComparator +{ +public : + bool operator () (const solution & _solution1 , const solution & _solution2) + { + const solution sol1(_solution1); + const solution sol2(_solution2); + + return true; + } +} ; + +class solutionPerturbation : public eoMonOp +{ +public : + bool operator () (solution & _solution) + { + solution sol(_solution); + + return true; + } +} ; + +//----------------------------------------------------------------------------- + +int +main() +{ + cout << "[ moILS ] ==> "; + + solution sol; + + sol.fitness(0); + + testMoveInit init; + testMoveNext next; + testMoveIncrEval incrEval; + testMoveSelect select; + solutionEval eval; + + moHC hc(init, next, incrEval, select, eval); + + solutionContinue continu; + solutionComparator comparator; + solutionPerturbation perturbation; + + moILS ils(hc, continu, comparator, perturbation, eval); + + ils(sol); + + if(sol.fitness()!=2) + { + cout << "KO" << endl; + return EXIT_FAILURE; + } + + cout << "OK" << endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moImprBestFitAspirCrit.cpp b/trunk/paradiseo-mo/test/t-moImprBestFitAspirCrit.cpp new file mode 100644 index 000000000..f0ce954b9 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moImprBestFitAspirCrit.cpp @@ -0,0 +1,107 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moImprBestFitAspirCrit.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + +typedef EO solution; + +class testMove : public moMove +{ +public : + void operator () (solution & _solution) + { + _solution=_solution; + } +} ; + +//----------------------------------------------------------------------------- + +int +main() +{ + unsigned int i; + + moImprBestFitAspirCrit aspirCriterion; + + testMove move; + + cout << "[ moImprBestFitAspirCrit ] ==> "; + + aspirCriterion(move, 10); + + i=0; + while ( !aspirCriterion(move,i) && i<15) + { + i++; + } + + if(i!=10) + { + cout << "KO" << endl; + cout << "before init, i = " << i << endl; + return EXIT_FAILURE; + } + + aspirCriterion.init(); + aspirCriterion(move, i); + + i=0; + while ( !aspirCriterion(move,i) && i<15) + { + i++; + } + + if(i!=10) + { + cout << "KO" << endl; + cout << "after init, i = " << i << endl; + return EXIT_FAILURE; + } + + cout << "OK" << std::endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moItRandNextMove.cpp b/trunk/paradiseo-mo/test/t-moItRandNextMove.cpp new file mode 100644 index 000000000..ed7220086 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moItRandNextMove.cpp @@ -0,0 +1,114 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moItRandNextMove.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + +typedef EO solution; + +class testMove : public moMove +{ +public : + void operator () (solution & _solution) + { + _solution=_solution; + } +} ; + +class testRandMove : public moRandMove +{ +public : + void operator () (testMove & _move) + { + _move=_move; + } +}; + +//----------------------------------------------------------------------------- + +int +main() +{ + unsigned int i; + + testMove move; + solution sol; + + testRandMove rand; + + moItRandNextMove next(rand, 10); + + cout << "[ moItRandNextMove ] ==> "; + + i=0; + while( next(move, sol) && i<15 ) + { + i++; + } + + if(i!=11) + { + cout << "KO" << endl; + cout << "First time, i = " << i << endl; + return EXIT_FAILURE; + } + + i=0; + while( next(move, sol) && i<15 ) + { + i++; + } + + if(i!=11) + { + cout << "KO" << endl; + cout << "Second time, i = " << i << endl; + return EXIT_FAILURE; + } + + cout << "OK" << endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moLSCheckPoint.cpp b/trunk/paradiseo-mo/test/t-moLSCheckPoint.cpp new file mode 100644 index 000000000..0ef842248 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moLSCheckPoint.cpp @@ -0,0 +1,114 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moLSCheckPoint.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + +typedef EO solution; + +class testMove : public moMove +{ +public : + void operator () (solution & _solution) + { + _solution=_solution; + } +} ; + +class testBF : public eoBF +{ + void operator () (const testMove & _move, const testMove::EOType & _solution) + { + const testMove move(_move); + const testMove::EOType sol(_solution); + std::ofstream os("test.txt"); + os << "OK" << endl; + } +}; + +//----------------------------------------------------------------------------- + +int +main() +{ + unsigned int i; + std::string result; + + testBF test; + moLSCheckPoint checkpoint; + + solution sol; + + testMove move; + + cout << "[ moLSCheckPoint ] ==> "; + + i=0; + + checkpoint.add(test); + checkpoint(move, sol); + + std::ifstream is("test.txt"); + + if(!is.is_open()) + { + cout << "KO" << endl; + cout << "test.txt does not exist" << endl; + return EXIT_FAILURE; + } + + is >> result; + + if(result.compare("OK")!=0) + { + cout << "KO" << endl; + cout << "result = " << result << endl; + return EXIT_FAILURE; + } + + cout << "OK" << endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moLinearCoolingSchedule.cpp b/trunk/paradiseo-mo/test/t-moLinearCoolingSchedule.cpp new file mode 100644 index 000000000..f8155d669 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moLinearCoolingSchedule.cpp @@ -0,0 +1,80 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moLinearCoolingSchedule.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + + +//----------------------------------------------------------------------------- + +int +main() +{ + unsigned int i; + double temperature; + + moLinearCoolingSchedule coolingSchedule( 1.0, 0.5 ); + + temperature=2.0; + + cout << "[ moLinearCoolingSchedule ] ==> "; + + i=0; + while( coolingSchedule(temperature) ) + { + i++; + } + + if(i!=1) + { + cout << "KO" << endl; + cout << "i = " << i << endl; + return EXIT_FAILURE; + } + + cout << "OK" << endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moNoAspirCrit.cpp b/trunk/paradiseo-mo/test/t-moNoAspirCrit.cpp new file mode 100644 index 000000000..ca4e05c71 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moNoAspirCrit.cpp @@ -0,0 +1,80 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moNoAspirCrit.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + +typedef EO solution; + +class testMove : public moMove +{ +public : + void operator () (solution & _solution) + { + _solution=_solution; + } +} ; + +//----------------------------------------------------------------------------- + +int +main() +{ + unsigned int i; + moNoAspirCrit aspirCriterion; + testMove move; + + cout << "[ moNoAspirCrit ] ==> "; + + if( aspirCriterion(move, i) ) + { + cout << "KO" << endl; + return EXIT_FAILURE; + } + + cout << "OK" << std::endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moNoFitImprSolContinue.cpp b/trunk/paradiseo-mo/test/t-moNoFitImprSolContinue.cpp new file mode 100644 index 000000000..98d281443 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moNoFitImprSolContinue.cpp @@ -0,0 +1,81 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moNoFitImprSolContinue.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + +typedef EO solution; + +//----------------------------------------------------------------------------- + +int +main() +{ + unsigned int i; + solution sol; + + moNoFitImprSolContinue continu(10); + + cout << "[ moNoFitImprSolContinue ] ==> "; + + sol.fitness(2); + + i=0; + while( continu(sol) ) + { + i++; + } + + if(i!=10) + { + cout << "KO" << endl; + cout << "i = " << i << endl; + return EXIT_FAILURE; + } + + cout << "OK" << endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moRandImprSelect.cpp b/trunk/paradiseo-mo/test/t-moRandImprSelect.cpp new file mode 100644 index 000000000..9a66fd961 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moRandImprSelect.cpp @@ -0,0 +1,103 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moRandImprSelect.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + +typedef EO solution; + +class testMove : public moMove +{ +public : + void operator () (solution & _solution) + { + _solution=_solution; + } +} ; + +//----------------------------------------------------------------------------- + +int +main() +{ + unsigned int i, fitness; + + moRandImprSelect selection; + + solution sol; + + testMove move; + + cout << "[ moRandImprSelect ] ==> "; + + i=fitness=0; + + selection.init(5); + + for(i=1;i<10;i++) + { + if(! selection.update(move, i) ) + { + cout << "KO" << endl; + cout << "update is false" << endl; + return EXIT_FAILURE; + } + } + + for(i=0;i<10;i++) + { + selection(move, fitness); + if(fitness<=5) + { + cout << "KO" << endl; + cout << "fitness = " << fitness << endl; + return EXIT_FAILURE; + } + } + + cout << "OK" << endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moSA.cpp b/trunk/paradiseo-mo/test/t-moSA.cpp new file mode 100644 index 000000000..b66128a51 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moSA.cpp @@ -0,0 +1,147 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moSA.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + +typedef EO solution; + +class testMove : public moMove +{ +public : + void operator () (solution & _solution) + { + solution sol=_solution; + } +} ; + +class testRandMove : public moRandMove +{ +public : + void operator () (testMove & _move) + { + _move=_move; + } +}; + +class testMoveIncrEval : public moMoveIncrEval +{ +public : + unsigned int operator () (const testMove & _move, const solution & _solution) + { + const testMove move(_move); + const solution solution(_solution); + + return 2; + } +} ; + +class solutionContinue : public moSolContinue +{ +public : + bool operator () (const solution & _solution) + { + const solution sol(_solution); + + return false; + } + + void init() + {} +} ; + +class testCooling : public moCoolingSchedule +{ +public : + bool operator () (double & _temperature) + { + double temperature; + temperature=_temperature; + + return false; + } +}; + +class solutionEval : public eoEvalFunc +{ +public : + void operator () (solution & _solution) + { + _solution.fitness(2); + } +} ; + + +//----------------------------------------------------------------------------- + +int +main() +{ + cout << "[ moSA ] ==> "; + + solution sol; + + sol.fitness(0); + + testRandMove rand; + testMoveIncrEval incrEval; + solutionContinue continu; + testCooling cooling; + solutionEval eval; + + moSA sa(rand, incrEval, continu, 10.0, cooling, eval); + + sa(sol); + + if(sol.fitness()!=2) + { + cout << "KO" << endl; + return EXIT_FAILURE; + } + + cout << "OK" << endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moSimpleMoveTabuList.cpp b/trunk/paradiseo-mo/test/t-moSimpleMoveTabuList.cpp new file mode 100644 index 000000000..fe4f0c94c --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moSimpleMoveTabuList.cpp @@ -0,0 +1,92 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moSimpleMoveTabuList.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + +typedef EO solution; + +class testMove : public moMove +{ +public : + void operator () (solution & _solution) + { + _solution=_solution; + } + + bool operator == (const testMove & _move) + { + testMove move; + move=(testMove)_move; + + return true; + } +} ; + +//----------------------------------------------------------------------------- + +int +main() +{ + moSimpleMoveTabuList tabuList(1); + + solution sol; + + testMove move; + + cout << "[ moSimpleMoveTabuList ] ==> "; + + tabuList.add(move, sol); + + if( !tabuList(move, sol) ) + { + cout << "KO" << endl; + return EXIT_FAILURE; + } + + cout << "OK" << endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moSimpleSolutionTabuList.cpp b/trunk/paradiseo-mo/test/t-moSimpleSolutionTabuList.cpp new file mode 100644 index 000000000..9ed64fe13 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moSimpleSolutionTabuList.cpp @@ -0,0 +1,92 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moSimpleSolutionTabuList.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + +typedef EO solution; + +class testMove : public moMove +{ +public : + void operator () (solution & _solution) + { + _solution=_solution; + } + + bool operator == (const testMove & _move) + { + testMove move; + move=(testMove)_move; + + return true; + } +} ; + +//----------------------------------------------------------------------------- + +int +main() +{ + moSimpleMoveTabuList tabuList(1); + + solution sol; + + testMove move; + + cout << "[ moSimpleSolutionTabuList ] ==> "; + + tabuList.add(move, sol); + + if( !tabuList(move, sol) ) + { + cout << "KO" << endl; + return EXIT_FAILURE; + } + + cout << "OK" << endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moSteadyFitSolContinue.cpp b/trunk/paradiseo-mo/test/t-moSteadyFitSolContinue.cpp new file mode 100644 index 000000000..26b25e2d3 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moSteadyFitSolContinue.cpp @@ -0,0 +1,84 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moSteadyFitSolContinue.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + +typedef EO solution; + +//----------------------------------------------------------------------------- + +int +main() +{ + unsigned int i; + solution sol; + + moSteadyFitSolContinue continu(10,10); + + cout << "[ moSteadyFitSolContinue ] ==> "; + + i=0; + sol.fitness(i); + while( continu(sol) && i<50) + { + i++; + if(i<11) + { + sol.fitness(i); + } + } + + if(i!=20) + { + cout << "KO" << endl; + cout << "i = " << i << endl; + return EXIT_FAILURE; + } + + cout << "OK" << endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moTS.cpp b/trunk/paradiseo-mo/test/t-moTS.cpp new file mode 100644 index 000000000..65eb63de1 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moTS.cpp @@ -0,0 +1,190 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moTS.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + +typedef EO solution; + +class testMove : public moMove +{ +public : + void operator () (solution & _solution) + { + solution sol=_solution; + } +} ; + +class testMoveInit : public moMoveInit +{ +public : + void operator () (testMove & _move, const solution & _solution) + { + testMove move=_move; + const solution sol(_solution); + } +} ; + +class testMoveNext : public moNextMove +{ +public : + bool operator () (testMove & _move, const solution & _solution) + { + testMove move(_move); + const solution sol(_solution); + + return false; + } +} ; + +class testMoveIncrEval : public moMoveIncrEval +{ +public : + unsigned int operator () (const testMove & _move, const solution & _solution) + { + const testMove move(_move); + const solution solution(_solution); + + return 2; + } +} ; + +class testTabuList : public moTabuList +{ +public: + bool operator() (const testMove & _move, const solution & _solution) + { + const testMove move(_move); + const solution sol(_solution); + + return false; + } + + void add(const testMove & _move, const solution & _solution) + { + const testMove move(_move); + const solution sol(_solution); + } + + void update() + {} + + void init() + {} +}; + +class testAspirCrit : public moAspirCrit +{ +public: + bool operator() (const testMove & _move, const unsigned int & _fitness) + { + unsigned int fitness; + const testMove move(_move); + fitness=_fitness; + + return false; + } + + void init() + {} +}; + +class solutionContinue : public moSolContinue +{ +public : + bool operator () (const solution & _solution) + { + const solution sol(_solution); + + return false; + } + + void init() + {} +} ; + +class solutionEval : public eoEvalFunc +{ +public : + void operator () (solution & _solution) + { + _solution.fitness(2); + } +} ; + + +//----------------------------------------------------------------------------- + +int +main() +{ + cout << "[ moTS ] ==> "; + + solution sol; + + sol.fitness(0); + + testMoveInit init; + testMoveNext next; + testMoveIncrEval incrEval; + testTabuList tabuList; + testAspirCrit aspirCrit; + solutionContinue continu; + solutionEval eval; + + moTS ts(init, next, incrEval, tabuList, aspirCrit, continu, eval); + + ts(sol); + + if(sol.fitness()!=2) + { + cout << "KO" << endl; + return EXIT_FAILURE; + } + + cout << "OK" << endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/test/t-moTSMoveLoopExpl.cpp b/trunk/paradiseo-mo/test/t-moTSMoveLoopExpl.cpp new file mode 100644 index 000000000..374f8f753 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moTSMoveLoopExpl.cpp @@ -0,0 +1,165 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moTSMoveLoopExpl.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +using std::cout; +using std::endl; + +//----------------------------------------------------------------------------- + +typedef EO solution; + +class testMove : public moMove +{ +public : + void operator () (solution & _solution) + { + solution sol=_solution; + } +} ; + +class testMoveInit : public moMoveInit +{ +public : + void operator () (testMove & _move, const solution & _solution) + { + testMove move=_move; + const solution sol(_solution); + } +} ; + +class testMoveNext : public moNextMove +{ +public : + bool operator () (testMove & _move, const solution & _solution) + { + testMove move(_move); + const solution sol(_solution); + + return false; + } +} ; + +class testMoveIncrEval : public moMoveIncrEval +{ +public : + unsigned int operator () (const testMove & _move, const solution & _solution) + { + const testMove move(_move); + const solution solution(_solution); + + return 2; + } +} ; + +class testTabuList : public moTabuList +{ +public: + bool operator() (const testMove & _move, const solution & _solution) + { + const testMove move(_move); + const solution sol(_solution); + + return false; + } + + void add(const testMove & _move, const solution & _solution) + { + const testMove move(_move); + const solution sol(_solution); + } + + void update() + {} + + void init() + {} +}; + +class testAspirCrit : public moAspirCrit +{ +public: + bool operator() (const testMove & _move, const unsigned int & _fitness) + { + unsigned int fitness; + const testMove move(_move); + fitness=_fitness; + + return false; + } + + void init() + {} +}; + +//----------------------------------------------------------------------------- + +int +main() +{ + cout << "[ moTSMoveLoopExpl ] ==> "; + + solution sol1 ,sol2; + + sol1.fitness(0); + sol2.fitness(0); + + testMoveInit init; + testMoveNext next; + testMoveIncrEval incrEval; + testTabuList tabuList; + testAspirCrit aspirCrit; + + moTSMoveLoopExpl explorer(init, next, incrEval, tabuList, aspirCrit); + + explorer(sol1, sol2); + + if(sol2.fitness()!=2) + { + cout << "KO" << endl; + return EXIT_FAILURE; + } + + cout << "OK" << endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_init.cpp b/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_init.cpp index bbf5a3e1a..2e593db0a 100644 --- a/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_init.cpp +++ b/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_init.cpp @@ -36,8 +36,10 @@ #include "two_opt_init.h" -void TwoOptInit :: operator () (TwoOpt & __move, const Route & __route) +void TwoOptInit :: operator () (TwoOpt & _move, const Route & _route) { - __move.first = 0 ; - __move.second = 2 ; + Route route=_route; + + _move.first = 0 ; + _move.second = 2 ; } diff --git a/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_init.h b/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_init.h index d6d22f8da..1b2a5e376 100644 --- a/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_init.h +++ b/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_init.h @@ -47,7 +47,7 @@ class TwoOptInit : public moMoveInit public : - void operator () (TwoOpt & __move, const Route & __route) ; + void operator () (TwoOpt & _move, const Route & _route) ; } ; diff --git a/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_next.cpp b/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_next.cpp index 47335a515..2438390fd 100644 --- a/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_next.cpp +++ b/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_next.cpp @@ -37,19 +37,21 @@ #include "two_opt_next.h" #include "graph.h" -bool TwoOptNext :: operator () (TwoOpt & __move, const Route & __route) +bool TwoOptNext :: operator () (TwoOpt & _move, const Route & _route) { - if (__move.first == Graph :: size () - 4 && __move.second == __move.first + 2) + Route route=_route; + + if (_move.first == Graph :: size () - 4 && _move.second == _move.first + 2) { return false ; } else { - __move.second ++ ; - if (__move.second == Graph :: size () - 1) + _move.second ++ ; + if (_move.second == Graph :: size () - 1) { - __move.first ++ ; - __move.second = __move.first + 2 ; + _move.first ++ ; + _move.second = _move.first + 2 ; } return true ; diff --git a/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_next.h b/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_next.h index 59856db9a..f57595cd6 100644 --- a/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_next.h +++ b/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_next.h @@ -46,7 +46,7 @@ class TwoOptNext : public moNextMove public : - bool operator () (TwoOpt & __move, const Route & __route) ; + bool operator () (TwoOpt & _move, const Route & _route) ; } ; diff --git a/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_tabu_list.cpp b/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_tabu_list.cpp index 2a2f009ed..290eef7f7 100644 --- a/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_tabu_list.cpp +++ b/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_tabu_list.cpp @@ -39,7 +39,8 @@ #define TABU_LENGTH 10 -void TwoOptTabuList :: init () +void +TwoOptTabuList :: init () { // Size (eventually) tabu_span.resize (Graph :: size ()) ; @@ -58,23 +59,32 @@ void TwoOptTabuList :: init () } } -bool TwoOptTabuList :: operator () (const TwoOpt & __move, const Route & __sol) +bool +TwoOptTabuList :: operator () (const TwoOpt & _move, const Route & _route) { - return tabu_span [__move.first] [__move.second] > 0 ; + Route route=_route; + + return tabu_span [_move.first] [_move.second] > 0 ; } -void TwoOptTabuList :: add (const TwoOpt & __move, const Route & __sol) +void +TwoOptTabuList :: add (const TwoOpt & _move, const Route & _route) { - tabu_span [__move.first] [__move.second] = tabu_span [__move.second] [__move.first] = TABU_LENGTH ; + Route route=_route; + + tabu_span [_move.first] [_move.second] = tabu_span [_move.second] [_move.first] = TABU_LENGTH ; } -void TwoOptTabuList :: update () +void +TwoOptTabuList :: update () { - for (unsigned int i = 0 ; i < tabu_span.size () ; i ++) + unsigned int i,j; + + for (i = 0 ; i < tabu_span.size () ; i ++) { - for (unsigned int j = 0 ; j < tabu_span [i].size () ; j ++) + for (j = 0 ; j < tabu_span [i].size () ; j ++) { - if (tabu_span [i] [j] > 0) + if ( tabu_span [i] [j] > 0 ) { tabu_span [i] [j] -- ; } diff --git a/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_tabu_list.h b/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_tabu_list.h index 57490fc9a..236919f69 100644 --- a/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_tabu_list.h +++ b/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_tabu_list.h @@ -46,9 +46,9 @@ class TwoOptTabuList : public moTabuList { public : - bool operator () (const TwoOpt & __move, const Route & __sol) ; + bool operator () (const TwoOpt & _move, const Route & _route) ; - void add (const TwoOpt & __move, const Route & __sol) ; + void add (const TwoOpt & _move, const Route & _route) ; void update () ;