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

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

@ -1,7 +1,7 @@
/*
* <t-mo.cpp>
* <t-moFitComparator.cpp>
* 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> // EO
#include <mo.h> // MO
#include <mo> // MO
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
typedef EO<float> Chrom;
typedef EO<unsigned int> solution;
//-----------------------------------------------------------------------------
int main()
int
main()
{
Chrom chrom1, chrom2;
solution sol1, sol2;
std::cout << "chrom1 = " << chrom1 << std::endl
<< "chrom2 = " << chrom2 << std::endl;
moFitComparator<solution> 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;
}
//-----------------------------------------------------------------------------

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

View file

@ -0,0 +1,114 @@
/*
* <t-moLSCheckPoint.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-moLSCheckPoint.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 testBF : public eoBF<const testMove & , const testMove::EOType &, void>
{
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<testMove> 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;
}
//-----------------------------------------------------------------------------

View file

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

View file

@ -0,0 +1,80 @@
/*
* <t-moNoAspirCrit.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-moNoAspirCrit.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;
moNoAspirCrit<testMove> aspirCriterion;
testMove move;
cout << "[ moNoAspirCrit ] ==> ";
if( aspirCriterion(move, i) )
{
cout << "KO" << endl;
return EXIT_FAILURE;
}
cout << "OK" << std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,81 @@
/*
* <t-moNoFitImprSolContinue.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-moNoFitImprSolContinue.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;
moNoFitImprSolContinue<solution> 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;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,103 @@
/*
* <t-moRandImprSelect.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-moRandImprSelect.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;
moRandImprSelect<testMove> 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;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,147 @@
/*
* <t-moSA.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-moSA.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 testRandMove : public moRandMove<testMove>
{
public :
void operator () (testMove & _move)
{
_move=_move;
}
};
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 solutionContinue : public moSolContinue<solution>
{
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 <solution>
{
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<testMove> 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;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,92 @@
/*
* <t-moSimpleMoveTabuList.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-moSimpleMoveTabuList.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;
}
bool operator == (const testMove & _move)
{
testMove move;
move=(testMove)_move;
return true;
}
} ;
//-----------------------------------------------------------------------------
int
main()
{
moSimpleMoveTabuList<testMove> 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;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,92 @@
/*
* <t-moSimpleSolutionTabuList.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-moSimpleSolutionTabuList.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;
}
bool operator == (const testMove & _move)
{
testMove move;
move=(testMove)_move;
return true;
}
} ;
//-----------------------------------------------------------------------------
int
main()
{
moSimpleMoveTabuList<testMove> 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;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,84 @@
/*
* <t-moSteadyFitSolContinue.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-moSteadyFitSolContinue.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;
moSteadyFitSolContinue<solution> 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;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,190 @@
/*
* <t-moTS.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-moTS.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 testTabuList : public moTabuList<testMove>
{
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<testMove>
{
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<solution>
{
public :
bool operator () (const solution & _solution)
{
const solution sol(_solution);
return false;
}
void init()
{}
} ;
class solutionEval : public eoEvalFunc <solution>
{
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<testMove> 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;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,165 @@
/*
* <t-moTSMoveLoopExpl.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-moTSMoveLoopExpl.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 testTabuList : public moTabuList<testMove>
{
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<testMove>
{
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<testMove> 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;
}
//-----------------------------------------------------------------------------