test and documentation added
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1699 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
cad0320e57
commit
500987685b
5 changed files with 185 additions and 41 deletions
|
|
@ -38,6 +38,7 @@
|
||||||
#include <continuator/moContinuator.h>
|
#include <continuator/moContinuator.h>
|
||||||
#include <utils/eoMonitor.h>
|
#include <utils/eoMonitor.h>
|
||||||
#include <continuator/moStatBase.h>
|
#include <continuator/moStatBase.h>
|
||||||
|
#include <utils/eoUpdater.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Continuator allowing to add others (continuators, stats, monitors or updaters)
|
* Continuator allowing to add others (continuators, stats, monitors or updaters)
|
||||||
|
|
@ -100,9 +101,11 @@ public :
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the name of the class
|
* @return class name
|
||||||
*/
|
*/
|
||||||
virtual std::string className(void) const { return "moCheckPoint"; }
|
virtual std::string className(void) const {
|
||||||
|
return "moCheckpoint";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* apply operator of checkpoint's containers
|
* apply operator of checkpoint's containers
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ SET (TEST_LIST
|
||||||
t-moNeighborhoodStat
|
t-moNeighborhoodStat
|
||||||
t-moCounterMonitorSaver
|
t-moCounterMonitorSaver
|
||||||
t-moSolutionStat
|
t-moSolutionStat
|
||||||
|
t-moCheckpoint
|
||||||
)
|
)
|
||||||
|
|
||||||
FOREACH (test ${TEST_LIST})
|
FOREACH (test ${TEST_LIST})
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,9 @@
|
||||||
#include <neighborhood/moOrderNeighborhood.h>
|
#include <neighborhood/moOrderNeighborhood.h>
|
||||||
#include <neighborhood/moBitNeighbor.h>
|
#include <neighborhood/moBitNeighbor.h>
|
||||||
|
|
||||||
|
#include <utils/eoMonitor.h>
|
||||||
|
#include <utils/eoUpdater.h>
|
||||||
|
|
||||||
typedef eoBit<eoMinimizingFitness> bitVector;
|
typedef eoBit<eoMinimizingFitness> bitVector;
|
||||||
typedef moBitNeighbor<eoMinimizingFitness> bitNeighbor ;
|
typedef moBitNeighbor<eoMinimizingFitness> bitNeighbor ;
|
||||||
typedef moOrderNeighborhood<bitNeighbor> bitNeighborhood ;
|
typedef moOrderNeighborhood<bitNeighbor> bitNeighborhood ;
|
||||||
|
|
@ -120,4 +123,59 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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
|
#endif
|
||||||
|
|
|
||||||
120
branches/newMo/test/t-moCheckpoint.cpp
Normal file
120
branches/newMo/test/t-moCheckpoint.cpp
Normal file
|
|
@ -0,0 +1,120 @@
|
||||||
|
/*
|
||||||
|
<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);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -28,51 +28,13 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <continuator/moCounterMonitorSaver.h>
|
#include <continuator/moCounterMonitorSaver.h>
|
||||||
#include <utils/eoMonitor.h>
|
#include "moTestClass.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
|
|
||||||
std::cout << "[t-moCounterMonitorSaver] => START" << std::endl;
|
std::cout << "[t-moCounterMonitorSaver] => START" << std::endl;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue