passage du code dans astyle

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1713 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jhumeau 2010-03-24 10:25:33 +00:00
commit dd66b5e4bd
105 changed files with 3950 additions and 3924 deletions

View file

@ -54,151 +54,151 @@
typedef eoBit<eoMinimizingFitness> bitVector;
typedef moBitNeighbor<eoMinimizingFitness> bitNeighbor ;
class moDummyRndNeighborhood: public moOrderNeighborhood<bitNeighbor>/*, public moRndNeighborhood<bitNeighbor>*/{
class moDummyRndNeighborhood: public moOrderNeighborhood<bitNeighbor>/*, public moRndNeighborhood<bitNeighbor>*/ {
public:
moDummyRndNeighborhood(unsigned int a): moOrderNeighborhood<bitNeighbor>(a){}
moDummyRndNeighborhood(unsigned int a): moOrderNeighborhood<bitNeighbor>(a) {}
};
typedef moDummyRndNeighborhood bitNeighborhood ;
typedef EO<int> Solution;
class moDummyNeighbor : public moNeighbor<Solution,int>{
class moDummyNeighbor : public moNeighbor<Solution,int> {
public:
virtual void move(Solution & _solution){}
virtual void move(Solution & _solution) {}
};
class moDummyBackableNeighbor : public moBackableNeighbor<Solution,int>{
class moDummyBackableNeighbor : public moBackableNeighbor<Solution,int> {
public:
virtual void move(Solution & _solution){}
virtual void moveBack(Solution & _solution){}
virtual void move(Solution & _solution) {}
virtual void moveBack(Solution & _solution) {}
};
class moDummyNeighborhood : public moNeighborhood<moDummyNeighbor>{
class moDummyNeighborhood : public moNeighborhood<moDummyNeighbor> {
public:
typedef moDummyNeighbor Neighbor;
typedef moDummyNeighbor Neighbor;
moDummyNeighborhood():i(0),j(0){}
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 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);
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>{
class moDummyEval: public eoEvalFunc<Solution> {
public:
void operator()(Solution& _sol){
if(_sol.invalid())
_sol.fitness(100);
else
_sol.fitness(_sol.fitness()+50);
}
void operator()(Solution& _sol) {
if (_sol.invalid())
_sol.fitness(100);
else
_sol.fitness(_sol.fitness()+50);
}
};
class evalOneMax : public moEval< bitNeighbor >
{
private:
unsigned size;
unsigned size;
public:
evalOneMax(unsigned _size) : size(_size) {};
evalOneMax(unsigned _size) : size(_size) {};
~evalOneMax(void) {} ;
~evalOneMax(void) {} ;
void operator() (bitVector& _sol, bitNeighbor& _n) {
unsigned int fit = _sol.fitness();
if(_sol[_n.index()])
fit--;
else
fit++;
_n.fitness(fit);
}
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;
unsigned size;
public:
dummyEvalOneMax(unsigned _size) : size(_size) {};
dummyEvalOneMax(unsigned _size) : size(_size) {};
~dummyEvalOneMax(void) {} ;
~dummyEvalOneMax(void) {} ;
void operator() (bitVector& _sol, bitNeighbor& _n) {
unsigned int fit = _sol.fitness();
_n.fitness(fit);
}
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){}
monitor1(unsigned int& _a): a(_a) {}
eoMonitor& operator()(){
a++;
return *this;
}
eoMonitor& operator()() {
a++;
return *this;
}
void lastCall(){
a++;
}
void lastCall() {
a++;
}
private:
unsigned int& a;
unsigned int& a;
};
class monitor2 : public eoMonitor
{
public:
monitor2(unsigned int& _a): a(_a){}
monitor2(unsigned int& _a): a(_a) {}
eoMonitor& operator()(){
a++;
return *this;
}
eoMonitor& operator()() {
a++;
return *this;
}
void lastCall(){
a++;
}
void lastCall() {
a++;
}
private:
unsigned int& a;
unsigned int& a;
};
class updater1: public eoUpdater
{
public:
updater1(unsigned int& _a): a(_a){}
updater1(unsigned int& _a): a(_a) {}
void operator()(){
a++;
}
void operator()() {
a++;
}
void lastCall(){
a++;
}
void lastCall() {
a++;
}
private:
unsigned int& a;
unsigned int& a;
};
#endif

View file

@ -33,46 +33,46 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moBestImprAspiration] => START" << std::endl;
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;
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;
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);
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);
//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;
std::cout << "[t-moBestImprAspiration] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -37,49 +37,49 @@
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moBitNeighbor] => START" << std::endl;
std::cout << "[t-moBitNeighbor] => START" << std::endl;
//init sol
eoBit<int> sol;
sol.push_back(true);
sol.push_back(false);
sol.push_back(true);
//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 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 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 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 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 move
test2.move(sol);
assert(!sol[2]);
//verif de moveBack
test2.moveBack(sol);
assert(sol[2]);
//verif de moveBack
test2.moveBack(sol);
assert(sol[2]);
test1.printOn(std::cout);
test2.printOn(std::cout);
test1.printOn(std::cout);
test2.printOn(std::cout);
assert(test1.className()=="moBitNeighbor");
std::cout << "[t-moBitNeighbor] => OK" << std::endl;
return EXIT_SUCCESS;
assert(test1.className()=="moBitNeighbor");
std::cout << "[t-moBitNeighbor] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -36,87 +36,87 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moCheckpoint] => START" << std::endl;
std::cout << "[t-moCheckpoint] => START" << std::endl;
unsigned int a=2;
unsigned int b=15;
unsigned int c= 10;
unsigned int d= 47;
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;
eoBit<eoMinimizingFitness> s(3);
s[0]=true;
s[1]=true;
s[2]=false;
s.fitness(17);
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;
//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);
moCheckpoint< bitNeighborhood> test1(cont);
moCheckpoint< bitNeighborhood> test2(cont, 3);
test1.add(up1);
test1.add(up2);
test1.add(mon1);
test1.add(mon2);
test1.add(stat);
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);
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.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);
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);
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);
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);
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);
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;
assert(test1.className()=="moCheckpoint");
std::cout << "[t-moCheckpoint] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -35,37 +35,37 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cassert>
int main(){
int main() {
std::cout << "[t-moCounterMonitorSaver] => START" << std::endl;
std::cout << "[t-moCounterMonitorSaver] => START" << std::endl;
unsigned int a=1;
unsigned int b=10;
unsigned int a=1;
unsigned int b=10;
monitor1 mon1(a);
monitor2 mon2(b);
monitor1 mon1(a);
monitor2 mon2(b);
moCounterMonitorSaver test(3, mon1);
test.add(mon2);
moCounterMonitorSaver test(3, mon1);
test.add(mon2);
//on verifie qu'on apelle les moniteurs seulement tout les 3 itération
//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();
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);
//test du lastCall
test.lastCall();
assert(a==4 && b==13);
assert(test.className()=="moCounterMonitorSaver");
std::cout << "[t-moCounterMonitorSaver] => OK" << std::endl;
assert(test.className()=="moCounterMonitorSaver");
std::cout << "[t-moCounterMonitorSaver] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -35,39 +35,39 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moDistanceStat] => START" << std::endl;
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);
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);
sol2.push_back(true);
sol2.push_back(true);
sol2.push_back(false);
sol3.push_back(true);
sol3.push_back(true);
sol3.push_back(true);
sol3.push_back(true);
sol3.push_back(true);
sol3.push_back(true);
//verification de la stat avec une distance de Hamming
//verification de la stat avec une distance de Hamming
eoHammingDistance< eoBit<int> > dist;
eoHammingDistance< eoBit<int> > dist;
moDistanceStat< eoBit<int> > test(dist, sol1);
moDistanceStat< eoBit<int> > test(dist, sol1);
test(sol2);
assert(test.value()==2);
test(sol3);
assert(test.value()==1);
test(sol2);
assert(test.value()==2);
test(sol3);
assert(test.value()==1);
assert(test.className()=="moDistanceStat");
std::cout << "[t-moDistanceStat] => OK" << std::endl;
assert(test.className()=="moDistanceStat");
std::cout << "[t-moDistanceStat] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -35,29 +35,29 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moDummyMemory] => START" << std::endl;
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));
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));
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;
std::cout << "[t-moDummyMemory] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -36,58 +36,58 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moFirstImprExplorer] => START" << std::endl;
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;
//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);
moFirstImprExplorer<bitNeighborhood> test(nh, eval, ncomp, sncomp);
//on verifie qu'on améliore peut continuer à explorer tant qu'on améliore la solution
//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()==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()==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()==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));
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));
test(sol);
assert(!test.accept(sol));
assert(sol.fitness()==0);
assert(!test.isContinue(sol));
std::cout << "[t-moFirstImprExplorer] => OK" << std::endl;
std::cout << "[t-moFirstImprExplorer] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -34,24 +34,24 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moFitnessStat] => START" << std::endl;
std::cout << "[t-moFitnessStat] => START" << std::endl;
eoBit<int> sol;
eoBit<int> sol;
moFitnessStat< eoBit<int> > test;
sol.fitness(3);
test(sol);
assert(test.value()==3);
moFitnessStat< eoBit<int> > test;
sol.fitness(3);
test(sol);
assert(test.value()==3);
sol.fitness(12);
test(sol);
assert(test.value()==12);
sol.fitness(12);
test(sol);
assert(test.value()==12);
assert(test.className()=="moFitnessStat");
std::cout << "[t-moFitnessStat] => OK" << std::endl;
assert(test.className()=="moFitnessStat");
std::cout << "[t-moFitnessStat] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -38,26 +38,26 @@
#include <cstdlib>
#include <cassert>
int main(){
int main() {
//Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval
//Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval
std::cout << "[t-moFullEvalByCopy] => START" << std::endl;
std::cout << "[t-moFullEvalByCopy] => START" << std::endl;
Solution sol;
moDummyNeighbor neighbor;
moDummyEval eval;
Solution sol;
moDummyNeighbor neighbor;
moDummyEval eval;
//verif constructor
moFullEvalByCopy<moDummyNeighbor> test(eval);
//verif constructor
moFullEvalByCopy<moDummyNeighbor> test(eval);
sol.fitness(3);
sol.fitness(3);
//verif operator()
test(sol,neighbor);
assert(sol.fitness()==3);
//verif operator()
test(sol,neighbor);
assert(sol.fitness()==3);
std::cout << "[t-moFullEvalByCopy] => OK" << std::endl;
std::cout << "[t-moFullEvalByCopy] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -38,26 +38,26 @@
#include <cstdlib>
#include <cassert>
int main(){
int main() {
//Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval
//Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval
std::cout << "[t-moFullEvalByModif] => START" << std::endl;
std::cout << "[t-moFullEvalByModif] => START" << std::endl;
Solution sol;
moDummyBackableNeighbor neighbor;
moDummyEval eval;
Solution sol;
moDummyBackableNeighbor neighbor;
moDummyEval eval;
//verif constructor
moFullEvalByModif<moDummyBackableNeighbor> test(eval);
//verif constructor
moFullEvalByModif<moDummyBackableNeighbor> test(eval);
sol.fitness(3);
sol.fitness(3);
//verif operator()
test(sol,neighbor);
assert(sol.fitness()==3);
//verif operator()
test(sol,neighbor);
assert(sol.fitness()==3);
std::cout << "[t-moFullEvalByModif] => OK" << std::endl;
std::cout << "[t-moFullEvalByModif] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -36,57 +36,57 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moHCneutralExplorer] => START" << std::endl;
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;
//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);
moHCneutralExplorer<bitNeighborhood> test(nh, eval, ncomp, sncomp,3);
//on verifie qu'on ameliore bien la solution et que l'exploration dure 3 itérations
//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));
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;
//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));
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;
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));
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 << sol << std::endl;
std::cout << "[t-moHCneutralExplorer] => OK" << std::endl;
std::cout << "[t-moHCneutralExplorer] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -34,64 +34,64 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moMetropolisHastingExplorer] => START" << std::endl;
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;
//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);
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));
//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;
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;
//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
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 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 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));
test.initParam(sol);
test(sol);
assert(!test.accept(sol));
std::cout << "[t-moMetropolisHastingExplorer] => OK" << std::endl;
std::cout << "[t-moMetropolisHastingExplorer] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -37,28 +37,28 @@
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moNeighbor] => START" << std::endl;
std::cout << "[t-moNeighbor] => START" << std::endl;
//test constructor
moDummyNeighbor test1, test2;
//test constructor
moDummyNeighbor test1, test2;
test1.fitness(3);
//test operateur d'affectation
test2=test1;
assert(test1.fitness()==test2.fitness());
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());
//test operateur de copy
moDummyNeighbor test3(test1);
assert(test1.fitness()==test3.fitness());
test1.printOn(std::cout);
test2.printOn(std::cout);
test3.printOn(std::cout);
test1.printOn(std::cout);
test2.printOn(std::cout);
test3.printOn(std::cout);
assert(test1.className()=="moNeighbor");
std::cout << "[t-moNeighbor] => OK" << std::endl;
assert(test1.className()=="moNeighbor");
std::cout << "[t-moNeighbor] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -40,29 +40,29 @@
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moNeighborComparator] => START" << std::endl;
std::cout << "[t-moNeighborComparator] => START" << std::endl;
moBitNeighbor<eoMinimizingFitness> neighbor1;
moBitNeighbor<eoMinimizingFitness> neighbor2;
moBitNeighbor<eoMinimizingFitness> neighbor1;
moBitNeighbor<eoMinimizingFitness> neighbor2;
moNeighborComparator< moBitNeighbor<eoMinimizingFitness> > test;
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));
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));
//test equals
assert(!test.equals(neighbor1,neighbor2));
neighbor2.fitness(3);
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;
assert(test.className()=="moNeighborComparator");
std::cout << "[t-moNeighborComparator] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -46,107 +46,107 @@ Contact: paradiseo-help@lists.gforge.inria.fr
/*
* Tests all classes depending of moNeighborhoodStat.h
*/
int main(){
int main() {
//test de moNeighborhoodStat.h
std::cout << "[t-moNeighborhoodStat] => START" << std::endl;
//test de moNeighborhoodStat.h
std::cout << "[t-moNeighborhoodStat] => START" << std::endl;
moNeighborComparator<bitNeighbor> neighborComp;
moSolNeighborComparator<bitNeighbor> solNeighborComp;
evalOneMax eval(10);
moNeighborComparator<bitNeighbor> neighborComp;
moSolNeighborComparator<bitNeighbor> solNeighborComp;
evalOneMax eval(10);
bitNeighborhood n(10);
bitNeighborhood n(10);
bitVector sol;
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.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);
sol.fitness(7);
moNeighborhoodStat<bitNeighborhood> test(n, eval, neighborComp, solNeighborComp);
moNeighborhoodStat<bitNeighborhood> test(n, eval, neighborComp, solNeighborComp);
test(sol);
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.getMin()==8);
assert(test.getMax()==6);
assert(test.getMean()==6.6);
double sd=test.getSD();
assert(sd>0.966 && sd<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;
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 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 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 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 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 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 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;
//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;
return EXIT_SUCCESS;
}

