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:
parent
50863ab6b9
commit
acc73239fb
37 changed files with 2531 additions and 47 deletions
|
|
@ -58,7 +58,8 @@ class moBestImprSelect:public moMoveSelect < M >
|
||||||
void init (const Fitness & _fitness)
|
void init (const Fitness & _fitness)
|
||||||
{
|
{
|
||||||
//Code only used to avoid warning because _fitness is not used in this procedure.
|
//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;
|
first_time = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ class moGenSolContinue:public moSolContinue < EOT >
|
||||||
bool operator () (const EOT & _solution)
|
bool operator () (const EOT & _solution)
|
||||||
{
|
{
|
||||||
//code only used for avoiding warning because _sol is not used in this function.
|
//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);
|
return (++generationNumber < generationMaximumNumber);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,10 +53,8 @@ class moImprBestFitAspirCrit:public moAspirCrit < M >
|
||||||
typedef typename M::EOType::Fitness Fitness;
|
typedef typename M::EOType::Fitness Fitness;
|
||||||
|
|
||||||
//! Contructor
|
//! Contructor
|
||||||
moImprBestFitAspirCrit ()
|
moImprBestFitAspirCrit (): first_time(true)
|
||||||
{
|
{}
|
||||||
first_time = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Initialisation procedure
|
//! Initialisation procedure
|
||||||
void init ()
|
void init ()
|
||||||
|
|
@ -74,6 +72,9 @@ class moImprBestFitAspirCrit:public moAspirCrit < M >
|
||||||
*/
|
*/
|
||||||
bool operator () (const M & _move, const Fitness & _fitness)
|
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)
|
if (first_time)
|
||||||
{
|
{
|
||||||
best_fitness = _fitness;
|
best_fitness = _fitness;
|
||||||
|
|
|
||||||
|
|
@ -73,9 +73,9 @@ class moItRandNextMove:public moNextMove < M >
|
||||||
bool operator () (M & _move, const EOT & _solution)
|
bool operator () (M & _move, const EOT & _solution)
|
||||||
{
|
{
|
||||||
//code only used to avoid warning because _solution is not used in this function.
|
//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;
|
iteration_number = 0;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@
|
||||||
/*!
|
/*!
|
||||||
Only a description...See moMoveLoopExpl.
|
Only a description...See moMoveLoopExpl.
|
||||||
*/
|
*/
|
||||||
template < class M > class
|
template < class M >
|
||||||
moMoveExpl : public eoBF < const typename M::EOType &, typename M::EOType &, void >
|
class moMoveExpl : public eoBF < const typename M::EOType &, typename M::EOType &, void >
|
||||||
{};
|
{};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@
|
||||||
template < class M >
|
template < class M >
|
||||||
class moNoAspirCrit:public moAspirCrit < M >
|
class moNoAspirCrit:public moAspirCrit < M >
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
//! Function which describes the aspiration criterion behaviour
|
//! Function which describes the aspiration criterion behaviour
|
||||||
/*!
|
/*!
|
||||||
Does nothing.
|
Does nothing.
|
||||||
|
|
@ -56,6 +58,11 @@ class moNoAspirCrit:public moAspirCrit < M >
|
||||||
*/
|
*/
|
||||||
bool operator () (const M & _move, const typename M::EOType::Fitness & _fitness)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ class moSimpleMoveTabuList: public moTabuList < M >
|
||||||
void add(const M & _move, const EOT & _solution)
|
void add(const M & _move, const EOT & _solution)
|
||||||
{
|
{
|
||||||
//code only used to avoid warning because _solution is not used in this function.
|
//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)
|
if (memory_size!=0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -68,10 +68,10 @@ class moSimpleSolutionTabuList: public moTabuList < M >
|
||||||
*/
|
*/
|
||||||
bool operator () (const M & _move, const EOT & _solution)
|
bool operator () (const M & _move, const EOT & _solution)
|
||||||
{
|
{
|
||||||
solutionIterator it;
|
M move((M)_move);
|
||||||
|
EOT solution((EOT)_solution);
|
||||||
|
|
||||||
M move=(M)_move;
|
solutionIterator it;
|
||||||
EOT solution=(EOT) _solution;
|
|
||||||
|
|
||||||
move(solution);
|
move(solution);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,28 @@ ENDIF(WIN32 AND NOT CYGWIN)
|
||||||
### 3) Define your targets and link the librairies
|
### 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})
|
FOREACH (test ${TEST_LIST})
|
||||||
SET ("T_${test}_SOURCES" "${test}.cpp")
|
SET ("T_${test}_SOURCES" "${test}.cpp")
|
||||||
|
|
|
||||||
101
trunk/paradiseo-mo/test/t-moBestImprSelect.cpp
Normal file
101
trunk/paradiseo-mo/test/t-moBestImprSelect.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
80
trunk/paradiseo-mo/test/t-moExponentialCoolingSchedule.cpp
Normal file
80
trunk/paradiseo-mo/test/t-moExponentialCoolingSchedule.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
96
trunk/paradiseo-mo/test/t-moFirstImprSelect.cpp
Normal file
96
trunk/paradiseo-mo/test/t-moFirstImprSelect.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* <t-mo.cpp>
|
* <t-moFitComparator.cpp>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
* 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)
|
* 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 <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
|
moFitComparator<solution> comparator;
|
||||||
<< "chrom2 = " << chrom2 << std::endl;
|
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
81
trunk/paradiseo-mo/test/t-moFitSolContinue.cpp
Normal file
81
trunk/paradiseo-mo/test/t-moFitSolContinue.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
94
trunk/paradiseo-mo/test/t-moGenSolContinue.cpp
Normal file
94
trunk/paradiseo-mo/test/t-moGenSolContinue.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
164
trunk/paradiseo-mo/test/t-moHC.cpp
Normal file
164
trunk/paradiseo-mo/test/t-moHC.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
154
trunk/paradiseo-mo/test/t-moHCMoveLoopExpl.cpp
Normal file
154
trunk/paradiseo-mo/test/t-moHCMoveLoopExpl.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
206
trunk/paradiseo-mo/test/t-moILS.cpp
Normal file
206
trunk/paradiseo-mo/test/t-moILS.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
107
trunk/paradiseo-mo/test/t-moImprBestFitAspirCrit.cpp
Normal file
107
trunk/paradiseo-mo/test/t-moImprBestFitAspirCrit.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
114
trunk/paradiseo-mo/test/t-moItRandNextMove.cpp
Normal file
114
trunk/paradiseo-mo/test/t-moItRandNextMove.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
114
trunk/paradiseo-mo/test/t-moLSCheckPoint.cpp
Normal file
114
trunk/paradiseo-mo/test/t-moLSCheckPoint.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
80
trunk/paradiseo-mo/test/t-moLinearCoolingSchedule.cpp
Normal file
80
trunk/paradiseo-mo/test/t-moLinearCoolingSchedule.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
80
trunk/paradiseo-mo/test/t-moNoAspirCrit.cpp
Normal file
80
trunk/paradiseo-mo/test/t-moNoAspirCrit.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
81
trunk/paradiseo-mo/test/t-moNoFitImprSolContinue.cpp
Normal file
81
trunk/paradiseo-mo/test/t-moNoFitImprSolContinue.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
103
trunk/paradiseo-mo/test/t-moRandImprSelect.cpp
Normal file
103
trunk/paradiseo-mo/test/t-moRandImprSelect.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
147
trunk/paradiseo-mo/test/t-moSA.cpp
Normal file
147
trunk/paradiseo-mo/test/t-moSA.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
92
trunk/paradiseo-mo/test/t-moSimpleMoveTabuList.cpp
Normal file
92
trunk/paradiseo-mo/test/t-moSimpleMoveTabuList.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
92
trunk/paradiseo-mo/test/t-moSimpleSolutionTabuList.cpp
Normal file
92
trunk/paradiseo-mo/test/t-moSimpleSolutionTabuList.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
84
trunk/paradiseo-mo/test/t-moSteadyFitSolContinue.cpp
Normal file
84
trunk/paradiseo-mo/test/t-moSteadyFitSolContinue.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
190
trunk/paradiseo-mo/test/t-moTS.cpp
Normal file
190
trunk/paradiseo-mo/test/t-moTS.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
165
trunk/paradiseo-mo/test/t-moTSMoveLoopExpl.cpp
Normal file
165
trunk/paradiseo-mo/test/t-moTSMoveLoopExpl.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -36,8 +36,10 @@
|
||||||
|
|
||||||
#include "two_opt_init.h"
|
#include "two_opt_init.h"
|
||||||
|
|
||||||
void TwoOptInit :: operator () (TwoOpt & __move, const Route & __route)
|
void TwoOptInit :: operator () (TwoOpt & _move, const Route & _route)
|
||||||
{
|
{
|
||||||
__move.first = 0 ;
|
Route route=_route;
|
||||||
__move.second = 2 ;
|
|
||||||
|
_move.first = 0 ;
|
||||||
|
_move.second = 2 ;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class TwoOptInit : public moMoveInit <TwoOpt>
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
void operator () (TwoOpt & __move, const Route & __route) ;
|
void operator () (TwoOpt & _move, const Route & _route) ;
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,19 +37,21 @@
|
||||||
#include "two_opt_next.h"
|
#include "two_opt_next.h"
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
|
|
||||||
bool TwoOptNext :: operator () (TwoOpt & __move, const Route & __route)
|
bool TwoOptNext :: operator () (TwoOpt & _move, const Route & _route)
|
||||||
{
|
{
|
||||||
if (__move.first == Graph :: size () - 4 && __move.second == __move.first + 2)
|
Route route=_route;
|
||||||
|
|
||||||
|
if (_move.first == Graph :: size () - 4 && _move.second == _move.first + 2)
|
||||||
{
|
{
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
__move.second ++ ;
|
_move.second ++ ;
|
||||||
if (__move.second == Graph :: size () - 1)
|
if (_move.second == Graph :: size () - 1)
|
||||||
{
|
{
|
||||||
__move.first ++ ;
|
_move.first ++ ;
|
||||||
__move.second = __move.first + 2 ;
|
_move.second = _move.first + 2 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class TwoOptNext : public moNextMove <TwoOpt>
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
bool operator () (TwoOpt & __move, const Route & __route) ;
|
bool operator () (TwoOpt & _move, const Route & _route) ;
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,8 @@
|
||||||
|
|
||||||
#define TABU_LENGTH 10
|
#define TABU_LENGTH 10
|
||||||
|
|
||||||
void TwoOptTabuList :: init ()
|
void
|
||||||
|
TwoOptTabuList :: init ()
|
||||||
{
|
{
|
||||||
// Size (eventually)
|
// Size (eventually)
|
||||||
tabu_span.resize (Graph :: size ()) ;
|
tabu_span.resize (Graph :: size ()) ;
|
||||||
|
|
@ -58,23 +59,32 @@ void TwoOptTabuList :: init ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TwoOptTabuList :: operator () (const TwoOpt & __move, const Route & __sol)
|
bool
|
||||||
|
TwoOptTabuList :: operator () (const TwoOpt & _move, const Route & _route)
|
||||||
{
|
{
|
||||||
return tabu_span [__move.first] [__move.second] > 0 ;
|
Route route=_route;
|
||||||
|
|
||||||
|
return tabu_span [_move.first] [_move.second] > 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwoOptTabuList :: add (const TwoOpt & __move, const Route & __sol)
|
void
|
||||||
|
TwoOptTabuList :: add (const TwoOpt & _move, const Route & _route)
|
||||||
{
|
{
|
||||||
tabu_span [__move.first] [__move.second] = tabu_span [__move.second] [__move.first] = TABU_LENGTH ;
|
Route route=_route;
|
||||||
|
|
||||||
|
tabu_span [_move.first] [_move.second] = tabu_span [_move.second] [_move.first] = TABU_LENGTH ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwoOptTabuList :: update ()
|
void
|
||||||
|
TwoOptTabuList :: update ()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0 ; i < tabu_span.size () ; i ++)
|
unsigned int i,j;
|
||||||
|
|
||||||
|
for (i = 0 ; i < tabu_span.size () ; i ++)
|
||||||
{
|
{
|
||||||
for (unsigned int j = 0 ; j < tabu_span [i].size () ; j ++)
|
for (j = 0 ; j < tabu_span [i].size () ; j ++)
|
||||||
{
|
{
|
||||||
if (tabu_span [i] [j] > 0)
|
if ( tabu_span [i] [j] > 0 )
|
||||||
{
|
{
|
||||||
tabu_span [i] [j] -- ;
|
tabu_span [i] [j] -- ;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,9 @@ class TwoOptTabuList : public moTabuList <TwoOpt>
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
|
|
||||||
bool operator () (const TwoOpt & __move, const Route & __sol) ;
|
bool operator () (const TwoOpt & _move, const Route & _route) ;
|
||||||
|
|
||||||
void add (const TwoOpt & __move, const Route & __sol) ;
|
void add (const TwoOpt & _move, const Route & _route) ;
|
||||||
|
|
||||||
void update () ;
|
void update () ;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue