Tests have been included and src code has been updated to avoid compilation warnings

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@937 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jboisson 2008-02-13 10:38:33 +00:00
commit acc73239fb
37 changed files with 2531 additions and 47 deletions

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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;
}

View file

@ -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)
{

View file

@ -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);

View file

@ -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")

View file

@ -0,0 +1,101 @@
/*
* <t-moBestImprSelect.cpp>
* 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> // EO
#include <mo> // MO
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
typedef EO<unsigned int> solution;
class testMove : public moMove <solution>
{
public :
void operator () (solution & _solution)
{
_solution=_solution;
}
} ;
//-----------------------------------------------------------------------------
int
main()
{
unsigned int i, fitness;
moBestImprSelect<testMove> 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;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,80 @@
/*
* <t-moExponentialCoolingSchedule.cpp>
* 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> // EO
#include <mo> // 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;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,96 @@
/*
* <t-moFirstImprSelect.cpp>
* 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> // EO
#include <mo> // MO
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
typedef EO<unsigned int> solution;
class testMove : public moMove <solution>
{
public :
void operator () (solution & _solution)
{
_solution=_solution;
}
} ;
//-----------------------------------------------------------------------------
int
main()
{
unsigned int i, fitness;
moFirstImprSelect<testMove> 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;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,74 @@
/*
* <t-moFitComparator.cpp>
* 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-moFitComparator.cpp
//-----------------------------------------------------------------------------
#include <eo> // EO
#include <mo> // MO
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
typedef EO<unsigned int> solution;
//-----------------------------------------------------------------------------
int
main()
{
solution sol1, sol2;
moFitComparator<solution> comparator;
sol1.fitness(0);
sol2.fitness(1);
cout << "[ moFitComparator ] ==> ";
if( comparator(sol1,sol2) )
{
cout << "KO" << endl;
return EXIT_FAILURE;
}
cout << "OK" << endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,81 @@
/*
* <t-moFitSolContinue.cpp>
* 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> // EO
#include <mo> // MO
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
typedef EO<unsigned int> solution;
//-----------------------------------------------------------------------------
int
main()
{
unsigned int i;
solution sol;
moFitSolContinue<solution> 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;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,94 @@
/*
* <t-moGenSolContinue.cpp>
* 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> // EO
#include <mo> // MO
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
typedef EO<unsigned int> solution;
//-----------------------------------------------------------------------------
int
main()
{
unsigned int i;
solution sol;
moGenSolContinue<solution> 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;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,164 @@
/*
* <t-moHC.cpp>
* 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> // EO
#include <mo> // MO
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
typedef EO<unsigned int> solution;
class testMove : public moMove <solution>
{
public :
void operator () (solution & _solution)
{
solution sol=_solution;
}
} ;
class testMoveInit : public moMoveInit <testMove>
{
public :
void operator () (testMove & _move, const solution & _solution)
{
testMove move=_move;
const solution sol(_solution);
}
} ;
class testMoveNext : public moNextMove <testMove>
{
public :
bool operator () (testMove & _move, const solution & _solution)
{
testMove move=_move;
const solution sol(_solution);
return false;
}
} ;
class testMoveIncrEval : public moMoveIncrEval <testMove>
{
public :
unsigned int operator () (const testMove & _move, const solution & _solution)
{
const testMove move(_move);
const solution solution(_solution);
return 2;
}
} ;
class testMoveSelect : public moMoveSelect <testMove>
{
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 <solution>
{
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<testMove> hc(init, next, incrEval, select, eval);
hc(sol);
if(sol.fitness()!=2)
{
cout << "KO" << endl;
return EXIT_FAILURE;
}
cout << "OK" << endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,154 @@
/*
* <t-moHCMoveLoopExpl.cpp>
* 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> // EO
#include <mo> // MO
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
typedef EO<unsigned int> solution;
class testMove : public moMove <solution>
{
public :
void operator () (solution & _solution)
{
solution sol=_solution;
}
} ;
class testMoveInit : public moMoveInit <testMove>
{
public :
void operator () (testMove & _move, const solution & _solution)
{
testMove move=_move;
const solution sol(_solution);
}
} ;
class testMoveNext : public moNextMove <testMove>
{
public :
bool operator () (testMove & _move, const solution & _solution)
{
testMove move=_move;
const solution sol(_solution);
return false;
}
} ;
class testMoveIncrEval : public moMoveIncrEval <testMove>
{
public :
unsigned int operator () (const testMove & _move, const solution & _solution)
{
const testMove move(_move);
const solution solution(_solution);
return 2;
}
} ;
class testMoveSelect : public moMoveSelect <testMove>
{
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<testMove> explorer(init, next, incrEval, select);
explorer(sol1, sol2);
if(sol2.fitness()!=2)
{
cout << "KO" << endl;
return EXIT_FAILURE;
}
cout << "OK" << endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,206 @@
/*
* <t-moILS.cpp>
* 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> // EO
#include <mo> // MO
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
typedef EO<unsigned int> solution;
class testMove : public moMove <solution>
{
public :
void operator () (solution & _solution)
{
solution sol=_solution;
}
} ;
class testMoveInit : public moMoveInit <testMove>
{
public :
void operator () (testMove & _move, const solution & _solution)
{
testMove move=_move;
const solution sol(_solution);
}
} ;
class testMoveNext : public moNextMove <testMove>
{
public :
bool operator () (testMove & _move, const solution & _solution)
{
testMove move=_move;
const solution sol(_solution);
return false;
}
} ;
class testMoveIncrEval : public moMoveIncrEval <testMove>
{
public :
unsigned int operator () (const testMove & _move, const solution & _solution)
{
const testMove move(_move);
const solution solution(_solution);
return 2;
}
} ;
class testMoveSelect : public moMoveSelect <testMove>
{
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 <solution>
{
public :
void operator () (solution & _solution)
{
_solution.fitness(2);
}
} ;
class solutionContinue : public moSolContinue<solution>
{
public :
bool operator () (const solution & _solution)
{
const solution sol(_solution);
return false;
}
void init()
{}
} ;
class solutionComparator : public moComparator<solution>
{
public :
bool operator () (const solution & _solution1 , const solution & _solution2)
{
const solution sol1(_solution1);
const solution sol2(_solution2);
return true;
}
} ;
class solutionPerturbation : public eoMonOp<solution>
{
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<testMove> hc(init, next, incrEval, select, eval);
solutionContinue continu;
solutionComparator comparator;
solutionPerturbation perturbation;
moILS<testMove> ils(hc, continu, comparator, perturbation, eval);
ils(sol);
if(sol.fitness()!=2)
{
cout << "KO" << endl;
return EXIT_FAILURE;
}
cout << "OK" << endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,107 @@
/*
* <t-moImprBestFitAspirCrit.cpp>
* 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> // EO
#include <mo> // MO
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
typedef EO<unsigned int> solution;
class testMove : public moMove <solution>
{
public :
void operator () (solution & _solution)
{
_solution=_solution;
}
} ;
//-----------------------------------------------------------------------------
int
main()
{
unsigned int i;
moImprBestFitAspirCrit<testMove> 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;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,114 @@
/*
* <t-moItRandNextMove.cpp>
* 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> // EO
#include <mo> // MO
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
typedef EO<unsigned int> solution;
class testMove : public moMove <solution>
{
public :
void operator () (solution & _solution)
{
_solution=_solution;
}
} ;
class testRandMove : public moRandMove<testMove>
{
public :
void operator () (testMove & _move)
{
_move=_move;
}
};
//-----------------------------------------------------------------------------
int
main()
{
unsigned int i;
testMove move;
solution sol;
testRandMove rand;
moItRandNextMove<testMove> 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;
}
//-----------------------------------------------------------------------------

Some files were not shown because too many files have changed in this diff Show more