View file

@ -39,42 +39,42 @@
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moOrderNeighborhood] => START" << std::endl;
std::cout << "[t-moOrderNeighborhood] => START" << std::endl;
//init sol
eoBit<int> sol;
sol.push_back(true);
sol.push_back(false);
sol.push_back(true);
//init sol
eoBit<int> sol;
sol.push_back(true);
sol.push_back(false);
sol.push_back(true);
moBitNeighbor<int> neighbor;
moBitNeighbor<int> neighbor;
//verif du constructeur vide
moOrderNeighborhood<moBitNeighbor<int> > test(3);
assert(test.position()==0);
//verif du constructeur vide
moOrderNeighborhood<moBitNeighbor<int> > test(3);
assert(test.position()==0);
//verif du hasneighbor
assert(test.hasNeighbor(sol));
//verif du hasneighbor
assert(test.hasNeighbor(sol));
//verif de init
test.init(sol, neighbor);
assert(neighbor.index()==0);
assert(test.position()==0);
//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 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));
//verif du cont
assert(test.cont(sol));
test.next(sol, neighbor);
assert(!test.cont(sol));
assert(test.className()=="moOrderNeighborhood");
assert(test.className()=="moOrderNeighborhood");
std::cout << "[t-moOrderNeighborhood] => OK" << std::endl;
return EXIT_SUCCESS;
std::cout << "[t-moOrderNeighborhood] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -34,55 +34,55 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moRandomNeutralWalkExplorer] => START" << std::endl;
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;
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 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.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);
//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));
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));
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;
std::cout << "[t-moRandomNeutralWalkExplorer] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -34,46 +34,46 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moRandomWalkExplorer] => START" << std::endl;
std::cout << "[t-moRandomWalkExplorer] => START" << std::endl;
eoBit<eoMinimizingFitness> sol(4, true);
sol.fitness(4);
bitNeighborhood nh(4);
evalOneMax eval(4);
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 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.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()==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()==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));
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;
std::cout << "[t-moRandomWalkExplorer] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -35,41 +35,41 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moRndWithReplNeighborhood] => START" << std::endl;
std::cout << "[t-moRndWithReplNeighborhood] => START" << std::endl;
unsigned int a, b;
eoBit<int> sol;
moBitNeighbor<int> n;
unsigned int a, b;
eoBit<int> sol;
moBitNeighbor<int> n;
moRndWithReplNeighborhood< moBitNeighbor<int> > test(3);
moRndWithReplNeighborhood< moBitNeighbor<int> > test2(0);
moRndWithReplNeighborhood< moBitNeighbor<int> > test(3);
moRndWithReplNeighborhood< moBitNeighbor<int> > test2(0);
assert(test.hasNeighbor(sol));
assert(!test2.hasNeighbor(sol));
assert(test.hasNeighbor(sol));
assert(!test2.hasNeighbor(sol));
test.init(sol,n);
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++){
//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();
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(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");
assert(test.className()=="moRndWithReplNeighborhood");
std::cout << "[t-moRndWithReplNeighborhood] => OK" << std::endl;
std::cout << "[t-moRndWithReplNeighborhood] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -35,42 +35,42 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moRndWithoutReplNeighborhood] => START" << std::endl;
std::cout << "[t-moRndWithoutReplNeighborhood] => START" << std::endl;
unsigned int a, b, c;
eoBit<int> sol;
moBitNeighbor<int> n;
unsigned int a, b, c;
eoBit<int> sol;
moBitNeighbor<int> n;
//instanciation
moRndWithoutReplNeighborhood< moBitNeighbor<int> > test(3);
moRndWithoutReplNeighborhood< moBitNeighbor<int> > test2(0);
//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 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 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);
//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");
assert(test.className()=="moRndWithoutReplNeighborhood");
std::cout << "[t-moRndWithoutReplNeighborhood] => OK" << std::endl;
std::cout << "[t-moRndWithoutReplNeighborhood] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -41,52 +41,52 @@
#include <cstdlib>
#include <cassert>
int main(){
int main() {
//Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval
//Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval
std::cout << "[t-moSimpleHCexplorer] => START" << std::endl;
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;
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 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));
//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 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));
//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);
//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));
//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");
assert(test.className()=="moSimpleHCexplorer");
std::cout << "[t-moSimpleHCexplorer] => OK" << std::endl;
std::cout << "[t-moSimpleHCexplorer] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -36,66 +36,66 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moSimpleHCneutralExplorer] => START" << std::endl;
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;
//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);
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);
//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;
//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);
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;
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);
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;
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));
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);
test(sol);
assert(!test.accept(sol));
assert(sol.fitness()==0);
assert(!test.isContinue(sol));
test.updateParam(sol);
std::cout << "[t-moSimpleHCneutralExplorer] => OK" << std::endl;
std::cout << "[t-moSimpleHCneutralExplorer] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -40,33 +40,33 @@
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moSolNeighborComparator] => START" << std::endl;
std::cout << "[t-moSolNeighborComparator] => START" << std::endl;
moBitNeighbor<eoMinimizingFitness> neighbor;
eoBit<eoMinimizingFitness> sol;
moBitNeighbor<eoMinimizingFitness> neighbor;
eoBit<eoMinimizingFitness> sol;
moSolNeighborComparator< moBitNeighbor<eoMinimizingFitness> > test;
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));
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));
//reversly
neighbor.fitness(2);
sol.fitness(3);
assert(test(sol, neighbor));
//test equals
assert(!test.equals(sol, neighbor));
//test equals
assert(!test.equals(sol, neighbor));
neighbor.fitness(3);
assert(test.equals(sol, neighbor));
neighbor.fitness(3);
assert(test.equals(sol, neighbor));
assert(test.className()=="moSolNeighborComparator");
assert(test.className()=="moSolNeighborComparator");
std::cout << "[t-moSolNeighborComparator] => OK" << std::endl;
return EXIT_SUCCESS;
std::cout << "[t-moSolNeighborComparator] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -34,121 +34,121 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moSolVectorTabuList] => START" << std::endl;
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);
//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);
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;
sol2[0]=false;
sol3[1]=false;
sol4[0]=false;
sol4[1]=false;
//init
test.init(sol1);
//init
test.init(sol1);
//ajout d'une sol tabu
test.add(sol1,n1);
//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));
//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(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));
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.init(sol1);
assert(!test.check(sol2,n1));
assert(!test.check(sol3,n2));
test.update(sol1,n1);
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.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));
//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(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));
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));
//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(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));
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));
//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(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));
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;
std::cout << "[t-moSolVectorTabuList] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -34,31 +34,31 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moSolutionStat] => START" << std::endl;
std::cout << "[t-moSolutionStat] => START" << std::endl;
eoBit<unsigned int> s(3);
s[0]=true;
s[1]=true;
s[2]=false;
eoBit<unsigned int> s(3);
s[0]=true;
s[1]=true;
s[2]=false;
s.fitness(17);
s.fitness(17);
moSolutionStat< eoBit<unsigned int > > test;
moSolutionStat< eoBit<unsigned int > > test;
test(s);
//on verifie que la solution est bien enregistré
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.value()[0]);
assert(test.value()[1]);
assert(!test.value()[2]);
assert(test.value().fitness()==17);
assert(test.className()=="moSolutionStat");
assert(test.className()=="moSolutionStat");
std::cout << "[t-moSolutionStat] => OK" << std::endl;
std::cout << "[t-moSolutionStat] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -38,128 +38,128 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib>
#include <cassert>
int main(){
int main() {
std::cout << "[t-moTSExplorer] => START" << std::endl;
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;
//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);
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 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 le comportement classique de la taboo
test.initParam(sol);
assert(aspir.getBest()==sol);
test(sol);
test.updateParam(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 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);
//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);
//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);
//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 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 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);
//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);
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.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);
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));
//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;
std::cout << "[t-moTSExplorer] => OK" << std::endl;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View file

@ -39,15 +39,15 @@
#include <cassert>
int main(){
int main() {
std::cout << "[t-moTrueContinuator] => START" << std::endl;
std::cout << "[t-moTrueContinuator] => START" << std::endl;
moTrueContinuator<moDummyNeighborhood> test;
Solution s;
moTrueContinuator<moDummyNeighborhood> test;
Solution s;
assert(test(s));
assert(test(s));
std::cout << "[t-moTrueContinuator] => OK" << std::endl;
return EXIT_SUCCESS;
std::cout << "[t-moTrueContinuator] => OK" << std::endl;
return EXIT_SUCCESS;
}