paradiseo new mo added

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1712 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jhumeau 2010-03-24 10:07:28 +00:00
commit d7496cafff
116 changed files with 12034 additions and 0 deletions

View file

@ -0,0 +1,84 @@
###############################################################################
##
## CMakeLists file for ParadisEO-MO/test
##
###############################################################################
######################################################################################
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${MO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
######################################################################################
######################################################################################
### 2) Specify where CMake can find the libraries
######################################################################################
LINK_DIRECTORIES(${EO_BIN_DIR}/lib)
######################################################################################
######################################################################################
### 3) Define your targets and link the librairies
######################################################################################
SET (TEST_LIST
t-moNeighbor
t-moBitNeighbor
t-moOrderNeighborhood
t-moFullEvalByCopy
t-moFullEvalByModif
t-moNeighborComparator
t-moSolNeighborComparator
t-moTrueContinuator
t-moRndWithoutReplNeighborhood
t-moRndWithReplNeighborhood
t-moFitnessStat
t-moDistanceStat
t-moNeighborhoodStat
t-moCounterMonitorSaver
t-moSolutionStat
t-moCheckpoint
t-moDummyMemory
t-moSolVectorTabuList
t-moBestImprAspiration
t-moSimpleHCexplorer
t-moSimpleHCneutralExplorer
t-moHCneutralExplorer
t-moFirstImprExplorer
t-moRandomWalkExplorer
t-moMetropolisHastingExplorer
t-moRandomNeutralWalkExplorer
t-moTSExplorer
)
FOREACH (test ${TEST_LIST})
SET ("T_${test}_SOURCES" "${test}.cpp")
ENDFOREACH (test)
IF(ENABLE_CMAKE_TESTING)
# Add the tests
FOREACH (test ${TEST_LIST})
ADD_EXECUTABLE(${test} ${T_${test}_SOURCES})
ADD_TEST(${test} ${test})
ENDFOREACH (test)
# Link the librairies
FOREACH (test ${TEST_LIST})
TARGET_LINK_LIBRARIES(${test} ga es eoutils eo)
ENDFOREACH (test)
ENDIF(ENABLE_CMAKE_TESTING)
######################################################################################

View file

@ -0,0 +1,204 @@
/*
<moTestClass.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can 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
*/
#ifndef _moTestClass_h
#define _moTestClass_h
#include <EO.h>
#include <eoEvalFunc.h>
#include <neighborhood/moNeighbor.h>
#include <neighborhood/moBackableNeighbor.h>
#include <neighborhood/moNeighborhood.h>
#include <neighborhood/moRndNeighborhood.h>
#include <eval/moEval.h>
#include <ga/eoBit.h>
#include <eoScalarFitness.h>
#include <neighborhood/moOrderNeighborhood.h>
#include <neighborhood/moBitNeighbor.h>
#include <utils/eoMonitor.h>
#include <utils/eoUpdater.h>
typedef eoBit<eoMinimizingFitness> bitVector;
typedef moBitNeighbor<eoMinimizingFitness> bitNeighbor ;
class moDummyRndNeighborhood: public moOrderNeighborhood<bitNeighbor>/*, public moRndNeighborhood<bitNeighbor>*/{
public:
moDummyRndNeighborhood(unsigned int a): moOrderNeighborhood<bitNeighbor>(a){}
};
typedef moDummyRndNeighborhood bitNeighborhood ;
typedef EO<int> Solution;
class moDummyNeighbor : public moNeighbor<Solution,int>{
public:
virtual void move(Solution & _solution){}
};
class moDummyBackableNeighbor : public moBackableNeighbor<Solution,int>{
public:
virtual void move(Solution & _solution){}
virtual void moveBack(Solution & _solution){}
};
class moDummyNeighborhood : public moNeighborhood<moDummyNeighbor>{
public:
typedef moDummyNeighbor Neighbor;
moDummyNeighborhood():i(0),j(0){}
virtual bool hasNeighbor(EOT & _solution){
bool res;
if(i%3==0)
res=false;
else
res=true;
i++;
return res;
}
virtual void init(EOT & _solution, Neighbor & _current){}
virtual void next(EOT & _solution, Neighbor & _current){}
virtual bool cont(EOT & _solution){
j++;
return (j%10!=0);
}
private:
int i,j;
};
class moDummyEval: public eoEvalFunc<Solution>{
public:
void operator()(Solution& _sol){
if(_sol.invalid())
_sol.fitness(100);
else
_sol.fitness(_sol.fitness()+50);
}
};
class evalOneMax : public moEval< bitNeighbor >
{
private:
unsigned size;
public:
evalOneMax(unsigned _size) : size(_size) {};
~evalOneMax(void) {} ;
void operator() (bitVector& _sol, bitNeighbor& _n) {
unsigned int fit = _sol.fitness();
if(_sol[_n.index()])
fit--;
else
fit++;
_n.fitness(fit);
}
};
class dummyEvalOneMax : public moEval< bitNeighbor >
{
private:
unsigned size;
public:
dummyEvalOneMax(unsigned _size) : size(_size) {};
~dummyEvalOneMax(void) {} ;
void operator() (bitVector& _sol, bitNeighbor& _n) {
unsigned int fit = _sol.fitness();
_n.fitness(fit);
}
};
class monitor1 : public eoMonitor
{
public:
monitor1(unsigned int& _a): a(_a){}
eoMonitor& operator()(){
a++;
return *this;
}
void lastCall(){
a++;
}
private:
unsigned int& a;
};
class monitor2 : public eoMonitor
{
public:
monitor2(unsigned int& _a): a(_a){}
eoMonitor& operator()(){
a++;
return *this;
}
void lastCall(){
a++;
}
private:
unsigned int& a;
};
class updater1: public eoUpdater
{
public:
updater1(unsigned int& _a): a(_a){}
void operator()(){
a++;
}
void lastCall(){
a++;
}
private:
unsigned int& a;
};
#endif

View file

@ -0,0 +1,78 @@
/*
<t-moBestImprAspiration.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <memory/moBestImprAspiration.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moBestImprAspiration] => START" << std::endl;
moBestImprAspiration<bitNeighbor> test;
eoBit<eoMinimizingFitness> sol1(4);
eoBit<eoMinimizingFitness> sol2(4);
eoBit<eoMinimizingFitness> sol3(4);
eoBit<eoMinimizingFitness> sol4(4);
bitNeighbor n1;
bitNeighbor n2;
bitNeighbor n3;
bitNeighbor n4;
sol3[0]=true;
sol4[3]=true;
sol1.fitness(4);
sol2.fitness(5);
sol3.fitness(3);
sol4.fitness(3);
n1.fitness(4);
n2.fitness(5);
n3.fitness(3);
n4.fitness(3);
//verification qu'on update bien le best so far quand il faut
test.init(sol1);
assert(test.getBest()==sol1);
assert(!test(sol2,n2));
assert(test(sol3,n3));
test.update(sol3,n3);
assert(test.getBest()==sol3);
assert(!test(sol4,n4));
test.update(sol4,n4);
assert(test.getBest()==sol3);
std::cout << "[t-moBestImprAspiration] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,85 @@
/*
<t-moBitNeighborh.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can 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
*/
#include <neighborhood/moBitNeighbor.h>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moBitNeighbor] => START" << std::endl;
//init sol
eoBit<int> sol;
sol.push_back(true);
sol.push_back(false);
sol.push_back(true);
//verif du constructeur vide
moBitNeighbor<int> test1;
assert(test1.index()==0);
//verif du setter d'index et du constructeur de copy
test1.index(6);
test1.fitness(2);
moBitNeighbor<int> test2(test1);
assert(test2.index()==6);
assert(test2.fitness()==2);
//verif du getter
assert(test1.index()==6);
//verif de l'operateur=
test1.fitness(8);
test1.index(2);
test2=test1;
assert(test2.fitness()==8);
assert(test2.index()==2);
//verif de move
test2.move(sol);
assert(!sol[2]);
//verif de moveBack
test2.moveBack(sol);
assert(sol[2]);
test1.printOn(std::cout);
test2.printOn(std::cout);
assert(test1.className()=="moBitNeighbor");
std::cout << "[t-moBitNeighbor] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,122 @@
/*
<t-moCheckpoint.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <continuator/moCheckpoint.h>
#include <continuator/moTrueContinuator.h>
#include <continuator/moSolutionStat.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moCheckpoint] => START" << std::endl;
unsigned int a=2;
unsigned int b=15;
unsigned int c= 10;
unsigned int d= 47;
eoBit<eoMinimizingFitness> s(3);
s[0]=true;
s[1]=true;
s[2]=false;
s.fitness(17);
//verification que toutes les operateurs sont bien apellés
moSolutionStat< eoBit< eoMinimizingFitness > > stat;
updater1 up1(a);
updater1 up2(b);
monitor1 mon1(c);
monitor2 mon2(d);
moTrueContinuator< bitNeighborhood > cont;
moCheckpoint< bitNeighborhood> test1(cont);
moCheckpoint< bitNeighborhood> test2(cont, 3);
test1.add(up1);
test1.add(up2);
test1.add(mon1);
test1.add(mon2);
test1.add(stat);
test2.add(up1);
test2.add(up2);
test2.add(mon1);
test2.add(mon2);
test2.add(stat);
test1.init(s);
test1(s);
assert(a==3 && b==16 && c==11 && d==48);
assert(stat.value()[0]);
assert(stat.value()[1]);
assert(!stat.value()[2]);
assert(stat.value().fitness()==17);
test1(s);
assert(a==4 && b==17 && c==12 && d==49);
assert(stat.value()[0]);
assert(stat.value()[1]);
assert(!stat.value()[2]);
assert(stat.value().fitness()==17);
s.fitness(4);
test2.init(s);
test2(s);
assert(a==5 && b==18 && c==13 && d==50);
assert(stat.value()[0]);
assert(stat.value()[1]);
assert(!stat.value()[2]);
assert(stat.value().fitness()==4);
s.fitness(6);
test2(s);
assert(stat.value().fitness()==4);
test2(s);
assert(stat.value().fitness()==4);
test2(s);
assert(stat.value().fitness()==6);
test1.lastCall(s);
assert(a==9 && b==22 && c==17 && d==54);
test2.lastCall(s);
assert(a==10 && b==23 && c==18 && d==55);
assert(test1.className()=="moCheckpoint");
std::cout << "[t-moCheckpoint] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,71 @@
/*
<t-moCounterMonitorSaver.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <continuator/moCounterMonitorSaver.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moCounterMonitorSaver] => START" << std::endl;
unsigned int a=1;
unsigned int b=10;
monitor1 mon1(a);
monitor2 mon2(b);
moCounterMonitorSaver test(3, mon1);
test.add(mon2);
//on verifie qu'on apelle les moniteurs seulement tout les 3 itération
test();
assert(a==2 && b==11);
test();
assert(a==2 && b==11);
test();
assert(a==2 && b==11);
test();
assert(a==3 && b==12);
//test du lastCall
test.lastCall();
assert(a==4 && b==13);
assert(test.className()=="moCounterMonitorSaver");
std::cout << "[t-moCounterMonitorSaver] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,73 @@
/*
<t-moDistanceStat.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <neighborhood/moBitNeighbor.h>
#include <continuator/moDistanceStat.h>
#include <utils/eoDistance.h>
#include <iostream>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moDistanceStat] => START" << std::endl;
eoBit<int> sol1;
eoBit<int> sol2;
eoBit<int> sol3;
sol1.push_back(true);
sol1.push_back(false);
sol1.push_back(true);
sol2.push_back(true);
sol2.push_back(true);
sol2.push_back(false);
sol3.push_back(true);
sol3.push_back(true);
sol3.push_back(true);
//verification de la stat avec une distance de Hamming
eoHammingDistance< eoBit<int> > dist;
moDistanceStat< eoBit<int> > test(dist, sol1);
test(sol2);
assert(test.value()==2);
test(sol3);
assert(test.value()==1);
assert(test.className()=="moDistanceStat");
std::cout << "[t-moDistanceStat] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,63 @@
/*
<t-moDummyMemory.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <memory/moDummyIntensification.h>
#include <memory/moDummyDiversification.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moDummyMemory] => START" << std::endl;
eoBit<eoMinimizingFitness> sol(4);
bitNeighbor n;
moDummyDiversification<bitNeighbor> test1;
test1.init(sol);
test1.add(sol, n);
test1.update(sol, n);
test1.clearMemory();
assert(!test1(sol));
moDummyIntensification<bitNeighbor> test2;
test2.init(sol);
test2.add(sol, n);
test2.update(sol, n);
test2.clearMemory();
assert(!test2(sol));
std::cout << "[t-moDummyMemory] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,93 @@
/*
<t-moFirstImprExplorer.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
#include <explorer/moFirstImprExplorer.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moFirstImprExplorer] => START" << std::endl;
//Instanciation
eoBit<eoMinimizingFitness> sol(4, true);
sol.fitness(4);
bitNeighborhood nh(4);
evalOneMax eval(4);
moNeighborComparator<bitNeighbor> ncomp;
moSolNeighborComparator<bitNeighbor> sncomp;
moFirstImprExplorer<bitNeighborhood> test(nh, eval, ncomp, sncomp);
//on verifie qu'on améliore peut continuer à explorer tant qu'on améliore la solution
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==3);
assert(!sol[0]);
assert(test.isContinue(sol));
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==2);
assert(!sol[1]);
assert(test.isContinue(sol));
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==1);
assert(!sol[2]);
assert(test.isContinue(sol));
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==0);
assert(!sol[3]);
assert(test.isContinue(sol));
test(sol);
assert(!test.accept(sol));
assert(sol.fitness()==0);
assert(!test.isContinue(sol));
std::cout << "[t-moFirstImprExplorer] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,57 @@
/*
<t-moFitnessStat.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <continuator/moFitnessStat.h>
#include <neighborhood/moBitNeighbor.h>
#include <iostream>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moFitnessStat] => START" << std::endl;
eoBit<int> sol;
moFitnessStat< eoBit<int> > test;
sol.fitness(3);
test(sol);
assert(test.value()==3);
sol.fitness(12);
test(sol);
assert(test.value()==12);
assert(test.className()=="moFitnessStat");
std::cout << "[t-moFitnessStat] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,63 @@
/*
<t-moFullEvalByCopy.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can 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
*/
#include "moTestClass.h"
#include <eval/moFullEvalByCopy.h>
#include <cstdlib>
#include <cassert>
int main(){
//Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval
std::cout << "[t-moFullEvalByCopy] => START" << std::endl;
Solution sol;
moDummyNeighbor neighbor;
moDummyEval eval;
//verif constructor
moFullEvalByCopy<moDummyNeighbor> test(eval);
sol.fitness(3);
//verif operator()
test(sol,neighbor);
assert(sol.fitness()==3);
std::cout << "[t-moFullEvalByCopy] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,63 @@
/*
<t-moFullEvalByModif.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can 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
*/
#include "moTestClass.h"
#include <eval/moFullEvalByModif.h>
#include <cstdlib>
#include <cassert>
int main(){
//Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval
std::cout << "[t-moFullEvalByModif] => START" << std::endl;
Solution sol;
moDummyBackableNeighbor neighbor;
moDummyEval eval;
//verif constructor
moFullEvalByModif<moDummyBackableNeighbor> test(eval);
sol.fitness(3);
//verif operator()
test(sol,neighbor);
assert(sol.fitness()==3);
std::cout << "[t-moFullEvalByModif] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,92 @@
/*
<t-moHCneutralExplorer.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
#include <explorer/moHCneutralExplorer.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moHCneutralExplorer] => START" << std::endl;
//Instanciation
eoBit<eoMinimizingFitness> sol(4, true);
sol.fitness(4);
bitNeighborhood nh(4);
evalOneMax eval(4);
moNeighborComparator<bitNeighbor> ncomp;
moSolNeighborComparator<bitNeighbor> sncomp;
moHCneutralExplorer<bitNeighborhood> test(nh, eval, ncomp, sncomp,3);
//on verifie qu'on ameliore bien la solution et que l'exploration dure 3 itérations
test.initParam(sol);
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==3);
test.updateParam(sol);
assert(test.isContinue(sol));
//les affichages permettent de voir qu'on prend pas toujours les mm voisins(lancer plusieurs fois l'exe)
std::cout << sol << std::endl;
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==2);
test.updateParam(sol);
assert(test.isContinue(sol));
std::cout << sol << std::endl;
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==1);
test.updateParam(sol);
assert(!test.isContinue(sol));
std::cout << sol << std::endl;
std::cout << "[t-moHCneutralExplorer] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,97 @@
/*
<t-moMetropolisHastingExplorer.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <explorer/moMetropolisHastingExplorer.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moMetropolisHastingExplorer] => START" << std::endl;
//Instanciation
eoBit<eoMinimizingFitness> sol(4, true);
sol.fitness(4);
bitNeighborhood nh(4);
evalOneMax eval(4);
moNeighborComparator<bitNeighbor> ncomp;
moSolNeighborComparator<bitNeighbor> sncomp;
moMetropolisHastingExplorer<bitNeighborhood> test(nh, eval, ncomp, sncomp, 3);
//test de l'acceptation d'un voisin améliorant
test.initParam(sol);
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==3);
test.updateParam(sol);
assert(test.isContinue(sol));
unsigned int oui=0, non=0;
//test de l'acceptation d'un voisin non améliorant
for(unsigned int i=0; i<1000; i++){
test(sol);
if(test.accept(sol))
oui++;
else
non++;
}
std::cout << "Attention test en fonction d'une proba \"p\" uniforme dans [0,1] , oui si p < 3/4, non sinon -> resultat sur 1000 essai" << std::endl;
std::cout << "oui: " << oui << std::endl;
std::cout << "non: " << non << std::endl;
assert(oui > 700 && oui < 800); //verification grossiere
//test du critere d'arret
test.updateParam(sol);
assert(test.isContinue(sol));
test.updateParam(sol);
assert(!test.isContinue(sol));
//test de l'acceptation d'un voisin
sol[0]=false;
sol[1]=false;
sol[2]=false;
sol[3]=false;
sol.fitness(0);
test.initParam(sol);
test(sol);
assert(!test.accept(sol));
std::cout << "[t-moMetropolisHastingExplorer] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,64 @@
/*
<t-moNeighbor.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can 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
*/
#include "moTestClass.h"
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moNeighbor] => START" << std::endl;
//test constructor
moDummyNeighbor test1, test2;
test1.fitness(3);
//test operateur d'affectation
test2=test1;
assert(test1.fitness()==test2.fitness());
//test operateur de copy
moDummyNeighbor test3(test1);
assert(test1.fitness()==test3.fitness());
test1.printOn(std::cout);
test2.printOn(std::cout);
test3.printOn(std::cout);
assert(test1.className()=="moNeighbor");
std::cout << "[t-moNeighbor] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,68 @@
/*
<t-moNeighborComparator.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can 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
*/
#include <neighborhood/moBitNeighbor.h>
#include <comparator/moNeighborComparator.h>
#include <ga/eoBit.h>
#include <eoScalarFitness.h>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moNeighborComparator] => START" << std::endl;
moBitNeighbor<eoMinimizingFitness> neighbor1;
moBitNeighbor<eoMinimizingFitness> neighbor2;
moNeighborComparator< moBitNeighbor<eoMinimizingFitness> > test;
neighbor1.fitness(3);
neighbor2.fitness(2);
//test with a minimizing fitness neighbor2 must be better than neighbor1 and reversly
assert(test(neighbor1, neighbor2));
assert(!test(neighbor2, neighbor1));
//test equals
assert(!test.equals(neighbor1,neighbor2));
neighbor2.fitness(3);
assert(test.equals(neighbor1,neighbor2));
assert(test.className()=="moNeighborComparator");
std::cout << "[t-moNeighborComparator] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,152 @@
/*
<t-moNeighborhoodStat.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <continuator/moNeighborhoodStat.h>
#include <continuator/moMaxNeighborStat.h>
#include <continuator/moMinNeighborStat.h>
#include <continuator/moNbInfNeighborStat.h>
#include <continuator/moNbSupNeighborStat.h>
#include <continuator/moNeutralDegreeNeighborStat.h>
#include <continuator/moSecondMomentNeighborStat.h>
#include <continuator/moSizeNeighborStat.h>
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
/*
* Tests all classes depending of moNeighborhoodStat.h
*/
int main(){
//test de moNeighborhoodStat.h
std::cout << "[t-moNeighborhoodStat] => START" << std::endl;
moNeighborComparator<bitNeighbor> neighborComp;
moSolNeighborComparator<bitNeighbor> solNeighborComp;
evalOneMax eval(10);
bitNeighborhood n(10);
bitVector sol;
sol.push_back(true);
sol.push_back(false);
sol.push_back(true);
sol.push_back(true);
sol.push_back(false);
sol.push_back(true);
sol.push_back(false);
sol.push_back(true);
sol.push_back(true);
sol.push_back(true);
sol.fitness(7);
moNeighborhoodStat<bitNeighborhood> test(n, eval, neighborComp, solNeighborComp);
test(sol);
assert(test.getMin()==8);
assert(test.getMax()==6);
assert(test.getMean()==6.6);
double sd=test.getSD();
assert(test.getSD()>0.966 && test.getSD()<0.967);
assert(test.getSize()==10);
assert(test.getNbSup()==7);
assert(test.getNbInf()==3);
assert(test.getNbEqual()==0);
assert(test.className()=="moNeighborhoodStat");
std::cout << "[t-moNeighborhoodStat] => OK" << std::endl;
//test of moMaxNeighborStat.h
std::cout << "[t-moMaxNeighborStat] => START" << std::endl;
moMaxNeighborStat<bitNeighborhood> test2(test);
test2(sol);
assert(test2.value()==6);
assert(test2.className()=="moMaxNeighborStat");
std::cout << "[t-moMaxNeighborStat] => OK" << std::endl;
//test of moMinNeighborStat.h
std::cout << "[t-moMinNeighborStat] => START" << std::endl;
moMinNeighborStat<bitNeighborhood> test3(test);
test3(sol);
assert(test3.value()==8);
assert(test3.className()=="moMinNeighborStat");
std::cout << "[t-moMinNeighborStat] => OK" << std::endl;
//test of moNbInfNeighborStat.h
std::cout << "[t-moNbInfNeighborStat] => START" << std::endl;
moNbInfNeighborStat<bitNeighborhood> test4(test);
test4(sol);
assert(test4.value()==3);
assert(test4.className()=="moNbInfNeighborStat");
std::cout << "[t-moNbInfNeighborStat] => OK" << std::endl;
//test of moNbSupNeighborStat.h
std::cout << "[t-moNbSupNeighborStat] => START" << std::endl;
moNbSupNeighborStat<bitNeighborhood> test5(test);
test5(sol);
assert(test5.value()==7);
assert(test5.className()=="moNbSupNeighborStat");
std::cout << "[t-moNbSupNeighborStat] => OK" << std::endl;
//test of moNeutralDegreeNeighborStat.h
std::cout << "[t-moNeutralDegreeNeighborStat] => START" << std::endl;
moNeutralDegreeNeighborStat<bitNeighborhood> test6(test);
test6(sol);
assert(test6.value()==0);
assert(test6.className()=="moNeutralDegreeNeighborStat");
std::cout << "[t-moNeutralDegreeNeighborStat] => OK" << std::endl;
//test of moSecondMomentNeighborStat.h
std::cout << "[t-moSecondMomentNeighborStat] => START" << std::endl;
moSecondMomentNeighborStat<bitNeighborhood> test7(test);
test7(sol);
assert(test7.value().first==6.6);
assert(test7.value().second > 0.966 && test7.value().second < 0.967);
assert(test7.className()=="moSecondMomentNeighborStat");
std::cout << "[t-moSecondMomentNeighborStat] => OK" << std::endl;
//test of moSizeNeighborStat.h
std::cout << "[t-moSizeNeighborStat] => START" << std::endl;
moSizeNeighborStat<bitNeighborhood> test8(test);
test8(sol);
assert(test8.value()==10);
assert(test8.className()=="moSizeNeighborStat");
std::cout << "[t-moSizeNeighborStat] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,80 @@
/*
<t-moOrderNeighborhood.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can 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
*/
#include <neighborhood/moOrderNeighborhood.h>
#include <neighborhood/moBitNeighbor.h>
#include <ga/eoBit.h>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moOrderNeighborhood] => START" << std::endl;
//init sol
eoBit<int> sol;
sol.push_back(true);
sol.push_back(false);
sol.push_back(true);
moBitNeighbor<int> neighbor;
//verif du constructeur vide
moOrderNeighborhood<moBitNeighbor<int> > test(3);
assert(test.position()==0);
//verif du hasneighbor
assert(test.hasNeighbor(sol));
//verif de init
test.init(sol, neighbor);
assert(neighbor.index()==0);
assert(test.position()==0);
//verif du next
test.next(sol, neighbor);
assert(neighbor.index()==1);
assert(test.position()==1);
//verif du cont
assert(test.cont(sol));
test.next(sol, neighbor);
assert(!test.cont(sol));
assert(test.className()=="moOrderNeighborhood");
std::cout << "[t-moOrderNeighborhood] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,88 @@
/*
<t-moRandomNeutralWalkExplorer.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <explorer/moRandomNeutralWalkExplorer.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moRandomNeutralWalkExplorer] => START" << std::endl;
eoBit<eoMinimizingFitness> sol(4, true);
sol.fitness(4);
bitNeighborhood nh(4);
evalOneMax eval(4);
dummyEvalOneMax eval2(4);
moSolNeighborComparator<bitNeighbor> sncomp;
//test avec la fonction d'eval classique
//on verifie qu'on ne trouve pas de voisin de mm fitness
moRandomNeutralWalkExplorer<bitNeighborhood> test(nh, eval, sncomp, 3);
test.initParam(sol);
test(sol);
assert(!test.accept(sol));
assert(!test.isContinue(sol));
//test avec une fonction d'eval bidon qui renvoie toujours la mm fitness
//on peut donc verifier qu'on s'arette au bout des 3 itérations.
moRandomNeutralWalkExplorer<bitNeighborhood> test2(nh, eval2, sncomp, 3);
sol.fitness(2);
test2.initParam(sol);
test2(sol);
assert(test2.accept(sol));
test2.move(sol);
assert(sol.fitness()==2);
test2.updateParam(sol);
assert(test2.isContinue(sol));
test2(sol);
assert(test2.accept(sol));
test2.move(sol);
assert(sol.fitness()==2);
test2.updateParam(sol);
assert(test2.isContinue(sol));
test2(sol);
assert(test2.accept(sol));
test2.move(sol);
assert(sol.fitness()==2);
test2.updateParam(sol);
assert(!test2.isContinue(sol));
std::cout << "[t-moRandomNeutralWalkExplorer] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,79 @@
/*
<t-moRandomWalkExplorer.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <explorer/moRandomWalkExplorer.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moRandomWalkExplorer] => START" << std::endl;
eoBit<eoMinimizingFitness> sol(4, true);
sol.fitness(4);
bitNeighborhood nh(4);
evalOneMax eval(4);
//test avec un neighbordhood ordonné
//Du coup on verifie juste qu'on a bien une evolution de la solution et qu'on fait 3 pas avant d'arreter l'exploration
moRandomWalkExplorer<bitNeighborhood> test(nh, eval, 3);
test.initParam(sol);
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==3);
test.updateParam(sol);
assert(test.isContinue(sol));
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==4);
test.updateParam(sol);
assert(test.isContinue(sol));
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==3);
assert(!sol[0]);
test.updateParam(sol);
assert(!test.isContinue(sol));
std::cout << "[t-moRandomWalkExplorer] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,75 @@
/*
<t-moRndWithReplNeighborhood.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <neighborhood/moRndWithReplNeighborhood.h>
#include <neighborhood/moBitNeighbor.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moRndWithReplNeighborhood] => START" << std::endl;
unsigned int a, b;
eoBit<int> sol;
moBitNeighbor<int> n;
moRndWithReplNeighborhood< moBitNeighbor<int> > test(3);
moRndWithReplNeighborhood< moBitNeighbor<int> > test2(0);
assert(test.hasNeighbor(sol));
assert(!test2.hasNeighbor(sol));
test.init(sol,n);
//on s'assure qu'on a bien toujours bien l'index 0, 1 ou 2 qui est renvoyé
for(unsigned int i=0; i<100; i++){
a=n.index();
test.next(sol,n);
b=n.index();
assert(a==0 || a==1 || a==2);
assert(b==0 || b==1 || b==2);
assert(test.cont(sol));
assert(!test2.cont(sol));
assert(test.cont(sol));
}
assert(test.className()=="moRndWithReplNeighborhood");
std::cout << "[t-moRndWithReplNeighborhood] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,76 @@
/*
<t-moRndWithoutReplNeighborhood.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <neighborhood/moRndWithoutReplNeighborhood.h>
#include <neighborhood/moBitNeighbor.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moRndWithoutReplNeighborhood] => START" << std::endl;
unsigned int a, b, c;
eoBit<int> sol;
moBitNeighbor<int> n;
//instanciation
moRndWithoutReplNeighborhood< moBitNeighbor<int> > test(3);
moRndWithoutReplNeighborhood< moBitNeighbor<int> > test2(0);
//on verifie que test a bien des voisins et que test2 n'en a pas
assert(test.hasNeighbor(sol));
assert(!test2.hasNeighbor(sol));
//on recupere successivement les index
test.init(sol, n);
assert(test.cont(sol));
a=test.position();
test.next(sol, n);
assert(test.cont(sol));
b=test.position();
test.next(sol,n);
assert(!test.cont(sol));
c=test.position();
//on s'assure qu'on a bien 0, 1 et 2 (dans un ordre aléatoire)
assert(a==0 || b==0 || c==0);
assert(a==1 || b==1 || c==1);
assert(a==2 || b==2 || c==2);
assert(test.className()=="moRndWithoutReplNeighborhood");
std::cout << "[t-moRndWithoutReplNeighborhood] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,92 @@
/*
<t-moSimpleHCexplorer.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can 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
*/
#include "moTestClass.h"
#include <eval/moFullEvalByCopy.h>
#include <explorer/moSimpleHCexplorer.h>
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
#include <cstdlib>
#include <cassert>
int main(){
//Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval
std::cout << "[t-moSimpleHCexplorer] => START" << std::endl;
Solution sol;
moDummyNeighbor neighbor;
moDummyEval eval;
moDummyNeighborhood nh;
moFullEvalByCopy<moDummyNeighbor> fulleval(eval);
moNeighborComparator<moDummyNeighbor> comp;
moSolNeighborComparator<moDummyNeighbor> solNeighborComp;
//verif constructor
moSimpleHCexplorer<moDummyNeighborhood> test(nh, fulleval, comp, solNeighborComp);
//verif operator() et accept: le neigorhood est construit pour qu'on tombe dans les 3 cas suivants:
//hasNeighbor() retourne faux a l'entrée de l'operator() donc on doit pas continuer
sol.fitness(3);
test(sol);
test.accept(sol);
assert(!test.isContinue(sol));
//hasNeighbor() retourne faux a l'entrée de accept() donc on doit pas continuer
test(sol);
test.accept(sol);
assert(!test.isContinue(sol));
//hasNeighbor() retourne vrai et on ameliore la fitness donc on doit continuer
test(sol);
test.accept(sol);
assert(test.isContinue(sol));
//verif de move -> on affecte la fitness du best d'avant
test.move(sol);
//hasNeighbor() retourne vrai et on ameliore pas la fitness donc on doit pas continuer
test(sol);
test(sol);
test.accept(sol);
assert(!test.isContinue(sol));
assert(test.className()=="moSimpleHCexplorer");
std::cout << "[t-moSimpleHCexplorer] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,101 @@
/*
<t-moSimpleHCneutralExplorer.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
#include <explorer/moSimpleHCneutralExplorer.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moSimpleHCneutralExplorer] => START" << std::endl;
//instanciation
eoBit<eoMinimizingFitness> sol(4, true);
sol.fitness(4);
bitNeighborhood nh(4);
evalOneMax eval(4);
moNeighborComparator<bitNeighbor> ncomp;
moSolNeighborComparator<bitNeighbor> sncomp;
moSimpleHCneutralExplorer<bitNeighborhood> test(nh, eval, ncomp, sncomp);
//test qu'on ameliore bien a chaque itération
test.initParam(sol);
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==3);
assert(test.isContinue(sol));
test.updateParam(sol);
//les affichages permettent de voir qu'on choisit pas toujours les mm voisins améliorant (lancer plusieurs fois l'exe)
std::cout << sol << std::endl;
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==2);
assert(test.isContinue(sol));
test.updateParam(sol);
std::cout << sol << std::endl;
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==1);
assert(test.isContinue(sol));
test.updateParam(sol);
std::cout << sol << std::endl;
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==0);
assert(test.isContinue(sol));
test.updateParam(sol);
test(sol);
assert(!test.accept(sol));
assert(sol.fitness()==0);
assert(!test.isContinue(sol));
test.updateParam(sol);
std::cout << "[t-moSimpleHCneutralExplorer] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,72 @@
/*
<t-moSolNeighborComparator.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can 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
*/
#include <neighborhood/moBitNeighbor.h>
#include <eoScalarFitness.h>
#include <comparator/moSolNeighborComparator.h>
#include <ga/eoBit.h>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moSolNeighborComparator] => START" << std::endl;
moBitNeighbor<eoMinimizingFitness> neighbor;
eoBit<eoMinimizingFitness> sol;
moSolNeighborComparator< moBitNeighbor<eoMinimizingFitness> > test;
neighbor.fitness(3);
sol.fitness(2);
//test with a minimizing fitness, neighbor must not be better than sol
assert(!test(sol, neighbor));
//reversly
neighbor.fitness(2);
sol.fitness(3);
assert(test(sol, neighbor));
//test equals
assert(!test.equals(sol, neighbor));
neighbor.fitness(3);
assert(test.equals(sol, neighbor));
assert(test.className()=="moSolNeighborComparator");
std::cout << "[t-moSolNeighborComparator] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,154 @@
/*
<t-moSolVectorTabuList.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <memory/moSolVectorTabuList.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moSolVectorTabuList] => START" << std::endl;
//test without countdown
moSolVectorTabuList<bitNeighbor> test(2,0);
bitNeighbor n1;
bitNeighbor n2;
bitNeighbor n3;
bitNeighbor n4;
n1.index(0);
n2.index(1);
n3.index(2);
n4.index(3);
eoBit<eoMinimizingFitness> sol1(4, true);
eoBit<eoMinimizingFitness> sol2(4, true);
eoBit<eoMinimizingFitness> sol3(4, true);
eoBit<eoMinimizingFitness> sol4(4, true);
sol2[0]=false;
sol3[1]=false;
sol4[0]=false;
sol4[1]=false;
//init
test.init(sol1);
//ajout d'une sol tabu
test.add(sol1,n1);
//verification des voisins de chaques sol
assert(test.check(sol2,n1));
assert(!test.check(sol2,n2));
assert(!test.check(sol2,n3));
assert(!test.check(sol2,n4));
assert(!test.check(sol3,n1));
assert(test.check(sol3,n2));
assert(!test.check(sol3,n3));
assert(!test.check(sol3,n4));
assert(!test.check(sol4,n1));
assert(!test.check(sol4,n2));
assert(!test.check(sol4,n3));
assert(!test.check(sol4,n4));
test.init(sol1);
assert(!test.check(sol2,n1));
assert(!test.check(sol3,n2));
test.update(sol1,n1);
test.add(sol1,n1);
test.add(sol2,n1);
assert(test.check(sol2,n1));
test.add(sol4,n1);
assert(!test.check(sol2,n1));
assert(test.check(sol2,n2));
//test with a countdown at 3
moSolVectorTabuList<bitNeighbor> test2(2,2);
test2.init(sol1);
test2.add(sol1,n1);
assert(test2.check(sol2,n1));
assert(!test2.check(sol2,n2));
assert(!test2.check(sol2,n3));
assert(!test2.check(sol2,n4));
assert(!test2.check(sol3,n1));
assert(test2.check(sol3,n2));
assert(!test2.check(sol3,n3));
assert(!test2.check(sol3,n4));
assert(!test2.check(sol4,n1));
assert(!test2.check(sol4,n2));
assert(!test2.check(sol4,n3));
assert(!test2.check(sol4,n4));
//coutdown sol1 -> 1
test2.update(sol1,n1);
assert(test2.check(sol2,n1));
assert(!test2.check(sol2,n2));
assert(!test2.check(sol2,n3));
assert(!test2.check(sol2,n4));
assert(!test2.check(sol3,n1));
assert(test2.check(sol3,n2));
assert(!test2.check(sol3,n3));
assert(!test2.check(sol3,n4));
assert(!test2.check(sol4,n1));
assert(!test2.check(sol4,n2));
assert(!test2.check(sol4,n3));
assert(!test2.check(sol4,n4));
//coutdown sol1 -> 0 : sol1 is no longer tabu
test2.update(sol1,n1);
assert(!test2.check(sol2,n1));
assert(!test2.check(sol2,n2));
assert(!test2.check(sol2,n3));
assert(!test2.check(sol2,n4));
assert(!test2.check(sol3,n1));
assert(!test2.check(sol3,n2));
assert(!test2.check(sol3,n3));
assert(!test2.check(sol3,n4));
assert(!test2.check(sol4,n1));
assert(!test2.check(sol4,n2));
assert(!test2.check(sol4,n3));
assert(!test2.check(sol4,n4));
std::cout << "[t-moSolVectorTabuList] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,64 @@
/*
<t-moSolutionStat.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <continuator/moSolutionStat.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moSolutionStat] => START" << std::endl;
eoBit<unsigned int> s(3);
s[0]=true;
s[1]=true;
s[2]=false;
s.fitness(17);
moSolutionStat< eoBit<unsigned int > > test;
test(s);
//on verifie que la solution est bien enregistré
assert(test.value()[0]);
assert(test.value()[1]);
assert(!test.value()[2]);
assert(test.value().fitness()==17);
assert(test.className()=="moSolutionStat");
std::cout << "[t-moSolutionStat] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,165 @@
/*
<t-moTSExplorer.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <memory/moSolVectorTabuList.h>
#include <memory/moDummyIntensification.h>
#include <memory/moDummyDiversification.h>
#include <memory/moBestImprAspiration.h>
#include <explorer/moTSExplorer.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moTSExplorer] => START" << std::endl;
//instansiation
eoBit<eoMinimizingFitness> sol(4, true);
sol.fitness(4);
bitNeighborhood nh(4);
bitNeighborhood emptyNH(0);
evalOneMax eval(4);
moNeighborComparator<bitNeighbor> ncomp;
moSolNeighborComparator<bitNeighbor> sncomp;
moDummyIntensification<bitNeighbor> intens;
moDummyDiversification<bitNeighbor> diver;
moSolVectorTabuList<bitNeighbor> tabuList(4,0);
moBestImprAspiration<bitNeighbor> aspir;
moTSExplorer<bitNeighborhood> test(nh, eval, ncomp, sncomp, tabuList, intens, diver, aspir);
moTSExplorer<bitNeighborhood> test2(emptyNH, eval, ncomp, sncomp, tabuList, intens, diver, aspir);
//test d'un voisinage vide
test2.initParam(sol);
test2(sol);
assert(!test2.accept(sol));
//test le comportement classique de la taboo
test.initParam(sol);
assert(aspir.getBest()==sol);
test(sol);
test.updateParam(sol);
assert(aspir.getBest()==sol);
//on ameliore et on stock une sol tabou 0111
test(sol);
test.move(sol);
test.moveApplied(true);
test.updateParam(sol);
assert(aspir.getBest()==sol);
//on ameliore et on stock une autre sol tabou 0011
test(sol);
test.move(sol);
test.moveApplied(true);
test.updateParam(sol);
assert(aspir.getBest()==sol);
//pareil on stock 0001 met pdt la recherche on se rend compte que 0111 est tabou
test(sol);
test.move(sol);
test.moveApplied(true);
test.updateParam(sol);
assert(aspir.getBest()==sol);
//on modifie la sol en 1001(fitness 2) pour que la 1er sol exploré(0001) soit tabou
//De plus on change la solution mais elle est pas meilleure que la best so Far
sol[0]=true;
std::cout << sol << std::endl;
sol.fitness(2);
test(sol);
test.move(sol);
test.moveApplied(true);
test.updateParam(sol);
assert( sol[0] && !sol[1] && !sol[2] && !sol[3]);
sol[0]=false;
sol[3]=true;
assert(aspir.getBest()==sol);
//test du isContinue
assert(test.isContinue(sol));
//test du terminate
test.initParam(sol);
sol[0]=true;
sol[1]=true;
sol[2]=true;
sol[3]=true;
sol.fitness(4);
test(sol);
test.move(sol);
test.moveApplied(true);
test.updateParam(sol);
assert( !sol[0] && sol[1] && sol[2] && sol[3]);
test.terminate(sol);
assert( !sol[0] && !sol[1] && !sol[2] && sol[3]);
//test pour avoir que des mouvement taboo
eoBit<eoMinimizingFitness> sol2(2, true);
sol2.fitness(2);
bitNeighborhood nh2(2);
evalOneMax eval2(2);
moTSExplorer<bitNeighborhood> test3(nh2, eval2, ncomp, sncomp, tabuList, intens, diver, aspir);
test3.initParam(sol2);
test3(sol2);
test3.move(sol2);
test3.moveApplied(true);
test3.updateParam(sol2);
test3(sol2);
test3.move(sol2);
test3.moveApplied(true);
test3.updateParam(sol2);
test3(sol2);
test3.move(sol2);
test3.moveApplied(true);
test3.updateParam(sol2);
test3(sol2);
test3.move(sol2);
test3.moveApplied(true);
test3.updateParam(sol2);
//on a rempli la liste tabu pour que tout les voisins soit tabu
test3(sol2);
assert(!test3.accept(sol2));
std::cout << "[t-moTSExplorer] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,53 @@
/*
<t-moTrueContinuator.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can 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
*/
#include <continuator/moTrueContinuator.h>
#include "moTestClass.h"
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moTrueContinuator] => START" << std::endl;
moTrueContinuator<moDummyNeighborhood> test;
Solution s;
assert(test(s));
std::cout << "[t-moTrueContinuator] => OK" << std::endl;
return EXIT_SUCCESS;
}