Encore du nettoyage
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1814 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
3d8057ac4d
commit
02e5cfb6c0
66 changed files with 987 additions and 1785 deletions
|
|
@ -34,18 +34,18 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <acceptCrit/moAlwaysAcceptCrit.h>
|
#include <acceptCrit/moAlwaysAcceptCrit.h>
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moAlwaysAcceptCrit] => START" << std::endl;
|
std::cout << "[t-moAlwaysAcceptCrit] => START" << std::endl;
|
||||||
|
|
||||||
bitVector sol1, sol2;
|
bitVector sol1, sol2;
|
||||||
|
|
||||||
moAlwaysAcceptCrit<bitNeighbor> test;
|
moAlwaysAcceptCrit<bitNeighbor> test;
|
||||||
|
|
||||||
assert(test(sol1,sol2));
|
assert(test(sol1,sol2));
|
||||||
|
|
||||||
std::cout << "[t-moAlwaysAcceptCrit] => OK" << std::endl;
|
std::cout << "[t-moAlwaysAcceptCrit] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,24 +35,24 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
#include <eval/oneMaxEval.h>
|
#include <eval/oneMaxEval.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moAutocorrelationSampling] => START" << std::endl;
|
std::cout << "[t-moAutocorrelationSampling] => START" << std::endl;
|
||||||
|
|
||||||
bitNeighborhood nh(4);
|
bitNeighborhood nh(4);
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
dummyInit2 init(4);
|
dummyInit2 init(4);
|
||||||
|
|
||||||
moAutocorrelationSampling<bitNeighbor> test(init, nh, fullEval, eval, 3);
|
moAutocorrelationSampling<bitNeighbor> test(init, nh, fullEval, eval, 3);
|
||||||
|
|
||||||
test();
|
test();
|
||||||
|
|
||||||
test.fileExport("outputTestAutocorrelationSampling");
|
test.fileExport("outputTestAutocorrelationSampling");
|
||||||
|
|
||||||
|
|
||||||
std::cout << "[t-moAutocorrelationSampling] => OK" << std::endl;
|
std::cout << "[t-moAutocorrelationSampling] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,27 +35,27 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <acceptCrit/moBetterAcceptCrit.h>
|
#include <acceptCrit/moBetterAcceptCrit.h>
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moBetterAcceptCrit] => START" << std::endl;
|
std::cout << "[t-moBetterAcceptCrit] => START" << std::endl;
|
||||||
|
|
||||||
bitVector sol1, sol2, sol3;
|
bitVector sol1, sol2, sol3;
|
||||||
|
|
||||||
sol1.fitness(2);
|
sol1.fitness(2);
|
||||||
sol2.fitness(3);
|
sol2.fitness(3);
|
||||||
sol3.fitness(3);
|
sol3.fitness(3);
|
||||||
|
|
||||||
moSolComparator<bitVector> comparator;
|
moSolComparator<bitVector> comparator;
|
||||||
|
|
||||||
moBetterAcceptCrit<bitNeighbor> test(comparator);
|
moBetterAcceptCrit<bitNeighbor> test(comparator);
|
||||||
|
|
||||||
assert(test(sol2, sol1));
|
assert(test(sol2, sol1));
|
||||||
assert(!test(sol1, sol2));
|
assert(!test(sol1, sol2));
|
||||||
assert(!test(sol2, sol3));
|
assert(!test(sol2, sol3));
|
||||||
|
|
||||||
|
|
||||||
std::cout << "[t-moBetterAcceptCrit] => OK" << std::endl;
|
std::cout << "[t-moBetterAcceptCrit] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,9 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
|
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moCombinedContinuator] => START" << std::endl;
|
std::cout << "[t-moCombinedContinuator] => START" << std::endl;
|
||||||
|
|
||||||
moIterContinuator<moDummyNeighborTest> cont1(3, false);
|
moIterContinuator<moDummyNeighborTest> cont1(3, false);
|
||||||
moTrueContinuator<moDummyNeighborTest> cont2;
|
moTrueContinuator<moDummyNeighborTest> cont2;
|
||||||
|
|
@ -58,8 +58,8 @@ int main(){
|
||||||
assert(test(s));
|
assert(test(s));
|
||||||
assert(!test(s));
|
assert(!test(s));
|
||||||
|
|
||||||
std::cout << "[t-moCombinedContinuator] => OK" << std::endl;
|
std::cout << "[t-moCombinedContinuator] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,58 +34,58 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <memory/moCountMoveMemory.h>
|
#include <memory/moCountMoveMemory.h>
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moCountMoveMemory] => START" << std::endl;
|
std::cout << "[t-moCountMoveMemory] => START" << std::endl;
|
||||||
|
|
||||||
bitVector sol;
|
bitVector sol;
|
||||||
bitNeighbor n;
|
bitNeighbor n;
|
||||||
|
|
||||||
|
|
||||||
moCountMoveMemory<bitNeighbor> test;
|
moCountMoveMemory<bitNeighbor> test;
|
||||||
|
|
||||||
test.init(sol);
|
test.init(sol);
|
||||||
assert(test.getNbMove()==0);
|
assert(test.getNbMove()==0);
|
||||||
assert(test.getNbNoMove()==0);
|
assert(test.getNbNoMove()==0);
|
||||||
assert(test.getCounter()==0);
|
assert(test.getCounter()==0);
|
||||||
|
|
||||||
test.add(sol,n);
|
test.add(sol,n);
|
||||||
assert(test.getNbMove()==1);
|
assert(test.getNbMove()==1);
|
||||||
assert(test.getNbNoMove()==0);
|
assert(test.getNbNoMove()==0);
|
||||||
assert(test.getCounter()==0);
|
assert(test.getCounter()==0);
|
||||||
|
|
||||||
test.add(sol,n);
|
test.add(sol,n);
|
||||||
assert(test.getNbMove()==2);
|
assert(test.getNbMove()==2);
|
||||||
assert(test.getNbNoMove()==0);
|
assert(test.getNbNoMove()==0);
|
||||||
assert(test.getCounter()==0);
|
assert(test.getCounter()==0);
|
||||||
|
|
||||||
test.update(sol,n);
|
test.update(sol,n);
|
||||||
assert(test.getNbMove()==2);
|
assert(test.getNbMove()==2);
|
||||||
assert(test.getNbNoMove()==1);
|
assert(test.getNbNoMove()==1);
|
||||||
assert(test.getCounter()==1);
|
assert(test.getCounter()==1);
|
||||||
|
|
||||||
test.add(sol,n);
|
test.add(sol,n);
|
||||||
assert(test.getNbMove()==3);
|
assert(test.getNbMove()==3);
|
||||||
assert(test.getNbNoMove()==1);
|
assert(test.getNbNoMove()==1);
|
||||||
assert(test.getCounter()==0);
|
assert(test.getCounter()==0);
|
||||||
|
|
||||||
test.update(sol,n);
|
test.update(sol,n);
|
||||||
assert(test.getNbMove()==3);
|
assert(test.getNbMove()==3);
|
||||||
assert(test.getNbNoMove()==2);
|
assert(test.getNbNoMove()==2);
|
||||||
assert(test.getCounter()==1);
|
assert(test.getCounter()==1);
|
||||||
|
|
||||||
test.update(sol,n);
|
test.update(sol,n);
|
||||||
assert(test.getNbMove()==3);
|
assert(test.getNbMove()==3);
|
||||||
assert(test.getNbNoMove()==3);
|
assert(test.getNbNoMove()==3);
|
||||||
assert(test.getCounter()==2);
|
assert(test.getCounter()==2);
|
||||||
|
|
||||||
test.clearMemory();
|
test.clearMemory();
|
||||||
assert(test.getNbMove()==0);
|
assert(test.getNbMove()==0);
|
||||||
assert(test.getNbNoMove()==0);
|
assert(test.getNbNoMove()==0);
|
||||||
assert(test.getCounter()==0);
|
assert(test.getCounter()==0);
|
||||||
|
|
||||||
std::cout << "[t-moCountMoveMemory] => OK" << std::endl;
|
std::cout << "[t-moCountMoveMemory] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,30 +33,30 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
|
|
||||||
#include <continuator/moCounterStat.h>
|
#include <continuator/moCounterStat.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moCounterStat] => START" << std::endl;
|
std::cout << "[t-moCounterStat] => START" << std::endl;
|
||||||
|
|
||||||
moCounterStat<int> test;
|
moCounterStat<int> test;
|
||||||
|
|
||||||
int a=3;
|
int a=3;
|
||||||
|
|
||||||
test.init(a);
|
test.init(a);
|
||||||
assert(test.value()==0);
|
assert(test.value()==0);
|
||||||
a=5;
|
a=5;
|
||||||
test(a);
|
test(a);
|
||||||
assert(test.value()==1);
|
assert(test.value()==1);
|
||||||
a=-3;
|
a=-3;
|
||||||
test(a);
|
test(a);
|
||||||
assert(test.value()==2);
|
assert(test.value()==2);
|
||||||
a=-12;
|
a=-12;
|
||||||
test.init(a);
|
test.init(a);
|
||||||
assert(test.value()==0);
|
assert(test.value()==0);
|
||||||
|
|
||||||
assert(test.className()=="moCounterStat");
|
assert(test.className()=="moCounterStat");
|
||||||
|
|
||||||
std::cout << "[t-moCounterStat] => OK" << std::endl;
|
std::cout << "[t-moCounterStat] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,20 +35,20 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
#include <eval/oneMaxEval.h>
|
#include <eval/oneMaxEval.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moDensityOfStatesSampling] => START" << std::endl;
|
std::cout << "[t-moDensityOfStatesSampling] => START" << std::endl;
|
||||||
|
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
dummyInit2 init(4);
|
dummyInit2 init(4);
|
||||||
|
|
||||||
moDensityOfStatesSampling<bitNeighbor> test(init, fullEval, 3);
|
moDensityOfStatesSampling<bitNeighbor> test(init, fullEval, 3);
|
||||||
test();
|
test();
|
||||||
|
|
||||||
test.fileExport("outputTestDensityOfState");
|
test.fileExport("outputTestDensityOfState");
|
||||||
|
|
||||||
std::cout << "[t-moDensityOfStatesSampling] => OK" << std::endl;
|
std::cout << "[t-moDensityOfStatesSampling] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,14 +33,14 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <eval/moDummyEval.h>
|
#include <eval/moDummyEval.h>
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moDummyEval] => START" << std::endl;
|
std::cout << "[t-moDummyEval] => START" << std::endl;
|
||||||
|
|
||||||
moDummyEval<bitNeighbor> test;
|
moDummyEval<bitNeighbor> test;
|
||||||
|
|
||||||
std::cout << "[t-moDummyEval] => OK" << std::endl;
|
std::cout << "[t-moDummyEval] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,16 +34,16 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <explorer/moDummyExplorer.h>
|
#include <explorer/moDummyExplorer.h>
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moDummyExplorer] => START" << std::endl;
|
std::cout << "[t-moDummyExplorer] => START" << std::endl;
|
||||||
|
|
||||||
moDummyExplorer<bitNeighbor> test;
|
moDummyExplorer<bitNeighbor> test;
|
||||||
|
|
||||||
assert(test.className()=="moDummyExplorer");
|
assert(test.className()=="moDummyExplorer");
|
||||||
|
|
||||||
std::cout << "[t-moDummyExplorer] => OK" << std::endl;
|
std::cout << "[t-moDummyExplorer] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,17 +35,17 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
#include <eval/oneMaxEval.h>
|
#include <eval/oneMaxEval.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moDummyLS] => START" << std::endl;
|
std::cout << "[t-moDummyLS] => START" << std::endl;
|
||||||
|
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
moDummyLS<bitNeighbor> test(fullEval);
|
moDummyLS<bitNeighbor> test(fullEval);
|
||||||
|
|
||||||
assert(test.className()=="moDummyLS");
|
assert(test.className()=="moDummyLS");
|
||||||
|
|
||||||
std::cout << "[t-moDummyLS] => OK" << std::endl;
|
std::cout << "[t-moDummyLS] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,14 +33,14 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <neighborhood/moDummyNeighbor.h>
|
#include <neighborhood/moDummyNeighbor.h>
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moDummyNeighbor] => START" << std::endl;
|
std::cout << "[t-moDummyNeighbor] => START" << std::endl;
|
||||||
|
|
||||||
moDummyNeighbor<bitVector> test;
|
moDummyNeighbor<bitVector> test;
|
||||||
|
|
||||||
std::cout << "[t-moDummyNeighbor] => OK" << std::endl;
|
std::cout << "[t-moDummyNeighbor] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,23 +34,23 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <neighborhood/moDummyNeighborhood.h>
|
#include <neighborhood/moDummyNeighborhood.h>
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moDummyNeighborhood] => START" << std::endl;
|
std::cout << "[t-moDummyNeighborhood] => START" << std::endl;
|
||||||
|
|
||||||
bitVector sol;
|
bitVector sol;
|
||||||
moDummyNeighbor<bitVector> n;
|
moDummyNeighbor<bitVector> n;
|
||||||
|
|
||||||
moDummyNeighborhood<moDummyNeighbor<bitVector> > test;
|
moDummyNeighborhood<moDummyNeighbor<bitVector> > test;
|
||||||
|
|
||||||
assert(!test.hasNeighbor(sol));
|
assert(!test.hasNeighbor(sol));
|
||||||
assert(!test.cont(sol));
|
assert(!test.cont(sol));
|
||||||
test.init(sol,n);
|
test.init(sol,n);
|
||||||
test.next(sol,n);
|
test.next(sol,n);
|
||||||
|
|
||||||
|
|
||||||
std::cout << "[t-moDummyNeighborhood] => OK" << std::endl;
|
std::cout << "[t-moDummyNeighborhood] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,33 +34,33 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <eval/moEvalCounter.h>
|
#include <eval/moEvalCounter.h>
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moEvalCounter] => START" << std::endl;
|
std::cout << "[t-moEvalCounter] => START" << std::endl;
|
||||||
|
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
bitVector sol;
|
bitVector sol;
|
||||||
sol.resize(4);
|
sol.resize(4);
|
||||||
sol[0]=true;
|
sol[0]=true;
|
||||||
sol[1]=false;
|
sol[1]=false;
|
||||||
sol[2]=true;
|
sol[2]=true;
|
||||||
sol[3]=true;
|
sol[3]=true;
|
||||||
sol.fitness(3);
|
sol.fitness(3);
|
||||||
bitNeighbor n;
|
bitNeighbor n;
|
||||||
n.index(2);
|
n.index(2);
|
||||||
|
|
||||||
moEvalCounter<bitNeighbor> test(eval);
|
moEvalCounter<bitNeighbor> test(eval);
|
||||||
|
|
||||||
test(sol,n);
|
test(sol,n);
|
||||||
assert(test.value()==1);
|
assert(test.value()==1);
|
||||||
assert(n.fitness()==2);
|
assert(n.fitness()==2);
|
||||||
n.index(1);
|
n.index(1);
|
||||||
test(sol,n);
|
test(sol,n);
|
||||||
assert(test.value()==2);
|
assert(test.value()==2);
|
||||||
assert(n.fitness()==4);
|
assert(n.fitness()==4);
|
||||||
|
|
||||||
std::cout << "[t-moEvalCounter] => OK" << std::endl;
|
std::cout << "[t-moEvalCounter] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,25 +37,25 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <utils/eoDistance.h>
|
#include <utils/eoDistance.h>
|
||||||
#include <eval/oneMaxEval.h>
|
#include <eval/oneMaxEval.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moFDCsampling] => START" << std::endl;
|
std::cout << "[t-moFDCsampling] => START" << std::endl;
|
||||||
|
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
dummyInit2 init(4);
|
dummyInit2 init(4);
|
||||||
eoHammingDistance<bitVector> dist;
|
eoHammingDistance<bitVector> dist;
|
||||||
bitVector sol(4, false);
|
bitVector sol(4, false);
|
||||||
sol.fitness(0);
|
sol.fitness(0);
|
||||||
|
|
||||||
|
|
||||||
moFDCsampling<bitNeighbor> test(init, fullEval, dist, sol, 3);
|
moFDCsampling<bitNeighbor> test(init, fullEval, dist, sol, 3);
|
||||||
|
|
||||||
test();
|
test();
|
||||||
|
|
||||||
test.fileExport("outputTestFDCsampling");
|
test.fileExport("outputTestFDCsampling");
|
||||||
|
|
||||||
std::cout << "[t-moFDCsampling] => OK" << std::endl;
|
std::cout << "[t-moFDCsampling] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,28 +37,28 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <continuator/moTrueContinuator.h>
|
#include <continuator/moTrueContinuator.h>
|
||||||
#include <comparator/moSolNeighborComparator.h>
|
#include <comparator/moSolNeighborComparator.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moFirstImprHC] => START" << std::endl;
|
std::cout << "[t-moFirstImprHC] => START" << std::endl;
|
||||||
|
|
||||||
bitNeighborhood nh(4);
|
bitNeighborhood nh(4);
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
|
|
||||||
//test first constructor
|
//test first constructor
|
||||||
moFirstImprHC<bitNeighbor> test1(nh, fullEval, eval);
|
moFirstImprHC<bitNeighbor> test1(nh, fullEval, eval);
|
||||||
|
|
||||||
//test second constructor
|
//test second constructor
|
||||||
moTrueContinuator<bitNeighbor> cont;
|
moTrueContinuator<bitNeighbor> cont;
|
||||||
moFirstImprHC<bitNeighbor> test2(nh, fullEval, eval, cont);
|
moFirstImprHC<bitNeighbor> test2(nh, fullEval, eval, cont);
|
||||||
|
|
||||||
//test third constructor
|
//test third constructor
|
||||||
moSolNeighborComparator<bitNeighbor> sncomp;
|
moSolNeighborComparator<bitNeighbor> sncomp;
|
||||||
moNeighborComparator<bitNeighbor> ncomp;
|
moNeighborComparator<bitNeighbor> ncomp;
|
||||||
moFirstImprHC<bitNeighbor> test3(nh, fullEval, eval, cont, ncomp, sncomp);
|
moFirstImprHC<bitNeighbor> test3(nh, fullEval, eval, cont, ncomp, sncomp);
|
||||||
|
|
||||||
std::cout << "[t-moFirstImprHC] => OK" << std::endl;
|
std::cout << "[t-moFirstImprHC] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,28 +34,28 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <continuator/moFitContinuator.h>
|
#include <continuator/moFitContinuator.h>
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moFitContinuator] => START" << std::endl;
|
std::cout << "[t-moFitContinuator] => START" << std::endl;
|
||||||
|
|
||||||
moFitContinuator<bitNeighbor> test1(3);
|
moFitContinuator<bitNeighbor> test1(3);
|
||||||
moFitContinuator<moDummyNeighborTest> test2(5);
|
moFitContinuator<moDummyNeighborTest> test2(5);
|
||||||
|
|
||||||
bitVector sol1;
|
bitVector sol1;
|
||||||
Solution sol2;
|
Solution sol2;
|
||||||
|
|
||||||
sol1.fitness(4);
|
sol1.fitness(4);
|
||||||
assert(test1(sol1));
|
assert(test1(sol1));
|
||||||
sol1.fitness(3);
|
sol1.fitness(3);
|
||||||
assert(!test1(sol1));
|
assert(!test1(sol1));
|
||||||
|
|
||||||
sol2.fitness(3);
|
sol2.fitness(3);
|
||||||
assert(test2(sol2));
|
assert(test2(sol2));
|
||||||
sol2.fitness(5);
|
sol2.fitness(5);
|
||||||
assert(!test2(sol2));
|
assert(!test2(sol2));
|
||||||
|
|
||||||
std::cout << "[t-moFitContinuator] => OK" << std::endl;
|
std::cout << "[t-moFitContinuator] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,36 +40,36 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <eval/oneMaxEval.h>
|
#include <eval/oneMaxEval.h>
|
||||||
|
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moFitnessCloudSampling] => START" << std::endl;
|
std::cout << "[t-moFitnessCloudSampling] => START" << std::endl;
|
||||||
|
|
||||||
bitNeighborhood nh(4);
|
bitNeighborhood nh(4);
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
dummyInit2 init(4);
|
dummyInit2 init(4);
|
||||||
|
|
||||||
moFitnessCloudSampling<bitNeighbor> test1(init, nh, fullEval, eval, 3);
|
moFitnessCloudSampling<bitNeighbor> test1(init, nh, fullEval, eval, 3);
|
||||||
|
|
||||||
moRndRndFitnessCloudSampling<bitNeighbor> test2(init, nh, fullEval, eval, 3);
|
moRndRndFitnessCloudSampling<bitNeighbor> test2(init, nh, fullEval, eval, 3);
|
||||||
|
|
||||||
moRndBestFitnessCloudSampling<bitNeighbor> test3(init, nh, fullEval, eval, 3);
|
moRndBestFitnessCloudSampling<bitNeighbor> test3(init, nh, fullEval, eval, 3);
|
||||||
|
|
||||||
moMHRndFitnessCloudSampling<bitNeighbor> test4(init, nh, fullEval, eval, 3);
|
moMHRndFitnessCloudSampling<bitNeighbor> test4(init, nh, fullEval, eval, 3);
|
||||||
|
|
||||||
moMHBestFitnessCloudSampling<bitNeighbor> test5(init, nh, fullEval, eval, 3);
|
moMHBestFitnessCloudSampling<bitNeighbor> test5(init, nh, fullEval, eval, 3);
|
||||||
|
|
||||||
test1();
|
test1();
|
||||||
test2();
|
test2();
|
||||||
test3();
|
test3();
|
||||||
test4();
|
test4();
|
||||||
test5();
|
test5();
|
||||||
|
|
||||||
test1.fileExport("outputTestFitnessCloudSampling");
|
test1.fileExport("outputTestFitnessCloudSampling");
|
||||||
|
|
||||||
|
|
||||||
std::cout << "[t-moFitnessCloudSampling] => OK" << std::endl;
|
std::cout << "[t-moFitnessCloudSampling] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,19 +37,19 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moForwardVariableNeighborhood] => START" << std::endl;
|
std::cout << "[t-moForwardVariableNeighborhood] => START" << std::endl;
|
||||||
|
|
||||||
moRndWithoutReplNeighborhood<bitNeighbor> rndNH(8);
|
moRndWithoutReplNeighborhood<bitNeighbor> rndNH(8);
|
||||||
moOrderNeighborhood<moIndexNeighbor<eoBit<eoMinimizingFitness> > >orderNH(8);
|
moOrderNeighborhood<moIndexNeighbor<eoBit<eoMinimizingFitness> > >orderNH(8);
|
||||||
|
|
||||||
|
|
||||||
//moForwardVariableNeighborhood<eoBit<eoMinimizingFitness>, eoMinimizingFitness> test(orderNH);
|
//moForwardVariableNeighborhood<eoBit<eoMinimizingFitness>, eoMinimizingFitness> test(orderNH);
|
||||||
|
|
||||||
|
|
||||||
std::cout << "[t-moForwardVariableNeighborhood] => OK" << std::endl;
|
std::cout << "[t-moForwardVariableNeighborhood] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,36 +35,36 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <eval/oneMaxEval.h>
|
#include <eval/oneMaxEval.h>
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moFullEvalContinuator] => START" << std::endl;
|
std::cout << "[t-moFullEvalContinuator] => START" << std::endl;
|
||||||
|
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
eoEvalFuncCounter<bitVector> evalCount(fullEval);
|
eoEvalFuncCounter<bitVector> evalCount(fullEval);
|
||||||
moFullEvalContinuator<bitNeighbor> test(evalCount, 3);
|
moFullEvalContinuator<bitNeighbor> test(evalCount, 3);
|
||||||
|
|
||||||
bitVector sol;
|
bitVector sol;
|
||||||
sol.push_back(1);
|
sol.push_back(1);
|
||||||
|
|
||||||
|
|
||||||
test.init(sol);
|
test.init(sol);
|
||||||
evalCount(sol);
|
evalCount(sol);
|
||||||
sol.invalidate();
|
sol.invalidate();
|
||||||
assert(test.value()==1);
|
assert(test.value()==1);
|
||||||
evalCount(sol);
|
evalCount(sol);
|
||||||
sol.invalidate();
|
sol.invalidate();
|
||||||
assert(test.value()==2);
|
assert(test.value()==2);
|
||||||
assert(test(sol));
|
assert(test(sol));
|
||||||
evalCount(sol);
|
evalCount(sol);
|
||||||
sol.invalidate();
|
sol.invalidate();
|
||||||
assert(test.value()==3);
|
assert(test.value()==3);
|
||||||
assert(!test(sol));
|
assert(!test(sol));
|
||||||
test.init(sol);
|
test.init(sol);
|
||||||
assert(test.value()==0);
|
assert(test.value()==0);
|
||||||
assert(test(sol));
|
assert(test(sol));
|
||||||
|
|
||||||
std::cout << "[t-moFullEvalContinuator] => OK" << std::endl;
|
std::cout << "[t-moFullEvalContinuator] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,23 +35,23 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
#include <eval/oneMaxEval.h>
|
#include <eval/oneMaxEval.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moHillClimberSampling] => START" << std::endl;
|
std::cout << "[t-moHillClimberSampling] => START" << std::endl;
|
||||||
|
|
||||||
bitNeighborhood nh(4);
|
bitNeighborhood nh(4);
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
dummyInit2 init(4);
|
dummyInit2 init(4);
|
||||||
|
|
||||||
moHillClimberSampling<bitNeighbor> test(init, nh, fullEval, eval, 3);
|
moHillClimberSampling<bitNeighbor> test(init, nh, fullEval, eval, 3);
|
||||||
|
|
||||||
test();
|
test();
|
||||||
|
|
||||||
test.fileExport("outputTestHillClimberSampling");
|
test.fileExport("outputTestHillClimberSampling");
|
||||||
|
|
||||||
std::cout << "[t-moHillClimberSampling] => OK" << std::endl;
|
std::cout << "[t-moHillClimberSampling] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,37 +41,39 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <memory/moSolVectorTabuList.h>
|
#include <memory/moSolVectorTabuList.h>
|
||||||
#include <neighborhood/moDummyNeighbor.h>
|
#include <neighborhood/moDummyNeighbor.h>
|
||||||
|
|
||||||
class dummyMonOp: public eoMonOp<bitVector>{
|
class dummyMonOp: public eoMonOp<bitVector> {
|
||||||
public:
|
public:
|
||||||
bool operator()(bitVector&){return false;}
|
bool operator()(bitVector&) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moILS] => START" << std::endl;
|
std::cout << "[t-moILS] => START" << std::endl;
|
||||||
|
|
||||||
bitNeighborhood nh(4);
|
bitNeighborhood nh(4);
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
|
|
||||||
moTS<bitNeighbor> ts(nh, fullEval, eval, 1, 7);
|
moTS<bitNeighbor> ts(nh, fullEval, eval, 1, 7);
|
||||||
|
|
||||||
dummyMonOp op;
|
dummyMonOp op;
|
||||||
|
|
||||||
//basic constructor
|
//basic constructor
|
||||||
moILS<bitNeighbor> test1(ts, fullEval, op, 3);
|
moILS<bitNeighbor> test1(ts, fullEval, op, 3);
|
||||||
|
|
||||||
//simple constructor
|
//simple constructor
|
||||||
moTrueContinuator<moDummyNeighbor<bitVector> > cont;
|
moTrueContinuator<moDummyNeighbor<bitVector> > cont;
|
||||||
moILS<bitNeighbor> test2(ts, fullEval, op, cont);
|
moILS<bitNeighbor> test2(ts, fullEval, op, cont);
|
||||||
|
|
||||||
//general constructor
|
//general constructor
|
||||||
moMonOpPerturb<bitNeighbor> perturb(op, fullEval);
|
moMonOpPerturb<bitNeighbor> perturb(op, fullEval);
|
||||||
moAlwaysAcceptCrit<bitNeighbor> accept;
|
moAlwaysAcceptCrit<bitNeighbor> accept;
|
||||||
moILS<bitNeighbor> test3(ts, fullEval, cont, perturb, accept);
|
moILS<bitNeighbor> test3(ts, fullEval, cont, perturb, accept);
|
||||||
|
|
||||||
std::cout << "[t-moILS] => OK" << std::endl;
|
std::cout << "[t-moILS] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,59 +42,59 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <acceptCrit/moAlwaysAcceptCrit.h>
|
#include <acceptCrit/moAlwaysAcceptCrit.h>
|
||||||
|
|
||||||
|
|
||||||
class dummyMonOp: public eoMonOp<bitVector>{
|
class dummyMonOp: public eoMonOp<bitVector> {
|
||||||
|
|
||||||
bool operator()(bitVector& _sol){
|
bool operator()(bitVector& _sol) {
|
||||||
_sol[0]=!_sol[0];
|
_sol[0]=!_sol[0];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moILSexplorer] => START" << std::endl;
|
std::cout << "[t-moILSexplorer] => START" << std::endl;
|
||||||
bitNeighborhood nh(4);
|
bitNeighborhood nh(4);
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
|
|
||||||
bitVector sol(4, true);
|
bitVector sol(4, true);
|
||||||
fullEval(sol);
|
fullEval(sol);
|
||||||
|
|
||||||
//test first constructor
|
//test first constructor
|
||||||
moSimpleHC<bitNeighbor> ls(nh, fullEval, eval);
|
moSimpleHC<bitNeighbor> ls(nh, fullEval, eval);
|
||||||
|
|
||||||
dummyMonOp op;
|
dummyMonOp op;
|
||||||
moMonOpPerturb<bitNeighbor> perturb(op, fullEval);
|
moMonOpPerturb<bitNeighbor> perturb(op, fullEval);
|
||||||
|
|
||||||
moAlwaysAcceptCrit<bitNeighbor> accept;
|
moAlwaysAcceptCrit<bitNeighbor> accept;
|
||||||
|
|
||||||
moILSexplorer<bitNeighbor> test(ls, perturb, accept);
|
moILSexplorer<bitNeighbor> test(ls, perturb, accept);
|
||||||
|
|
||||||
assert(test.className()=="moILSexplorer");
|
assert(test.className()=="moILSexplorer");
|
||||||
assert(test.isContinue(sol));
|
assert(test.isContinue(sol));
|
||||||
assert(test.accept(sol));
|
assert(test.accept(sol));
|
||||||
|
|
||||||
test.initParam(sol);
|
test.initParam(sol);
|
||||||
test.moveApplied(true);
|
test.moveApplied(true);
|
||||||
test.updateParam(sol);
|
test.updateParam(sol);
|
||||||
test.moveApplied(false);
|
test.moveApplied(false);
|
||||||
test.updateParam(sol);
|
test.updateParam(sol);
|
||||||
test.terminate(sol);
|
test.terminate(sol);
|
||||||
|
|
||||||
test.initParam(sol);
|
test.initParam(sol);
|
||||||
test(sol);
|
test(sol);
|
||||||
test.move(sol);
|
test.move(sol);
|
||||||
|
|
||||||
for(unsigned int i=0; i<sol.size(); i++)
|
for (unsigned int i=0; i<sol.size(); i++)
|
||||||
assert(!sol[i]);
|
assert(!sol[i]);
|
||||||
assert(sol.fitness()==0);
|
assert(sol.fitness()==0);
|
||||||
|
|
||||||
test(sol);
|
test(sol);
|
||||||
|
|
||||||
|
|
||||||
std::cout << "[t-moILSexplorer] => OK" << std::endl;
|
std::cout << "[t-moILSexplorer] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,9 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <continuator/moIterContinuator.h>
|
#include <continuator/moIterContinuator.h>
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moIterContinuator] => START" << std::endl;
|
std::cout << "[t-moIterContinuator] => START" << std::endl;
|
||||||
|
|
||||||
moIterContinuator<moDummyNeighborTest> test(3, false);
|
moIterContinuator<moDummyNeighborTest> test(3, false);
|
||||||
moIterContinuator<moDummyNeighborTest> test2(3);
|
moIterContinuator<moDummyNeighborTest> test2(3);
|
||||||
|
|
@ -54,8 +54,8 @@ int main(){
|
||||||
assert(test.value()==0);
|
assert(test.value()==0);
|
||||||
|
|
||||||
|
|
||||||
std::cout << "[t-moIterContinuator] => OK" << std::endl;
|
std::cout << "[t-moIterContinuator] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,32 +39,32 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
|
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moLocalSearch] => START" << std::endl;
|
std::cout << "[t-moLocalSearch] => START" << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bitNeighborhood nh(8);
|
bitNeighborhood nh(8);
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
evalOneMax eval(8);
|
evalOneMax eval(8);
|
||||||
moTrueContinuator<bitNeighbor> cont;
|
moTrueContinuator<bitNeighbor> cont;
|
||||||
moSolNeighborComparator<bitNeighbor> sncomp;
|
moSolNeighborComparator<bitNeighbor> sncomp;
|
||||||
moNeighborComparator<bitNeighbor> ncomp;
|
moNeighborComparator<bitNeighbor> ncomp;
|
||||||
moSimpleHCexplorer<bitNeighbor> explorer(nh, eval, ncomp, sncomp);
|
moSimpleHCexplorer<bitNeighbor> explorer(nh, eval, ncomp, sncomp);
|
||||||
moLocalSearch<bitNeighbor> test(explorer, cont, fullEval);
|
moLocalSearch<bitNeighbor> test(explorer, cont, fullEval);
|
||||||
|
|
||||||
bitVector sol(8, true);
|
bitVector sol(8, true);
|
||||||
|
|
||||||
test(sol);
|
test(sol);
|
||||||
|
|
||||||
assert(sol.fitness()==0);
|
assert(sol.fitness()==0);
|
||||||
for(unsigned int i=0; i<sol.size(); i++)
|
for (unsigned int i=0; i<sol.size(); i++)
|
||||||
assert(!sol[i]);
|
assert(!sol[i]);
|
||||||
|
|
||||||
|
|
||||||
std::cout << "[t-moLocalSearch] => OK" << std::endl;
|
std::cout << "[t-moLocalSearch] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,22 +37,22 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <eval/oneMaxEval.h>
|
#include <eval/oneMaxEval.h>
|
||||||
|
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moLocalSearchInit] => START" << std::endl;
|
std::cout << "[t-moLocalSearchInit] => START" << std::endl;
|
||||||
|
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
moDummyLS<bitNeighbor> ls(fullEval);
|
moDummyLS<bitNeighbor> ls(fullEval);
|
||||||
dummyInit init;
|
dummyInit init;
|
||||||
bitVector sol;
|
bitVector sol;
|
||||||
sol.fitness(0);
|
sol.fitness(0);
|
||||||
|
|
||||||
moLocalSearchInit<bitNeighbor> test(init, ls);
|
moLocalSearchInit<bitNeighbor> test(init, ls);
|
||||||
|
|
||||||
test(sol);
|
test(sol);
|
||||||
|
|
||||||
std::cout << "[t-moLocalSearchInit] => OK" << std::endl;
|
std::cout << "[t-moLocalSearchInit] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,28 +38,28 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <comparator/moSolNeighborComparator.h>
|
#include <comparator/moSolNeighborComparator.h>
|
||||||
#include <comparator/moNeighborComparator.h>
|
#include <comparator/moNeighborComparator.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moMetropolisHasting] => START" << std::endl;
|
std::cout << "[t-moMetropolisHasting] => START" << std::endl;
|
||||||
|
|
||||||
bitNeighborhood nh(4);
|
bitNeighborhood nh(4);
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
moTrueContinuator<bitNeighbor> cont;
|
moTrueContinuator<bitNeighbor> cont;
|
||||||
moSolNeighborComparator<bitNeighbor> sncomp;
|
moSolNeighborComparator<bitNeighbor> sncomp;
|
||||||
moNeighborComparator<bitNeighbor> ncomp;
|
moNeighborComparator<bitNeighbor> ncomp;
|
||||||
|
|
||||||
//test du 1er constructeur
|
//test du 1er constructeur
|
||||||
moMetropolisHasting<bitNeighbor> test1(nh, fullEval, eval, 3);
|
moMetropolisHasting<bitNeighbor> test1(nh, fullEval, eval, 3);
|
||||||
|
|
||||||
//test du 2eme constructeur
|
//test du 2eme constructeur
|
||||||
moMetropolisHasting<bitNeighbor> test2(nh, fullEval, eval, 3, cont);
|
moMetropolisHasting<bitNeighbor> test2(nh, fullEval, eval, 3, cont);
|
||||||
|
|
||||||
//test du 3eme constructeur
|
//test du 3eme constructeur
|
||||||
moMetropolisHasting<bitNeighbor> test3(nh, fullEval, eval, 3, cont, ncomp, sncomp);
|
moMetropolisHasting<bitNeighbor> test3(nh, fullEval, eval, 3, cont, ncomp, sncomp);
|
||||||
|
|
||||||
std::cout << "[t-moMetropolisHasting] => OK" << std::endl;
|
std::cout << "[t-moMetropolisHasting] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,32 +33,32 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
|
|
||||||
#include <continuator/moMinusOneCounterStat.h>
|
#include <continuator/moMinusOneCounterStat.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moMinusOneCounterStat] => START" << std::endl;
|
std::cout << "[t-moMinusOneCounterStat] => START" << std::endl;
|
||||||
|
|
||||||
moMinusOneCounterStat<int> test;
|
moMinusOneCounterStat<int> test;
|
||||||
|
|
||||||
int a=3;
|
int a=3;
|
||||||
|
|
||||||
test.init(a);
|
test.init(a);
|
||||||
assert(test.value()==0);
|
assert(test.value()==0);
|
||||||
a=5;
|
a=5;
|
||||||
test(a);
|
test(a);
|
||||||
assert(test.value()==0);
|
assert(test.value()==0);
|
||||||
a=-3;
|
a=-3;
|
||||||
test(a);
|
test(a);
|
||||||
assert(test.value()==1);
|
assert(test.value()==1);
|
||||||
a=-12;
|
a=-12;
|
||||||
test(a);
|
test(a);
|
||||||
assert(test.value()==2);
|
assert(test.value()==2);
|
||||||
test.init(a);
|
test.init(a);
|
||||||
assert(test.value()==0);
|
assert(test.value()==0);
|
||||||
|
|
||||||
assert(test.className()=="moMinusOneCounterStat");
|
assert(test.className()=="moMinusOneCounterStat");
|
||||||
|
|
||||||
std::cout << "[t-moMinusOneCounterStat] => OK" << std::endl;
|
std::cout << "[t-moMinusOneCounterStat] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,37 +38,37 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <eval/oneMaxEval.h>
|
#include <eval/oneMaxEval.h>
|
||||||
|
|
||||||
|
|
||||||
class dummyMonOp: public eoMonOp<bitVector>{
|
class dummyMonOp: public eoMonOp<bitVector> {
|
||||||
|
|
||||||
bool operator()(bitVector& _sol){
|
bool operator()(bitVector& _sol) {
|
||||||
_sol[0]=!_sol[0];
|
_sol[0]=!_sol[0];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moMonOpDiversification] => START" << std::endl;
|
std::cout << "[t-moMonOpDiversification] => START" << std::endl;
|
||||||
|
|
||||||
dummyMonOp op;
|
dummyMonOp op;
|
||||||
oneMaxEval<bitVector> eval;
|
oneMaxEval<bitVector> eval;
|
||||||
|
|
||||||
bitVector sol;
|
bitVector sol;
|
||||||
sol.push_back(1);
|
sol.push_back(1);
|
||||||
sol.push_back(0);
|
sol.push_back(0);
|
||||||
sol.push_back(1);
|
sol.push_back(1);
|
||||||
|
|
||||||
sol.fitness(5);
|
sol.fitness(5);
|
||||||
|
|
||||||
moMonOpDiversification<bitNeighbor> test(op, eval);
|
moMonOpDiversification<bitNeighbor> test(op, eval);
|
||||||
|
|
||||||
test(sol);
|
test(sol);
|
||||||
|
|
||||||
assert(sol.fitness()==1);
|
assert(sol.fitness()==1);
|
||||||
|
|
||||||
std::cout << "[t-moMonOpDiversification] => OK" << std::endl;
|
std::cout << "[t-moMonOpDiversification] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,38 +37,38 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <eval/oneMaxEval.h>
|
#include <eval/oneMaxEval.h>
|
||||||
|
|
||||||
|
|
||||||
class dummyMonOp: public eoMonOp<bitVector>{
|
class dummyMonOp: public eoMonOp<bitVector> {
|
||||||
|
|
||||||
bool operator()(bitVector& _sol){
|
bool operator()(bitVector& _sol) {
|
||||||
_sol[0]=!_sol[0];
|
_sol[0]=!_sol[0];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moMonOpPerturb] => START" << std::endl;
|
std::cout << "[t-moMonOpPerturb] => START" << std::endl;
|
||||||
|
|
||||||
dummyMonOp op;
|
dummyMonOp op;
|
||||||
oneMaxEval<bitVector> eval;
|
oneMaxEval<bitVector> eval;
|
||||||
|
|
||||||
bitVector sol;
|
bitVector sol;
|
||||||
sol.push_back(1);
|
sol.push_back(1);
|
||||||
sol.push_back(0);
|
sol.push_back(0);
|
||||||
sol.push_back(1);
|
sol.push_back(1);
|
||||||
|
|
||||||
sol.fitness(5);
|
sol.fitness(5);
|
||||||
|
|
||||||
moMonOpPerturb<bitNeighbor> test(op, eval);
|
moMonOpPerturb<bitNeighbor> test(op, eval);
|
||||||
|
|
||||||
test(sol);
|
test(sol);
|
||||||
|
|
||||||
assert(sol.fitness()==1);
|
assert(sol.fitness()==1);
|
||||||
|
|
||||||
|
|
||||||
std::cout << "[t-moMonOpPerturb] => OK" << std::endl;
|
std::cout << "[t-moMonOpPerturb] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,41 +34,41 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <continuator/moNeighborBestStat.h>
|
#include <continuator/moNeighborBestStat.h>
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moNeighborBestStat] => START" << std::endl;
|
std::cout << "[t-moNeighborBestStat] => START" << std::endl;
|
||||||
|
|
||||||
bitNeighborhood nh(4);
|
bitNeighborhood nh(4);
|
||||||
bitNeighborhood emptyNH(0);
|
bitNeighborhood emptyNH(0);
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
moSolNeighborComparator<bitNeighbor> sncomp;
|
moSolNeighborComparator<bitNeighbor> sncomp;
|
||||||
moNeighborComparator<bitNeighbor> ncomp;
|
moNeighborComparator<bitNeighbor> ncomp;
|
||||||
|
|
||||||
moNeighborBestStat<bitNeighbor> test1(nh, eval, ncomp, sncomp, 1);
|
moNeighborBestStat<bitNeighbor> test1(nh, eval, ncomp, sncomp, 1);
|
||||||
moNeighborBestStat<bitNeighbor> test2(nh, eval);
|
moNeighborBestStat<bitNeighbor> test2(nh, eval);
|
||||||
moNeighborBestStat<bitNeighbor> test3(emptyNH, eval);
|
moNeighborBestStat<bitNeighbor> test3(emptyNH, eval);
|
||||||
|
|
||||||
bitVector sol(4, true);
|
bitVector sol(4, true);
|
||||||
sol.fitness(4);
|
sol.fitness(4);
|
||||||
|
|
||||||
test1.init(sol);
|
test1.init(sol);
|
||||||
assert(test1.value()==3);
|
assert(test1.value()==3);
|
||||||
|
|
||||||
sol[0]=false;
|
sol[0]=false;
|
||||||
sol.fitness(3);
|
sol.fitness(3);
|
||||||
test1(sol);
|
test1(sol);
|
||||||
assert(test1.value()==4);
|
assert(test1.value()==4);
|
||||||
|
|
||||||
test2(sol);
|
test2(sol);
|
||||||
assert(test2.value()==2);
|
assert(test2.value()==2);
|
||||||
|
|
||||||
test3(sol);
|
test3(sol);
|
||||||
assert(test3.value()==int());
|
assert(test3.value()==int());
|
||||||
|
|
||||||
assert(test1.className()=="moNeighborBestStat");
|
assert(test1.className()=="moNeighborBestStat");
|
||||||
|
|
||||||
std::cout << "[t-moNeighborBestStat] => OK" << std::endl;
|
std::cout << "[t-moNeighborBestStat] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,36 +34,36 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <continuator/moNeighborEvalContinuator.h>
|
#include <continuator/moNeighborEvalContinuator.h>
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moNeighborEvalContinuator] => START" << std::endl;
|
std::cout << "[t-moNeighborEvalContinuator] => START" << std::endl;
|
||||||
|
|
||||||
evalOneMax moEval(2);
|
evalOneMax moEval(2);
|
||||||
moEvalCounter<bitNeighbor> evalCount(moEval);
|
moEvalCounter<bitNeighbor> evalCount(moEval);
|
||||||
moNeighborEvalContinuator<bitNeighbor> test(evalCount, 3);
|
moNeighborEvalContinuator<bitNeighbor> test(evalCount, 3);
|
||||||
|
|
||||||
bitVector sol;
|
bitVector sol;
|
||||||
sol.push_back(true);
|
sol.push_back(true);
|
||||||
sol.push_back(false);
|
sol.push_back(false);
|
||||||
|
|
||||||
bitNeighbor n;
|
bitNeighbor n;
|
||||||
sol.fitness(1);
|
sol.fitness(1);
|
||||||
|
|
||||||
test.init(sol);
|
test.init(sol);
|
||||||
evalCount(sol,n);
|
evalCount(sol,n);
|
||||||
assert(test.value()==1);
|
assert(test.value()==1);
|
||||||
evalCount(sol,n);
|
evalCount(sol,n);
|
||||||
assert(test.value()==2);
|
assert(test.value()==2);
|
||||||
assert(test(sol));
|
assert(test(sol));
|
||||||
evalCount(sol,n);
|
evalCount(sol,n);
|
||||||
assert(test.value()==3);
|
assert(test.value()==3);
|
||||||
assert(!test(sol));
|
assert(!test(sol));
|
||||||
test.init(sol);
|
test.init(sol);
|
||||||
assert(test.value()==0);
|
assert(test.value()==0);
|
||||||
assert(test(sol));
|
assert(test(sol));
|
||||||
|
|
||||||
std::cout << "[t-moNeighborEvalContinuator] => OK" << std::endl;
|
std::cout << "[t-moNeighborEvalContinuator] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,33 +34,33 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <continuator/moNeighborFitnessStat.h>
|
#include <continuator/moNeighborFitnessStat.h>
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moNeighborFitnessStat] => START" << std::endl;
|
std::cout << "[t-moNeighborFitnessStat] => START" << std::endl;
|
||||||
|
|
||||||
bitNeighborhood nh(4);
|
bitNeighborhood nh(4);
|
||||||
bitNeighborhood nh2(0);
|
bitNeighborhood nh2(0);
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
|
|
||||||
moNeighborFitnessStat<bitNeighbor> test(nh, eval);
|
moNeighborFitnessStat<bitNeighbor> test(nh, eval);
|
||||||
moNeighborFitnessStat<bitNeighbor> test2(nh2, eval);
|
moNeighborFitnessStat<bitNeighbor> test2(nh2, eval);
|
||||||
|
|
||||||
bitVector sol(4, true);
|
bitVector sol(4, true);
|
||||||
sol.fitness(4);
|
sol.fitness(4);
|
||||||
test.init(sol);
|
test.init(sol);
|
||||||
assert(test.value()==3);
|
assert(test.value()==3);
|
||||||
test(sol);
|
test(sol);
|
||||||
assert(test.value()==3);
|
assert(test.value()==3);
|
||||||
|
|
||||||
test2.init(sol);
|
test2.init(sol);
|
||||||
sol.fitness(3);
|
sol.fitness(3);
|
||||||
test2(sol);
|
test2(sol);
|
||||||
assert(test2.value()==int());
|
assert(test2.value()==int());
|
||||||
|
|
||||||
assert(test.className()=="moNeighborFitnessStat");
|
assert(test.className()=="moNeighborFitnessStat");
|
||||||
|
|
||||||
std::cout << "[t-moNeighborFitnessStat] => OK" << std::endl;
|
std::cout << "[t-moNeighborFitnessStat] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,11 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moNeighborVectorTabuList] => START" << std::endl;
|
std::cout << "[t-moNeighborVectorTabuList] => START" << std::endl;
|
||||||
|
|
||||||
//tabu list of size 2 (neighbor are always tabu)
|
//tabu list of size 2 (neighbor are always tabu)
|
||||||
moNeighborVectorTabuList<bitNeighbor> test(2,0);
|
moNeighborVectorTabuList<bitNeighbor> test(2,0);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@ int main(){
|
||||||
assert(!test.check(sol, n3));
|
assert(!test.check(sol, n3));
|
||||||
assert(!test.check(sol, n4));
|
assert(!test.check(sol, n4));
|
||||||
|
|
||||||
//tabu list of size 2 (neighbor are tabu during 2 iterations)
|
//tabu list of size 2 (neighbor are tabu during 2 iterations)
|
||||||
moNeighborVectorTabuList<bitNeighbor> test2(2,2);
|
moNeighborVectorTabuList<bitNeighbor> test2(2,2);
|
||||||
|
|
||||||
test2.add(sol, n1);
|
test2.add(sol, n1);
|
||||||
|
|
@ -97,8 +97,8 @@ int main(){
|
||||||
assert(!test2.check(sol, n1));
|
assert(!test2.check(sol, n1));
|
||||||
assert(!test2.check(sol, n2));
|
assert(!test2.check(sol, n2));
|
||||||
|
|
||||||
std::cout << "[t-moNeighborVectorTabuList] => OK" << std::endl;
|
std::cout << "[t-moNeighborVectorTabuList] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,53 +39,53 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
|
|
||||||
typedef moOrderNeighborhood<bitNeighbor> Neighborhood;
|
typedef moOrderNeighborhood<bitNeighbor> Neighborhood;
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moNeighborhoodPerturb] => START" << std::endl;
|
std::cout << "[t-moNeighborhoodPerturb] => START" << std::endl;
|
||||||
|
|
||||||
oneMaxEval<bitVector> eval;
|
oneMaxEval<bitVector> eval;
|
||||||
|
|
||||||
moFullEvalByCopy<bitNeighbor> moeval(eval);
|
moFullEvalByCopy<bitNeighbor> moeval(eval);
|
||||||
|
|
||||||
bitVector sol;
|
bitVector sol;
|
||||||
sol.resize(3);
|
sol.resize(3);
|
||||||
sol[0]=0;
|
sol[0]=0;
|
||||||
sol[1]=0;
|
sol[1]=0;
|
||||||
sol[2]=0;
|
sol[2]=0;
|
||||||
|
|
||||||
sol.fitness(0);
|
sol.fitness(0);
|
||||||
|
|
||||||
Neighborhood nh(3);
|
Neighborhood nh(3);
|
||||||
|
|
||||||
bitNeighbor n;
|
bitNeighbor n;
|
||||||
|
|
||||||
moNeighborhoodPerturb<bitNeighbor, bitNeighbor> test(nh, moeval);
|
moNeighborhoodPerturb<bitNeighbor, bitNeighbor> test(nh, moeval);
|
||||||
|
|
||||||
//test update
|
//test update
|
||||||
test.init(sol);
|
test.init(sol);
|
||||||
test(sol);
|
test(sol);
|
||||||
assert(sol[0]==1 && sol[1]==0 && sol[2]==0);
|
assert(sol[0]==1 && sol[1]==0 && sol[2]==0);
|
||||||
test.update(sol, n);
|
test.update(sol, n);
|
||||||
test(sol);
|
test(sol);
|
||||||
assert(sol[0]==1 && sol[1]==1 && sol[2]==0);
|
assert(sol[0]==1 && sol[1]==1 && sol[2]==0);
|
||||||
test.update(sol, n);
|
test.update(sol, n);
|
||||||
test(sol);
|
test(sol);
|
||||||
assert(sol[0]==1 && sol[1]==1 && sol[2]==1);
|
assert(sol[0]==1 && sol[1]==1 && sol[2]==1);
|
||||||
test.update(sol, n);
|
test.update(sol, n);
|
||||||
test(sol);
|
test(sol);
|
||||||
assert(sol[0]==0 && sol[1]==1 && sol[2]==1);
|
assert(sol[0]==0 && sol[1]==1 && sol[2]==1);
|
||||||
|
|
||||||
//test add
|
//test add
|
||||||
|
|
||||||
test.add(sol, n);
|
test.add(sol, n);
|
||||||
test(sol);
|
test(sol);
|
||||||
assert(sol[0]==1 && sol[1]==1 && sol[2]==1);
|
assert(sol[0]==1 && sol[1]==1 && sol[2]==1);
|
||||||
|
|
||||||
test.clearMemory();
|
test.clearMemory();
|
||||||
|
|
||||||
|
|
||||||
std::cout << "[t-moNeighborhoodPerturb] => OK" << std::endl;
|
std::cout << "[t-moNeighborhoodPerturb] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,27 +38,27 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <comparator/moNeighborComparator.h>
|
#include <comparator/moNeighborComparator.h>
|
||||||
|
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moNeutralDegreeSampling] => START" << std::endl;
|
std::cout << "[t-moNeutralDegreeSampling] => START" << std::endl;
|
||||||
|
|
||||||
bitNeighborhood nh(4);
|
bitNeighborhood nh(4);
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
dummyInit2 init(4);
|
dummyInit2 init(4);
|
||||||
|
|
||||||
moSolNeighborComparator<bitNeighbor> sncomp;
|
moSolNeighborComparator<bitNeighbor> sncomp;
|
||||||
moNeighborComparator<bitNeighbor> ncomp;
|
moNeighborComparator<bitNeighbor> ncomp;
|
||||||
|
|
||||||
moNeutralDegreeSampling<bitNeighbor> test1(init, nh, fullEval, eval, 3);
|
moNeutralDegreeSampling<bitNeighbor> test1(init, nh, fullEval, eval, 3);
|
||||||
moNeutralDegreeSampling<bitNeighbor> test2(init, nh, fullEval, eval, ncomp, sncomp, 3);
|
moNeutralDegreeSampling<bitNeighbor> test2(init, nh, fullEval, eval, ncomp, sncomp, 3);
|
||||||
|
|
||||||
test1();
|
test1();
|
||||||
|
|
||||||
test1.fileExport("outputNeutralDegreeSampling");
|
test1.fileExport("outputNeutralDegreeSampling");
|
||||||
|
|
||||||
std::cout << "[t-moNeutralDegreeSampling] => OK" << std::endl;
|
std::cout << "[t-moNeutralDegreeSampling] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,28 +38,28 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <comparator/moSolNeighborComparator.h>
|
#include <comparator/moSolNeighborComparator.h>
|
||||||
#include <comparator/moNeighborComparator.h>
|
#include <comparator/moNeighborComparator.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moNeutralHC] => START" << std::endl;
|
std::cout << "[t-moNeutralHC] => START" << std::endl;
|
||||||
|
|
||||||
bitNeighborhood nh(4);
|
bitNeighborhood nh(4);
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
moTrueContinuator<bitNeighbor> cont;
|
moTrueContinuator<bitNeighbor> cont;
|
||||||
moSolNeighborComparator<bitNeighbor> sncomp;
|
moSolNeighborComparator<bitNeighbor> sncomp;
|
||||||
moNeighborComparator<bitNeighbor> ncomp;
|
moNeighborComparator<bitNeighbor> ncomp;
|
||||||
|
|
||||||
//test du 1er constructeur
|
//test du 1er constructeur
|
||||||
moNeutralHC<bitNeighbor> test1(nh, fullEval, eval, 3);
|
moNeutralHC<bitNeighbor> test1(nh, fullEval, eval, 3);
|
||||||
|
|
||||||
//test du 2eme constructeur
|
//test du 2eme constructeur
|
||||||
moNeutralHC<bitNeighbor> test2(nh, fullEval, eval, 3, cont);
|
moNeutralHC<bitNeighbor> test2(nh, fullEval, eval, 3, cont);
|
||||||
|
|
||||||
//test du 3eme constructeur
|
//test du 3eme constructeur
|
||||||
moNeutralHC<bitNeighbor> test3(nh, fullEval, eval, 3, cont, ncomp, sncomp);
|
moNeutralHC<bitNeighbor> test3(nh, fullEval, eval, 3, cont, ncomp, sncomp);
|
||||||
|
|
||||||
std::cout << "[t-moNeutralHC] => OK" << std::endl;
|
std::cout << "[t-moNeutralHC] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,26 +37,26 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <utils/eoDistance.h>
|
#include <utils/eoDistance.h>
|
||||||
#include <eval/oneMaxEval.h>
|
#include <eval/oneMaxEval.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moNeutralWalkSampling] => START" << std::endl;
|
std::cout << "[t-moNeutralWalkSampling] => START" << std::endl;
|
||||||
|
|
||||||
bitNeighborhood nh(4);
|
bitNeighborhood nh(4);
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
dummyInit2 init(4);
|
dummyInit2 init(4);
|
||||||
bitVector sol(4, true);
|
bitVector sol(4, true);
|
||||||
sol.fitness(4);
|
sol.fitness(4);
|
||||||
eoHammingDistance<bitVector> dist;
|
eoHammingDistance<bitVector> dist;
|
||||||
|
|
||||||
moNeutralWalkSampling<bitNeighbor> test(sol, nh, fullEval, eval, dist, 3);
|
moNeutralWalkSampling<bitNeighbor> test(sol, nh, fullEval, eval, dist, 3);
|
||||||
|
|
||||||
test();
|
test();
|
||||||
|
|
||||||
test.fileExport("outputTestNeutralWalkSampling");
|
test.fileExport("outputTestNeutralWalkSampling");
|
||||||
|
|
||||||
std::cout << "[t-moNeutralWalkSampling] => OK" << std::endl;
|
std::cout << "[t-moNeutralWalkSampling] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,28 +37,28 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <continuator/moTrueContinuator.h>
|
#include <continuator/moTrueContinuator.h>
|
||||||
#include <comparator/moSolNeighborComparator.h>
|
#include <comparator/moSolNeighborComparator.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moRandomBestHC] => START" << std::endl;
|
std::cout << "[t-moRandomBestHC] => START" << std::endl;
|
||||||
|
|
||||||
bitNeighborhood nh(4);
|
bitNeighborhood nh(4);
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
|
|
||||||
//test first constructor
|
//test first constructor
|
||||||
moRandomBestHC<bitNeighbor> test1(nh, fullEval, eval);
|
moRandomBestHC<bitNeighbor> test1(nh, fullEval, eval);
|
||||||
|
|
||||||
//test second constructor
|
//test second constructor
|
||||||
moTrueContinuator<bitNeighbor> cont;
|
moTrueContinuator<bitNeighbor> cont;
|
||||||
moRandomBestHC<bitNeighbor> test2(nh, fullEval, eval, cont);
|
moRandomBestHC<bitNeighbor> test2(nh, fullEval, eval, cont);
|
||||||
|
|
||||||
//test third constructor
|
//test third constructor
|
||||||
moSolNeighborComparator<bitNeighbor> sncomp;
|
moSolNeighborComparator<bitNeighbor> sncomp;
|
||||||
moNeighborComparator<bitNeighbor> ncomp;
|
moNeighborComparator<bitNeighbor> ncomp;
|
||||||
moRandomBestHC<bitNeighbor> test3(nh, fullEval, eval, cont, ncomp, sncomp);
|
moRandomBestHC<bitNeighbor> test3(nh, fullEval, eval, cont, ncomp, sncomp);
|
||||||
|
|
||||||
std::cout << "[t-moRandomBestHC] => OK" << std::endl;
|
std::cout << "[t-moRandomBestHC] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,27 +37,27 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <continuator/moTrueContinuator.h>
|
#include <continuator/moTrueContinuator.h>
|
||||||
#include <comparator/moSolNeighborComparator.h>
|
#include <comparator/moSolNeighborComparator.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moRandomNeutralWalk] => START" << std::endl;
|
std::cout << "[t-moRandomNeutralWalk] => START" << std::endl;
|
||||||
|
|
||||||
bitNeighborhood nh(4);
|
bitNeighborhood nh(4);
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
moTrueContinuator<bitNeighbor> cont;
|
moTrueContinuator<bitNeighbor> cont;
|
||||||
moSolNeighborComparator<bitNeighbor> sncomp;
|
moSolNeighborComparator<bitNeighbor> sncomp;
|
||||||
|
|
||||||
//test du 1er constructeur
|
//test du 1er constructeur
|
||||||
moRandomNeutralWalk<bitNeighbor> test1(nh, fullEval, eval, 3);
|
moRandomNeutralWalk<bitNeighbor> test1(nh, fullEval, eval, 3);
|
||||||
|
|
||||||
//test du 2eme constructeur
|
//test du 2eme constructeur
|
||||||
moRandomNeutralWalk<bitNeighbor> test2(nh, fullEval, eval, 3, cont);
|
moRandomNeutralWalk<bitNeighbor> test2(nh, fullEval, eval, 3, cont);
|
||||||
|
|
||||||
//test du 3eme constructeur
|
//test du 3eme constructeur
|
||||||
moRandomNeutralWalk<bitNeighbor> test3(nh, fullEval, eval, 3, cont, sncomp);
|
moRandomNeutralWalk<bitNeighbor> test3(nh, fullEval, eval, 3, cont, sncomp);
|
||||||
|
|
||||||
std::cout << "[t-moRandomNeutralWalk] => OK" << std::endl;
|
std::cout << "[t-moRandomNeutralWalk] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,22 +36,22 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <eval/oneMaxEval.h>
|
#include <eval/oneMaxEval.h>
|
||||||
#include <continuator/moTrueContinuator.h>
|
#include <continuator/moTrueContinuator.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moRandomSearch] => START" << std::endl;
|
std::cout << "[t-moRandomSearch] => START" << std::endl;
|
||||||
|
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
dummyInit init;
|
dummyInit init;
|
||||||
moTrueContinuator<bitNeighbor> cont;
|
moTrueContinuator<bitNeighbor> cont;
|
||||||
//test du 1er constructor
|
//test du 1er constructor
|
||||||
moRandomSearch<bitNeighbor> test1(init, fullEval, 3);
|
moRandomSearch<bitNeighbor> test1(init, fullEval, 3);
|
||||||
//test du 2e constructor
|
//test du 2e constructor
|
||||||
moRandomSearch<bitNeighbor> test2(init, fullEval, 3, cont);
|
moRandomSearch<bitNeighbor> test2(init, fullEval, 3, cont);
|
||||||
|
|
||||||
assert(test1.className()=="moRandomSearch");
|
assert(test1.className()=="moRandomSearch");
|
||||||
|
|
||||||
std::cout << "[t-moRandomSearch] => OK" << std::endl;
|
std::cout << "[t-moRandomSearch] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,31 +35,31 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
#include <eval/oneMaxEval.h>
|
#include <eval/oneMaxEval.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moRandomSearchExplorer] => START" << std::endl;
|
std::cout << "[t-moRandomSearchExplorer] => START" << std::endl;
|
||||||
|
|
||||||
dummyInit init;
|
dummyInit init;
|
||||||
oneMaxEval<bitVector> eval;
|
oneMaxEval<bitVector> eval;
|
||||||
bitVector sol(4, true);
|
bitVector sol(4, true);
|
||||||
|
|
||||||
moRandomSearchExplorer<bitNeighbor> test(init, eval, 2);
|
moRandomSearchExplorer<bitNeighbor> test(init, eval, 2);
|
||||||
|
|
||||||
test.initParam(sol);
|
test.initParam(sol);
|
||||||
test(sol);
|
test(sol);
|
||||||
assert(sol.fitness()==4);
|
assert(sol.fitness()==4);
|
||||||
test.updateParam(sol);
|
test.updateParam(sol);
|
||||||
assert(test.isContinue(sol));
|
assert(test.isContinue(sol));
|
||||||
test.updateParam(sol);
|
test.updateParam(sol);
|
||||||
assert(!test.isContinue(sol));
|
assert(!test.isContinue(sol));
|
||||||
test.initParam(sol);
|
test.initParam(sol);
|
||||||
assert(test.isContinue(sol));
|
assert(test.isContinue(sol));
|
||||||
test.terminate(sol);
|
test.terminate(sol);
|
||||||
assert(test.accept(sol));
|
assert(test.accept(sol));
|
||||||
test.move(sol);
|
test.move(sol);
|
||||||
|
|
||||||
std::cout << "[t-moRandomSearchExplorer] => OK" << std::endl;
|
std::cout << "[t-moRandomSearchExplorer] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,26 +38,26 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <comparator/moSolNeighborComparator.h>
|
#include <comparator/moSolNeighborComparator.h>
|
||||||
#include <comparator/moNeighborComparator.h>
|
#include <comparator/moNeighborComparator.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moRandomWalk] => START" << std::endl;
|
std::cout << "[t-moRandomWalk] => START" << std::endl;
|
||||||
|
|
||||||
bitNeighborhood nh(4);
|
bitNeighborhood nh(4);
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
moTrueContinuator<bitNeighbor> cont;
|
moTrueContinuator<bitNeighbor> cont;
|
||||||
moSolNeighborComparator<bitNeighbor> sncomp;
|
moSolNeighborComparator<bitNeighbor> sncomp;
|
||||||
moNeighborComparator<bitNeighbor> ncomp;
|
moNeighborComparator<bitNeighbor> ncomp;
|
||||||
|
|
||||||
//test du 1er constructeur
|
//test du 1er constructeur
|
||||||
moRandomWalk<bitNeighbor> test1(nh, fullEval, eval, 3);
|
moRandomWalk<bitNeighbor> test1(nh, fullEval, eval, 3);
|
||||||
|
|
||||||
//test du 2eme constructeur
|
//test du 2eme constructeur
|
||||||
moRandomWalk<bitNeighbor> test2(nh, fullEval, eval, 3, cont);
|
moRandomWalk<bitNeighbor> test2(nh, fullEval, eval, 3, cont);
|
||||||
|
|
||||||
|
|
||||||
std::cout << "[t-moRandomWalk] => OK" << std::endl;
|
std::cout << "[t-moRandomWalk] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,75 +43,75 @@ typedef eoInt<unsigned int> QUEEN;
|
||||||
class dummyInit : public eoInit<QUEEN>
|
class dummyInit : public eoInit<QUEEN>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
dummyInit(unsigned int _size):size(_size){}
|
dummyInit(unsigned int _size):size(_size) {}
|
||||||
|
|
||||||
void operator()(QUEEN& _sol){
|
void operator()(QUEEN& _sol) {
|
||||||
_sol.resize(0);
|
_sol.resize(0);
|
||||||
for(unsigned int i=0; i<size; i++)
|
for (unsigned int i=0; i<size; i++)
|
||||||
_sol.push_back(i);
|
_sol.push_back(i);
|
||||||
_sol.invalidate();
|
_sol.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moRestartPerturb] => START" << std::endl;
|
std::cout << "[t-moRestartPerturb] => START" << std::endl;
|
||||||
|
|
||||||
QUEEN queen;
|
QUEEN queen;
|
||||||
moShiftNeighbor<QUEEN> n;
|
moShiftNeighbor<QUEEN> n;
|
||||||
|
|
||||||
dummyInit initializer(4);
|
dummyInit initializer(4);
|
||||||
|
|
||||||
queenEval<QUEEN> eval;
|
queenEval<QUEEN> eval;
|
||||||
|
|
||||||
moRestartPerturb<moShiftNeighbor<QUEEN> > test(initializer, eval, 3);
|
moRestartPerturb<moShiftNeighbor<QUEEN> > test(initializer, eval, 3);
|
||||||
|
|
||||||
queen.resize(4);
|
queen.resize(4);
|
||||||
queen[0]=1;
|
queen[0]=1;
|
||||||
queen[1]=2;
|
queen[1]=2;
|
||||||
queen[2]=0;
|
queen[2]=0;
|
||||||
queen[3]=3;
|
queen[3]=3;
|
||||||
|
|
||||||
test.init(queen);
|
test.init(queen);
|
||||||
|
|
||||||
test(queen);
|
test(queen);
|
||||||
assert(queen[0]==1 && queen[1]==2 && queen[2]==0 && queen[3]==3);
|
assert(queen[0]==1 && queen[1]==2 && queen[2]==0 && queen[3]==3);
|
||||||
test.update(queen,n); //first noMove
|
test.update(queen,n); //first noMove
|
||||||
test(queen);
|
test(queen);
|
||||||
assert(queen[0]==1 && queen[1]==2 && queen[2]==0 && queen[3]==3);
|
assert(queen[0]==1 && queen[1]==2 && queen[2]==0 && queen[3]==3);
|
||||||
test.update(queen,n); //second noMove
|
test.update(queen,n); //second noMove
|
||||||
test(queen);
|
test(queen);
|
||||||
assert(queen[0]==1 && queen[1]==2 && queen[2]==0 && queen[3]==3);
|
assert(queen[0]==1 && queen[1]==2 && queen[2]==0 && queen[3]==3);
|
||||||
test.update(queen,n); //third noMove
|
test.update(queen,n); //third noMove
|
||||||
test(queen);//here the perturb should be called
|
test(queen);//here the perturb should be called
|
||||||
assert(queen[0]==0 && queen[1]==1 && queen[2]==2 && queen[3]==3);
|
assert(queen[0]==0 && queen[1]==1 && queen[2]==2 && queen[3]==3);
|
||||||
|
|
||||||
queen[0]=1;
|
queen[0]=1;
|
||||||
queen[1]=2;
|
queen[1]=2;
|
||||||
queen[2]=0;
|
queen[2]=0;
|
||||||
queen[3]=3;
|
queen[3]=3;
|
||||||
|
|
||||||
//Retry the same test to verify counter is been reinit to 0
|
//Retry the same test to verify counter is been reinit to 0
|
||||||
|
|
||||||
test(queen);
|
test(queen);
|
||||||
assert(queen[0]==1 && queen[1]==2 && queen[2]==0 && queen[3]==3);
|
assert(queen[0]==1 && queen[1]==2 && queen[2]==0 && queen[3]==3);
|
||||||
test.update(queen,n); //first noMove
|
test.update(queen,n); //first noMove
|
||||||
test(queen);
|
test(queen);
|
||||||
assert(queen[0]==1 && queen[1]==2 && queen[2]==0 && queen[3]==3);
|
assert(queen[0]==1 && queen[1]==2 && queen[2]==0 && queen[3]==3);
|
||||||
test.update(queen,n); //second noMove
|
test.update(queen,n); //second noMove
|
||||||
test(queen);
|
test(queen);
|
||||||
assert(queen[0]==1 && queen[1]==2 && queen[2]==0 && queen[3]==3);
|
assert(queen[0]==1 && queen[1]==2 && queen[2]==0 && queen[3]==3);
|
||||||
test.update(queen,n); //third noMove
|
test.update(queen,n); //third noMove
|
||||||
test(queen); //here the perturb should be called
|
test(queen); //here the perturb should be called
|
||||||
assert(queen[0]==0 && queen[1]==1 && queen[2]==2 && queen[3]==3);
|
assert(queen[0]==0 && queen[1]==1 && queen[2]==2 && queen[3]==3);
|
||||||
|
|
||||||
std::cout << "[t-moRestartPerturb] => OK" << std::endl;
|
std::cout << "[t-moRestartPerturb] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,28 +38,28 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <continuator/moTrueContinuator.h>
|
#include <continuator/moTrueContinuator.h>
|
||||||
#include <comparator/moSolNeighborComparator.h>
|
#include <comparator/moSolNeighborComparator.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moSA] => START" << std::endl;
|
std::cout << "[t-moSA] => START" << std::endl;
|
||||||
|
|
||||||
bitNeighborhood nh(4);
|
bitNeighborhood nh(4);
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
|
|
||||||
//test first constructor
|
//test first constructor
|
||||||
moSA<bitNeighbor> test1(nh, fullEval, eval);
|
moSA<bitNeighbor> test1(nh, fullEval, eval);
|
||||||
|
|
||||||
//test second constructor
|
//test second constructor
|
||||||
moSimpleCoolingSchedule<bitVector> cool(10, 0.9, 100, 0.01);
|
moSimpleCoolingSchedule<bitVector> cool(10, 0.9, 100, 0.01);
|
||||||
moSA<bitNeighbor> test2(nh, fullEval, eval, cool);
|
moSA<bitNeighbor> test2(nh, fullEval, eval, cool);
|
||||||
|
|
||||||
//test third constructor
|
//test third constructor
|
||||||
moTrueContinuator<bitNeighbor> cont;
|
moTrueContinuator<bitNeighbor> cont;
|
||||||
moSolNeighborComparator<bitNeighbor> comp;
|
moSolNeighborComparator<bitNeighbor> comp;
|
||||||
moSA<bitNeighbor> test3(nh, fullEval, eval, cool, comp, cont);
|
moSA<bitNeighbor> test3(nh, fullEval, eval, cool, comp, cont);
|
||||||
|
|
||||||
std::cout << "[t-moSA] => OK" << std::endl;
|
std::cout << "[t-moSA] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,9 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <explorer/moSAexplorer.h>
|
#include <explorer/moSAexplorer.h>
|
||||||
#include <coolingSchedule/moSimpleCoolingSchedule.h>
|
#include <coolingSchedule/moSimpleCoolingSchedule.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moSAexplorer] => START" << std::endl;
|
std::cout << "[t-moSAexplorer] => START" << std::endl;
|
||||||
|
|
||||||
eoBit<eoMinimizingFitness> sol(4, true);
|
eoBit<eoMinimizingFitness> sol(4, true);
|
||||||
sol.fitness(4);
|
sol.fitness(4);
|
||||||
|
|
@ -66,22 +66,22 @@ int main(){
|
||||||
assert(sol.fitness()==3);
|
assert(sol.fitness()==3);
|
||||||
unsigned int ok=0;
|
unsigned int ok=0;
|
||||||
unsigned int ko=0;
|
unsigned int ko=0;
|
||||||
for(unsigned int i=0; i<1000; i++){
|
for (unsigned int i=0; i<1000; i++) {
|
||||||
test2(sol);
|
test2(sol);
|
||||||
if(test2.isContinue(sol))
|
if (test2.isContinue(sol))
|
||||||
test2.updateParam(sol);
|
test2.updateParam(sol);
|
||||||
if(test2.accept(sol))
|
if (test2.accept(sol))
|
||||||
ok++;
|
ok++;
|
||||||
else
|
else
|
||||||
ko++;
|
ko++;
|
||||||
test2.move(sol);
|
test2.move(sol);
|
||||||
}
|
}
|
||||||
assert((ok>0) && (ko>0));
|
assert((ok>0) && (ko>0));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::cout << "[t-moSAexplorer] => OK" << std::endl;
|
std::cout << "[t-moSAexplorer] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,43 +39,43 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <continuator/moCounterStat.h>
|
#include <continuator/moCounterStat.h>
|
||||||
#include <continuator/moIterContinuator.h>
|
#include <continuator/moIterContinuator.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moSampling] => START" << std::endl;
|
std::cout << "[t-moSampling] => START" << std::endl;
|
||||||
|
|
||||||
bitNeighborhood nh(4);
|
bitNeighborhood nh(4);
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
dummyInit2 init(4);
|
dummyInit2 init(4);
|
||||||
moIterContinuator<bitNeighbor> cont(3);
|
moIterContinuator<bitNeighbor> cont(3);
|
||||||
|
|
||||||
moFirstImprHC<bitNeighbor> hc(nh, fullEval, eval, cont);
|
moFirstImprHC<bitNeighbor> hc(nh, fullEval, eval, cont);
|
||||||
moSolutionStat<bitVector> stat1;
|
moSolutionStat<bitVector> stat1;
|
||||||
moCounterStat<bitVector> stat2;
|
moCounterStat<bitVector> stat2;
|
||||||
moSampling<bitNeighbor> test(init, hc, stat1);
|
moSampling<bitNeighbor> test(init, hc, stat1);
|
||||||
|
|
||||||
test.add(stat2);
|
test.add(stat2);
|
||||||
|
|
||||||
test();
|
test();
|
||||||
|
|
||||||
std::vector<double> res;
|
std::vector<double> res;
|
||||||
std::vector<bitVector> res2;
|
std::vector<bitVector> res2;
|
||||||
res = test.getValues(1);
|
res = test.getValues(1);
|
||||||
res2= test.getSolutions(0);
|
res2= test.getSolutions(0);
|
||||||
|
|
||||||
for(unsigned int i=0; i<res2.size(); i++)
|
for (unsigned int i=0; i<res2.size(); i++)
|
||||||
assert(res2[i].fitness()==4-i);
|
assert(res2[i].fitness()==4-i);
|
||||||
|
|
||||||
for(unsigned int i=0; i<res.size(); i++)
|
for (unsigned int i=0; i<res.size(); i++)
|
||||||
assert(res[i]==i);
|
assert(res[i]==i);
|
||||||
|
|
||||||
test.fileExport("outputTestSampling1");
|
test.fileExport("outputTestSampling1");
|
||||||
test.fileExport(1, "outputTestSampling2");
|
test.fileExport(1, "outputTestSampling2");
|
||||||
|
|
||||||
assert(test.className()=="moSampling");
|
assert(test.className()=="moSampling");
|
||||||
|
|
||||||
std::cout << "[t-moSampling] => OK" << std::endl;
|
std::cout << "[t-moSampling] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,55 +34,55 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <coolingSchedule/moSimpleCoolingSchedule.h>
|
#include <coolingSchedule/moSimpleCoolingSchedule.h>
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moSimpleCoolingSchedule] => START" << std::endl;
|
std::cout << "[t-moSimpleCoolingSchedule] => START" << std::endl;
|
||||||
|
|
||||||
double temperature;
|
double temperature;
|
||||||
|
|
||||||
bitVector sol;
|
bitVector sol;
|
||||||
|
|
||||||
moSimpleCoolingSchedule<bitVector> test(100, 0.1, 2, 0.1);
|
moSimpleCoolingSchedule<bitVector> test(100, 0.1, 2, 0.1);
|
||||||
|
|
||||||
temperature=test.init(sol);
|
temperature=test.init(sol);
|
||||||
assert(temperature==100);
|
assert(temperature==100);
|
||||||
|
|
||||||
//temperature must not changed 2*
|
//temperature must not changed 2*
|
||||||
test.update(temperature);
|
test.update(temperature);
|
||||||
assert(temperature==100);
|
assert(temperature==100);
|
||||||
assert(test(temperature));
|
assert(test(temperature));
|
||||||
test.update(temperature);
|
test.update(temperature);
|
||||||
assert(temperature==100);
|
assert(temperature==100);
|
||||||
assert(test(temperature));
|
assert(test(temperature));
|
||||||
|
|
||||||
//then temperature must be /10
|
//then temperature must be /10
|
||||||
test.update(temperature);
|
test.update(temperature);
|
||||||
assert(temperature==10);
|
assert(temperature==10);
|
||||||
assert(test(temperature));
|
assert(test(temperature));
|
||||||
test.update(temperature);
|
test.update(temperature);
|
||||||
assert(temperature==10);
|
assert(temperature==10);
|
||||||
assert(test(temperature));
|
assert(test(temperature));
|
||||||
test.update(temperature);
|
test.update(temperature);
|
||||||
assert(temperature==10);
|
assert(temperature==10);
|
||||||
assert(test(temperature));
|
assert(test(temperature));
|
||||||
|
|
||||||
test.update(temperature);
|
test.update(temperature);
|
||||||
assert(temperature==1);
|
assert(temperature==1);
|
||||||
assert(test(temperature));
|
assert(test(temperature));
|
||||||
test.update(temperature);
|
test.update(temperature);
|
||||||
assert(temperature==1);
|
assert(temperature==1);
|
||||||
assert(test(temperature));
|
assert(test(temperature));
|
||||||
test.update(temperature);
|
test.update(temperature);
|
||||||
assert(temperature==1);
|
assert(temperature==1);
|
||||||
assert(test(temperature));
|
assert(test(temperature));
|
||||||
|
|
||||||
test.update(temperature);
|
test.update(temperature);
|
||||||
assert(temperature==0.1);
|
assert(temperature==0.1);
|
||||||
assert(!test(temperature));
|
assert(!test(temperature));
|
||||||
|
|
||||||
|
|
||||||
std::cout << "[t-moSimpleCoolingSchedule] => OK" << std::endl;
|
std::cout << "[t-moSimpleCoolingSchedule] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,28 +38,28 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <comparator/moSolNeighborComparator.h>
|
#include <comparator/moSolNeighborComparator.h>
|
||||||
|
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moSimpleHC] => START" << std::endl;
|
std::cout << "[t-moSimpleHC] => START" << std::endl;
|
||||||
|
|
||||||
bitNeighborhood nh(4);
|
bitNeighborhood nh(4);
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
|
|
||||||
//test first constructor
|
//test first constructor
|
||||||
moSimpleHC<bitNeighbor> test1(nh, fullEval, eval);
|
moSimpleHC<bitNeighbor> test1(nh, fullEval, eval);
|
||||||
|
|
||||||
//test second constructor
|
//test second constructor
|
||||||
moTrueContinuator<bitNeighbor> cont;
|
moTrueContinuator<bitNeighbor> cont;
|
||||||
moSimpleHC<bitNeighbor> test2(nh, fullEval, eval, cont);
|
moSimpleHC<bitNeighbor> test2(nh, fullEval, eval, cont);
|
||||||
|
|
||||||
//test third constructor
|
//test third constructor
|
||||||
moSolNeighborComparator<bitNeighbor> sncomp;
|
moSolNeighborComparator<bitNeighbor> sncomp;
|
||||||
moNeighborComparator<bitNeighbor> ncomp;
|
moNeighborComparator<bitNeighbor> ncomp;
|
||||||
moSimpleHC<bitNeighbor> test3(nh, fullEval, eval, cont, ncomp, sncomp);
|
moSimpleHC<bitNeighbor> test3(nh, fullEval, eval, cont, ncomp, sncomp);
|
||||||
|
|
||||||
std::cout << "[t-moSimpleHC] => OK" << std::endl;
|
std::cout << "[t-moSimpleHC] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,9 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <comparator/moSolComparator.h>
|
#include <comparator/moSolComparator.h>
|
||||||
#include <ga/eoBit.h>
|
#include <ga/eoBit.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moSolComparator] => START" << std::endl;
|
std::cout << "[t-moSolComparator] => START" << std::endl;
|
||||||
|
|
||||||
eoBit<eoMinimizingFitness> sol1, sol2, sol3;
|
eoBit<eoMinimizingFitness> sol1, sol2, sol3;
|
||||||
|
|
||||||
|
|
@ -54,8 +54,8 @@ int main(){
|
||||||
|
|
||||||
assert(test.className()=="moSolComparator");
|
assert(test.className()=="moSolComparator");
|
||||||
|
|
||||||
std::cout << "[t-moSolComparator] => OK" << std::endl;
|
std::cout << "[t-moSolComparator] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,24 +33,24 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
|
|
||||||
#include <perturb/moSolInit.h>
|
#include <perturb/moSolInit.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moSolInit] => START" << std::endl;
|
std::cout << "[t-moSolInit] => START" << std::endl;
|
||||||
|
|
||||||
int a=3;
|
int a=3;
|
||||||
|
|
||||||
int b=5;
|
int b=5;
|
||||||
|
|
||||||
moSolInit<int> test(a);
|
moSolInit<int> test(a);
|
||||||
|
|
||||||
test(b);
|
test(b);
|
||||||
assert(b==3);
|
assert(b==3);
|
||||||
a=4;
|
a=4;
|
||||||
test(b);
|
test(b);
|
||||||
assert(b==4);
|
assert(b==4);
|
||||||
|
|
||||||
std::cout << "[t-moSolInit] => OK" << std::endl;
|
std::cout << "[t-moSolInit] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,77 +35,77 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
#include <utils/eoDistance.h>
|
#include <utils/eoDistance.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moStatistics] => START" << std::endl;
|
std::cout << "[t-moStatistics] => START" << std::endl;
|
||||||
|
|
||||||
moStatistics test;
|
moStatistics test;
|
||||||
|
|
||||||
double min;
|
double min;
|
||||||
double max;
|
double max;
|
||||||
double avg;
|
double avg;
|
||||||
double std;
|
double std;
|
||||||
|
|
||||||
//test des stats basic
|
//test des stats basic
|
||||||
std::vector<double> sampling;
|
std::vector<double> sampling;
|
||||||
sampling.push_back(3);
|
sampling.push_back(3);
|
||||||
sampling.push_back(5);
|
sampling.push_back(5);
|
||||||
sampling.push_back(2);
|
sampling.push_back(2);
|
||||||
sampling.push_back(4);
|
sampling.push_back(4);
|
||||||
|
|
||||||
|
|
||||||
test.basic(sampling, min, max, avg, std);
|
test.basic(sampling, min, max, avg, std);
|
||||||
assert(min==2);
|
assert(min==2);
|
||||||
assert(max==5);
|
assert(max==5);
|
||||||
assert(avg==3.5);
|
assert(avg==3.5);
|
||||||
assert(std==sqrt(1.25));
|
assert(std==sqrt(1.25));
|
||||||
|
|
||||||
sampling.resize(0);
|
sampling.resize(0);
|
||||||
test.basic(sampling, min, max, avg, std);
|
test.basic(sampling, min, max, avg, std);
|
||||||
assert(min==0);
|
assert(min==0);
|
||||||
assert(max==0);
|
assert(max==0);
|
||||||
assert(avg==0);
|
assert(avg==0);
|
||||||
assert(std==0);
|
assert(std==0);
|
||||||
|
|
||||||
//test de la distance
|
//test de la distance
|
||||||
std::vector<bitVector> data;
|
std::vector<bitVector> data;
|
||||||
eoHammingDistance<bitVector> dist;
|
eoHammingDistance<bitVector> dist;
|
||||||
bitVector tmp(4,true);
|
bitVector tmp(4,true);
|
||||||
data.push_back(tmp);
|
data.push_back(tmp);
|
||||||
tmp[0]=false;
|
tmp[0]=false;
|
||||||
data.push_back(tmp);
|
data.push_back(tmp);
|
||||||
tmp[2]=false;
|
tmp[2]=false;
|
||||||
data.push_back(tmp);
|
data.push_back(tmp);
|
||||||
|
|
||||||
std::vector< std::vector<double> > matrix;
|
std::vector< std::vector<double> > matrix;
|
||||||
|
|
||||||
test.distances(data, dist, matrix);
|
test.distances(data, dist, matrix);
|
||||||
|
|
||||||
assert(matrix[0][0]==0.0);
|
assert(matrix[0][0]==0.0);
|
||||||
assert(matrix[0][1]==1.0);
|
assert(matrix[0][1]==1.0);
|
||||||
assert(matrix[0][2]==2.0);
|
assert(matrix[0][2]==2.0);
|
||||||
|
|
||||||
assert(matrix[1][0]==1.0);
|
assert(matrix[1][0]==1.0);
|
||||||
assert(matrix[1][1]==0.0);
|
assert(matrix[1][1]==0.0);
|
||||||
assert(matrix[1][2]==1.0);
|
assert(matrix[1][2]==1.0);
|
||||||
|
|
||||||
assert(matrix[2][0]==2.0);
|
assert(matrix[2][0]==2.0);
|
||||||
assert(matrix[2][1]==1.0);
|
assert(matrix[2][1]==1.0);
|
||||||
assert(matrix[2][2]==0.0);
|
assert(matrix[2][2]==0.0);
|
||||||
|
|
||||||
//test de l'autocorrelation
|
//test de l'autocorrelation
|
||||||
std::vector<double> rho, phi;
|
std::vector<double> rho, phi;
|
||||||
test.autocorrelation(sampling, 2, rho, phi);
|
test.autocorrelation(sampling, 2, rho, phi);
|
||||||
|
|
||||||
sampling.push_back(3);
|
sampling.push_back(3);
|
||||||
sampling.push_back(5);
|
sampling.push_back(5);
|
||||||
sampling.push_back(2);
|
sampling.push_back(2);
|
||||||
sampling.push_back(4);
|
sampling.push_back(4);
|
||||||
|
|
||||||
test.autocorrelation(sampling, 2, rho, phi);
|
test.autocorrelation(sampling, 2, rho, phi);
|
||||||
|
|
||||||
std::cout << "[t-moStatistics] => OK" << std::endl;
|
std::cout << "[t-moStatistics] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,34 +39,34 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <comparator/moNeighborComparator.h>
|
#include <comparator/moNeighborComparator.h>
|
||||||
#include <memory/moSolVectorTabuList.h>
|
#include <memory/moSolVectorTabuList.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moTS] => START" << std::endl;
|
std::cout << "[t-moTS] => START" << std::endl;
|
||||||
|
|
||||||
bitNeighborhood nh(4);
|
bitNeighborhood nh(4);
|
||||||
oneMaxEval<bitVector> fullEval;
|
oneMaxEval<bitVector> fullEval;
|
||||||
evalOneMax eval(4);
|
evalOneMax eval(4);
|
||||||
|
|
||||||
//test first constructor
|
//test first constructor
|
||||||
moTS<bitNeighbor> test1(nh, fullEval, eval, 1, 7);
|
moTS<bitNeighbor> test1(nh, fullEval, eval, 1, 7);
|
||||||
|
|
||||||
//test second constructor
|
//test second constructor
|
||||||
moSolVectorTabuList<bitNeighbor> tl(7,0);
|
moSolVectorTabuList<bitNeighbor> tl(7,0);
|
||||||
moTS<bitNeighbor> test2(nh, fullEval, eval, 1, tl);
|
moTS<bitNeighbor> test2(nh, fullEval, eval, 1, tl);
|
||||||
|
|
||||||
//test third constructor
|
//test third constructor
|
||||||
moTrueContinuator<bitNeighbor> cont;
|
moTrueContinuator<bitNeighbor> cont;
|
||||||
moSolNeighborComparator<bitNeighbor> sncomp;
|
moSolNeighborComparator<bitNeighbor> sncomp;
|
||||||
moNeighborComparator<bitNeighbor> ncomp;
|
moNeighborComparator<bitNeighbor> ncomp;
|
||||||
moDummyIntensification<bitNeighbor> intens;
|
moDummyIntensification<bitNeighbor> intens;
|
||||||
moDummyDiversification<bitNeighbor> div;
|
moDummyDiversification<bitNeighbor> div;
|
||||||
moBestImprAspiration<bitNeighbor> aspir;
|
moBestImprAspiration<bitNeighbor> aspir;
|
||||||
|
|
||||||
moTS<bitNeighbor> test3(nh, fullEval, eval, ncomp, sncomp, cont, tl, intens, div, aspir);
|
moTS<bitNeighbor> test3(nh, fullEval, eval, ncomp, sncomp, cont, tl, intens, div, aspir);
|
||||||
|
|
||||||
|
|
||||||
std::cout << "[t-moTS] => OK" << std::endl;
|
std::cout << "[t-moTS] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,15 +37,15 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
|
|
||||||
void wait ( int seconds )
|
void wait ( int seconds )
|
||||||
{
|
{
|
||||||
clock_t endwait;
|
clock_t endwait;
|
||||||
endwait = clock () + seconds * CLOCKS_PER_SEC ;
|
endwait = clock () + seconds * CLOCKS_PER_SEC ;
|
||||||
while (clock() < endwait) {}
|
while (clock() < endwait) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moTimeContinuator] => START" << std::endl;
|
std::cout << "[t-moTimeContinuator] => START" << std::endl;
|
||||||
|
|
||||||
moTimeContinuator<moDummyNeighborTest> test(2, false);
|
moTimeContinuator<moDummyNeighborTest> test(2, false);
|
||||||
moTimeContinuator<moDummyNeighborTest> test2(3);
|
moTimeContinuator<moDummyNeighborTest> test2(3);
|
||||||
|
|
@ -64,8 +64,8 @@ int main(){
|
||||||
|
|
||||||
assert(test.className()=="moTimeContinuator");
|
assert(test.className()=="moTimeContinuator");
|
||||||
|
|
||||||
std::cout << "[t-moTimeContinuator] => OK" << std::endl;
|
std::cout << "[t-moTimeContinuator] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,79 +34,79 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <continuator/moVectorMonitor.h>
|
#include <continuator/moVectorMonitor.h>
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moVectorMonitor] => START" << std::endl;
|
std::cout << "[t-moVectorMonitor] => START" << std::endl;
|
||||||
|
|
||||||
|
|
||||||
eoValueParam<double> doubleParam;
|
eoValueParam<double> doubleParam;
|
||||||
eoValueParam<unsigned int> intParam;
|
eoValueParam<unsigned int> intParam;
|
||||||
eoValueParam<bitVector> eotParam;
|
eoValueParam<bitVector> eotParam;
|
||||||
eoValueParam<std::string> stringParam;
|
eoValueParam<std::string> stringParam;
|
||||||
doubleParam.value()= 3.1;
|
doubleParam.value()= 3.1;
|
||||||
intParam.value()=6;
|
intParam.value()=6;
|
||||||
bitVector sol(4,true);
|
bitVector sol(4,true);
|
||||||
sol.fitness(0);
|
sol.fitness(0);
|
||||||
eotParam.value()=sol;
|
eotParam.value()=sol;
|
||||||
|
|
||||||
moVectorMonitor<bitVector> test1(doubleParam);
|
moVectorMonitor<bitVector> test1(doubleParam);
|
||||||
moVectorMonitor<bitVector> test2(intParam);
|
moVectorMonitor<bitVector> test2(intParam);
|
||||||
moVectorMonitor<bitVector> test3(eotParam);
|
moVectorMonitor<bitVector> test3(eotParam);
|
||||||
moVectorMonitor<bitVector> test4(stringParam);
|
moVectorMonitor<bitVector> test4(stringParam);
|
||||||
|
|
||||||
assert(!test1.solutionType());
|
assert(!test1.solutionType());
|
||||||
assert(!test2.solutionType());
|
assert(!test2.solutionType());
|
||||||
assert(test3.solutionType());
|
assert(test3.solutionType());
|
||||||
|
|
||||||
test1();
|
test1();
|
||||||
test2();
|
test2();
|
||||||
test3();
|
test3();
|
||||||
doubleParam.value()= 3.3;
|
doubleParam.value()= 3.3;
|
||||||
intParam.value()=7;
|
intParam.value()=7;
|
||||||
sol.fitness(1);
|
sol.fitness(1);
|
||||||
eotParam.value()=sol;
|
eotParam.value()=sol;
|
||||||
test1();
|
test1();
|
||||||
test2();
|
test2();
|
||||||
test3();
|
test3();
|
||||||
doubleParam.value()= 3.6;
|
doubleParam.value()= 3.6;
|
||||||
intParam.value()=8;
|
intParam.value()=8;
|
||||||
sol.fitness(2);
|
sol.fitness(2);
|
||||||
eotParam.value()=sol;
|
eotParam.value()=sol;
|
||||||
test1();
|
test1();
|
||||||
test2();
|
test2();
|
||||||
test3();
|
test3();
|
||||||
doubleParam.value()= 3.001;
|
doubleParam.value()= 3.001;
|
||||||
intParam.value()=9;
|
intParam.value()=9;
|
||||||
test1();
|
test1();
|
||||||
test2();
|
test2();
|
||||||
|
|
||||||
assert(test1.size()==4);
|
assert(test1.size()==4);
|
||||||
assert(test2.size()==4);
|
assert(test2.size()==4);
|
||||||
assert(test3.size()==3);
|
assert(test3.size()==3);
|
||||||
assert(test1.getValue(1)=="3.3");
|
assert(test1.getValue(1)=="3.3");
|
||||||
assert(test2.getValue(2)=="8");
|
assert(test2.getValue(2)=="8");
|
||||||
std::cout << test3.getValue(2) << std::endl;
|
std::cout << test3.getValue(2) << std::endl;
|
||||||
assert(test1.getValues()[0]==3.1);
|
assert(test1.getValues()[0]==3.1);
|
||||||
assert(test2.getValues()[2]==8);
|
assert(test2.getValues()[2]==8);
|
||||||
assert(test3.getSolutions()[0].fitness()==0);
|
assert(test3.getSolutions()[0].fitness()==0);
|
||||||
|
|
||||||
test1.fileExport("outputTestVectorMonitor.txt");
|
test1.fileExport("outputTestVectorMonitor.txt");
|
||||||
|
|
||||||
test1.clear();
|
test1.clear();
|
||||||
test2.clear();
|
test2.clear();
|
||||||
test3.clear();
|
test3.clear();
|
||||||
assert(test1.size()==0);
|
assert(test1.size()==0);
|
||||||
assert(test2.size()==0);
|
assert(test2.size()==0);
|
||||||
assert(test3.size()==0);
|
assert(test3.size()==0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
assert(test1.className()=="moVectorMonitor");
|
assert(test1.className()=="moVectorMonitor");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::cout << "[t-moVectorMonitor] => OK" << std::endl;
|
std::cout << "[t-moVectorMonitor] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ using namespace std;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// fitness function
|
// fitness function
|
||||||
#include "../oneMax/src/funcRoyalRoad.h"
|
#include <eval/royalRoadEval.h>
|
||||||
#include <eoInt.h>
|
#include <eoInt.h>
|
||||||
#include <neighborhood/moRndWithoutReplNeighborhood.h>
|
#include <neighborhood/moRndWithoutReplNeighborhood.h>
|
||||||
#include <problems/bitString/moBitNeighbor.h>
|
#include <problems/bitString/moBitNeighbor.h>
|
||||||
|
|
@ -120,7 +120,7 @@ void main_function(int argc, char **argv)
|
||||||
*
|
*
|
||||||
* ========================================================= */
|
* ========================================================= */
|
||||||
|
|
||||||
FuncRoyalRoad<Indi> eval(vecSize / blockSize, blockSize);
|
RoyalRoadEval<Indi> eval(blockSize);
|
||||||
|
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
ADD_SUBDIRECTORY(application)
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src
|
|
||||||
${MO_SRC_DIR}/src
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../src)
|
|
||||||
|
|
||||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib)
|
|
||||||
|
|
||||||
ADD_EXECUTABLE(testSimpleHC testSimpleHC.cpp)
|
|
||||||
ADD_EXECUTABLE(testFirstImpr testFirstImpr.cpp)
|
|
||||||
ADD_EXECUTABLE(testRandomWalk testRandomWalk.cpp)
|
|
||||||
ADD_EXECUTABLE(testRandomBestHC testRandomBestHC.cpp)
|
|
||||||
ADD_EXECUTABLE(testHCneutral testHCneutral.cpp)
|
|
||||||
ADD_EXECUTABLE(testMetropolisHasting testMetropolisHasting.cpp)
|
|
||||||
#ADD_EXECUTABLE(testWithMove testWithMove.cpp)
|
|
||||||
ADD_EXECUTABLE(testSimpleTS testSimpleTS.cpp)
|
|
||||||
ADD_EXECUTABLE(testRandomNeutralWalk testRandomNeutralWalk.cpp)
|
|
||||||
ADD_EXECUTABLE(testILS testILS.cpp)
|
|
||||||
ADD_EXECUTABLE(testSimulatedAnnealing testSimulatedAnnealing.cpp)
|
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(testSimpleHC eoutils ga eo)
|
|
||||||
TARGET_LINK_LIBRARIES(testFirstImpr eoutils ga eo)
|
|
||||||
TARGET_LINK_LIBRARIES(testRandomWalk eoutils ga eo)
|
|
||||||
TARGET_LINK_LIBRARIES(testRandomBestHC eoutils ga eo)
|
|
||||||
TARGET_LINK_LIBRARIES(testHCneutral eoutils ga eo)
|
|
||||||
TARGET_LINK_LIBRARIES(testMetropolisHasting eoutils ga eo)
|
|
||||||
#TARGET_LINK_LIBRARIES(testWithMove eoutils ga eo)
|
|
||||||
TARGET_LINK_LIBRARIES(testSimpleTS eoutils ga eo)
|
|
||||||
TARGET_LINK_LIBRARIES(testRandomNeutralWalk eoutils ga eo)
|
|
||||||
TARGET_LINK_LIBRARIES(testILS eoutils ga eo)
|
|
||||||
TARGET_LINK_LIBRARIES(testSimulatedAnnealing eoutils ga eo)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,214 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
/** testSimpleHC.cpp
|
|
||||||
*
|
|
||||||
* SV - 12/01/10
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// standard includes
|
|
||||||
#define HAVE_SSTREAM
|
|
||||||
|
|
||||||
#include <stdexcept> // runtime_error
|
|
||||||
#include <iostream> // cout
|
|
||||||
#include <sstream> // ostrstream, istrstream
|
|
||||||
#include <fstream>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
// the general include for eo
|
|
||||||
#include <eo>
|
|
||||||
#include "ga.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// fitness function
|
|
||||||
#include <funcOneMax.h>
|
|
||||||
|
|
||||||
//#include <eoInt.h>
|
|
||||||
//#include <moEmptyNeighbor.h>
|
|
||||||
|
|
||||||
#include <continuator/moTrueContinuator.h>
|
|
||||||
|
|
||||||
// local search algorithm
|
|
||||||
#include <algo/moLocalSearch.h>
|
|
||||||
|
|
||||||
// the simple HC explorer
|
|
||||||
#include <explorer/moSimpleHCexplorer.h>
|
|
||||||
|
|
||||||
// explore the neighborhood of a bit string in order
|
|
||||||
#include <neighborhood/moMoveNeighborhood.h>
|
|
||||||
|
|
||||||
//#include <moFullEvalBitNeighbor.h>
|
|
||||||
|
|
||||||
#include <neighborhood/moMoveNeighbor.h>
|
|
||||||
|
|
||||||
#include <bitMove.h>
|
|
||||||
#include <bitMove_init.h>
|
|
||||||
#include <bitMoveIncrEval.h>
|
|
||||||
#include <bitMove_next.h>
|
|
||||||
|
|
||||||
// REPRESENTATION
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// define your individuals
|
|
||||||
typedef eoBit<unsigned> Indi;
|
|
||||||
//typedef OneMaxBitNeighbor<unsigned> Neighbor ; // incremental evaluation
|
|
||||||
typedef moMoveNeighbor<BitMove<Indi>, unsigned> Neighbor ; // full evaluation
|
|
||||||
typedef moMoveNeighborhood<BitMove<Indi>, unsigned> Neighborhood ;
|
|
||||||
|
|
||||||
// GENERAL
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void main_function(int argc, char **argv)
|
|
||||||
{
|
|
||||||
/* =========================================================
|
|
||||||
*
|
|
||||||
* Parameters
|
|
||||||
*
|
|
||||||
* ========================================================= */
|
|
||||||
|
|
||||||
// First define a parser from the command-line arguments
|
|
||||||
eoParser parser(argc, argv);
|
|
||||||
|
|
||||||
// For each parameter, define Parameter, read it through the parser,
|
|
||||||
// and assign the value to the variable
|
|
||||||
|
|
||||||
eoValueParam<uint32_t> seedParam(time(0), "seed", "Random number seed", 'S');
|
|
||||||
parser.processParam( seedParam );
|
|
||||||
unsigned seed = seedParam.value();
|
|
||||||
|
|
||||||
// description of genotype
|
|
||||||
eoValueParam<unsigned int> vecSizeParam(8, "vecSize", "Genotype size", 'V');
|
|
||||||
parser.processParam( vecSizeParam, "Representation" );
|
|
||||||
unsigned vecSize = vecSizeParam.value();
|
|
||||||
|
|
||||||
string fileOut("out.dat");
|
|
||||||
eoValueParam<string> fileStatParam(fileOut.c_str(), "out", "A file to export results", 'o');
|
|
||||||
parser.processParam( fileStatParam, "Persistence" );
|
|
||||||
fileOut = fileStatParam.value();
|
|
||||||
|
|
||||||
// the name of the "status" file where all actual parameter values will be saved
|
|
||||||
string str_status = parser.ProgramName() + ".status"; // default value
|
|
||||||
eoValueParam<string> statusParam(str_status.c_str(), "status", "Status file");
|
|
||||||
parser.processParam( statusParam, "Persistence" );
|
|
||||||
|
|
||||||
// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED
|
|
||||||
// i.e. in case you need parameters somewhere else, postpone these
|
|
||||||
if (parser.userNeedsHelp())
|
|
||||||
{
|
|
||||||
parser.printHelp(cout);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (statusParam.value() != "")
|
|
||||||
{
|
|
||||||
ofstream os(statusParam.value().c_str());
|
|
||||||
os << parser; // and you can use that file as parameter file
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* =========================================================
|
|
||||||
*
|
|
||||||
* Random seed
|
|
||||||
*
|
|
||||||
* ========================================================= */
|
|
||||||
|
|
||||||
//reproducible random seed: if you don't change SEED above,
|
|
||||||
// you'll aways get the same result, NOT a random run
|
|
||||||
rng.reseed(seed);
|
|
||||||
|
|
||||||
|
|
||||||
/* =========================================================
|
|
||||||
*
|
|
||||||
* Eval fitness function
|
|
||||||
*
|
|
||||||
* ========================================================= */
|
|
||||||
|
|
||||||
FuncOneMax<Indi> eval(vecSize);
|
|
||||||
|
|
||||||
OneMaxIncrEval<Indi> incrEval;
|
|
||||||
Neighbor::setIncrEval(incrEval);
|
|
||||||
|
|
||||||
/* =========================================================
|
|
||||||
*
|
|
||||||
* Initilisation of the solution
|
|
||||||
*
|
|
||||||
* ========================================================= */
|
|
||||||
|
|
||||||
// a Indi random initializer
|
|
||||||
eoUniformGenerator<bool> uGen;
|
|
||||||
eoInitFixedLength<Indi> random(vecSize, uGen);
|
|
||||||
|
|
||||||
/* =========================================================
|
|
||||||
*
|
|
||||||
* evaluation of a neighbor solution
|
|
||||||
*
|
|
||||||
* ========================================================= */
|
|
||||||
|
|
||||||
// no need if incremental evaluation with OneMaxBitNeighbor
|
|
||||||
// Neighbor::setFullEvalFunc(eval);
|
|
||||||
|
|
||||||
/* =========================================================
|
|
||||||
*
|
|
||||||
* the neighborhood of a solution
|
|
||||||
*
|
|
||||||
* ========================================================= */
|
|
||||||
BitMove_init<Indi> init;
|
|
||||||
BitMove_next<Indi> next;
|
|
||||||
|
|
||||||
|
|
||||||
Neighborhood neighborhood(init, next);
|
|
||||||
|
|
||||||
/* =========================================================
|
|
||||||
*
|
|
||||||
* a neighborhood explorator solution
|
|
||||||
*
|
|
||||||
* ========================================================= */
|
|
||||||
|
|
||||||
moSimpleHCexplorer<Neighborhood> explorer(neighborhood);
|
|
||||||
|
|
||||||
/* =========================================================
|
|
||||||
*
|
|
||||||
* the local search algorithm
|
|
||||||
*
|
|
||||||
* ========================================================= */
|
|
||||||
|
|
||||||
moTrueContinuator<Neighborhood> continuator;
|
|
||||||
|
|
||||||
moLocalSearch< moSimpleHCexplorer<Neighborhood> > localSearch(explorer, continuator);
|
|
||||||
|
|
||||||
/* =========================================================
|
|
||||||
*
|
|
||||||
* execute the local search from random sollution
|
|
||||||
*
|
|
||||||
* ========================================================= */
|
|
||||||
|
|
||||||
Indi solution;
|
|
||||||
|
|
||||||
random(solution);
|
|
||||||
|
|
||||||
eval(solution);
|
|
||||||
|
|
||||||
std::cout << "initial: " << solution << std::endl ;
|
|
||||||
|
|
||||||
localSearch(solution);
|
|
||||||
|
|
||||||
std::cout << "final: " << solution << std::endl ;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// A main that catches the exceptions
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
main_function(argc, argv);
|
|
||||||
}
|
|
||||||
catch (exception& e)
|
|
||||||
{
|
|
||||||
cout << "Exception: " << e.what() << '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "bitMove.h"
|
|
||||||
|
|
||||||
#ifndef __bitMove
|
|
||||||
#define __bitMove
|
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
#include <move/moMove.h>
|
|
||||||
|
|
||||||
template <class EOT>
|
|
||||||
class BitMove : public moMove <EOT> {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
typedef EOT EOType;
|
|
||||||
|
|
||||||
unsigned bit;
|
|
||||||
|
|
||||||
BitMove() {
|
|
||||||
bit = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
BitMove(unsigned _bit) : bit(_bit) { }
|
|
||||||
|
|
||||||
|
|
||||||
void operator () (EOT & chrom)
|
|
||||||
{
|
|
||||||
chrom[bit] = !chrom[bit];
|
|
||||||
};
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "incrEval_funcNK.h"
|
|
||||||
|
|
||||||
#ifndef __incr_eval_funcNK_h
|
|
||||||
#define __incr_eval_funcNK_h
|
|
||||||
|
|
||||||
#include <move/moMoveIncrEval.h>
|
|
||||||
#include "bitMove.h"
|
|
||||||
|
|
||||||
template <class EOT>
|
|
||||||
class OneMaxIncrEval : public moMoveIncrEval < BitMove<EOT> > {
|
|
||||||
|
|
||||||
public :
|
|
||||||
OneMaxIncrEval() { };
|
|
||||||
|
|
||||||
typename EOT::Fitness operator () (const BitMove<EOT> & move, const EOT & chrom) {
|
|
||||||
if (chrom[move.bit]==0) {
|
|
||||||
return chrom.fitness()+1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return chrom.fitness()-1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "bitMove_init.h"
|
|
||||||
#ifndef __bitMove_init
|
|
||||||
#define __bitMove_init
|
|
||||||
|
|
||||||
#include <move/moMoveInit.h>
|
|
||||||
#include "bitMove.h"
|
|
||||||
|
|
||||||
template <class EOT>
|
|
||||||
class BitMove_init : public moMoveInit < BitMove<EOT> > {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
void operator () (BitMove<EOT> & __move, const EOT & genome) {
|
|
||||||
__move.bit = 0 ;
|
|
||||||
};
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "bitMove_next.h"
|
|
||||||
|
|
||||||
#ifndef __bitMove_next_h
|
|
||||||
#define __bitMove_next_h
|
|
||||||
|
|
||||||
#include <move/moNextMove.h>
|
|
||||||
#include "bitMove.h"
|
|
||||||
|
|
||||||
template <class EOT>
|
|
||||||
class BitMove_next : public moNextMove < BitMove<EOT> > {
|
|
||||||
|
|
||||||
public:
|
|
||||||
BitMove_next()
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
bool operator () (BitMove<EOT> & __move, const EOT & genome) {
|
|
||||||
|
|
||||||
if (__move.bit >= (genome.size() - 1)) {
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
__move.bit++;
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,328 +0,0 @@
|
||||||
#ifndef __funcNK
|
|
||||||
#define __funcNK
|
|
||||||
|
|
||||||
#include <eo>
|
|
||||||
#include <fstream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
template< class EOT >
|
|
||||||
class FuncNK : public eoEvalFunc<EOT> {
|
|
||||||
public:
|
|
||||||
// tables des contributions
|
|
||||||
double ** tables;
|
|
||||||
|
|
||||||
// liste des liens epistatiques en fonction du bit i
|
|
||||||
// pour chaque contribution, donne la liste des variables consernés
|
|
||||||
unsigned ** links;
|
|
||||||
|
|
||||||
// liste inverse
|
|
||||||
// pour chaque variable, donne la liste indices des contributions
|
|
||||||
vector<unsigned> * knils;
|
|
||||||
|
|
||||||
unsigned N;
|
|
||||||
unsigned K;
|
|
||||||
|
|
||||||
// constructeur vide
|
|
||||||
FuncNK() : N(0), K(0)
|
|
||||||
{
|
|
||||||
tables = NULL;
|
|
||||||
links = NULL;
|
|
||||||
};
|
|
||||||
|
|
||||||
FuncNK(unsigned _n) : N(_n), K(0)
|
|
||||||
{
|
|
||||||
tables = NULL;
|
|
||||||
links = NULL;
|
|
||||||
};
|
|
||||||
|
|
||||||
// construction de tables aléatoirement
|
|
||||||
FuncNK(int n, int k, bool consecutive = false) : N(n), K(k)
|
|
||||||
{
|
|
||||||
if (consecutive)
|
|
||||||
consecutiveTables();
|
|
||||||
else
|
|
||||||
randomTables();
|
|
||||||
};
|
|
||||||
|
|
||||||
// construction à partir d'un fichier des tables et des liens
|
|
||||||
FuncNK(const char * fichier = "")
|
|
||||||
{
|
|
||||||
load(fichier);
|
|
||||||
};
|
|
||||||
|
|
||||||
~FuncNK()
|
|
||||||
{
|
|
||||||
deleteTables();
|
|
||||||
};
|
|
||||||
|
|
||||||
void buildTables()
|
|
||||||
{
|
|
||||||
links = new unsigned*[N];
|
|
||||||
knils = new vector<unsigned>[N];
|
|
||||||
tables = new double*[N];
|
|
||||||
for(unsigned i = 0; i < N; i++) {
|
|
||||||
tables[i] = new double[1<<(K+1)];
|
|
||||||
links[i] = new unsigned[K+1];
|
|
||||||
knils[i].clear();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void deleteTables()
|
|
||||||
{
|
|
||||||
if (links != NULL) {
|
|
||||||
for(int i = 0; i < N; i++) {
|
|
||||||
delete [] (links[i]);
|
|
||||||
}
|
|
||||||
delete [] links;
|
|
||||||
links = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (knils != NULL) {
|
|
||||||
/*
|
|
||||||
for(int i = 0; i < N; i++) {
|
|
||||||
knils[i].clear();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
delete [] knils;
|
|
||||||
knils = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tables != NULL) {
|
|
||||||
for(int i = 0; i < N; i++) {
|
|
||||||
delete [] (tables[i]);
|
|
||||||
}
|
|
||||||
delete [] tables;
|
|
||||||
tables = NULL;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual void load(const char * nomTables)
|
|
||||||
{
|
|
||||||
fstream file;
|
|
||||||
file.open(nomTables, ios::in);
|
|
||||||
|
|
||||||
if (file.is_open()) {
|
|
||||||
//cout <<"loadTables: chargement des tables " <<nomTables <<endl;
|
|
||||||
string s;
|
|
||||||
|
|
||||||
// lecture des commentaires
|
|
||||||
string line;
|
|
||||||
file >> s;
|
|
||||||
while (s[0] == 'c') {
|
|
||||||
getline(file,line,'\n');
|
|
||||||
file >> s;
|
|
||||||
}
|
|
||||||
|
|
||||||
// lecture des parametres
|
|
||||||
if (s[0] != 'p') {
|
|
||||||
cerr <<"loadTables: erreur de lecture de paramètre pour " << nomTables <<endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
file >> s;
|
|
||||||
if (s != "NK") {
|
|
||||||
cerr <<"erreur " <<nomTables << " n'est pas un fichier NK" <<endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// lecture des paramètres N et K
|
|
||||||
file >> N >> K;
|
|
||||||
buildTables();
|
|
||||||
|
|
||||||
// lecture des liens
|
|
||||||
if (s[0] != 'p') {
|
|
||||||
cerr <<"loadTables: erreur de lecture de paramètre 'links' pour " << nomTables <<endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
file >> s;
|
|
||||||
if (s == "links") {
|
|
||||||
loadLinks(file);
|
|
||||||
} else {
|
|
||||||
cerr <<"loadTables: erreur de lecture de paramètre 'links' pour " << nomTables <<endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// lecture des tables
|
|
||||||
if (s[0] != 'p') {
|
|
||||||
cerr <<"loadTables: erreur de lecture de paramètre 'tables' pour " << nomTables <<endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
file >> s;
|
|
||||||
|
|
||||||
if (s == "tables") {
|
|
||||||
loadTables(file);
|
|
||||||
} else {
|
|
||||||
cerr << "loadTables: erreur de lecture de paramètre 'tables' pour " << nomTables <<endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
file.close();
|
|
||||||
} else {
|
|
||||||
cerr << "loadTables: impossible d'ouvrir " << nomTables << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
void loadLinks(fstream & file) {
|
|
||||||
for(int j = 0; j < K+1; j++)
|
|
||||||
for(int i = 0; i < N; i++) {
|
|
||||||
file >> links[i][j];
|
|
||||||
knils[links[i][j]].push_back(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void loadTables(fstream & file) {
|
|
||||||
for(int j = 0; j < (1<<(K+1)); j++)
|
|
||||||
for(int i = 0; i < N; i++)
|
|
||||||
file >> tables[i][j];
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void save(const char * nomTables)
|
|
||||||
{
|
|
||||||
// cout <<"saveTables: sauvegarde de la table " <<nomTables <<endl;
|
|
||||||
fstream file;
|
|
||||||
file.open(nomTables, ios::out);
|
|
||||||
|
|
||||||
if (file.is_open()) {
|
|
||||||
file << "c name of file : " << nomTables << endl;
|
|
||||||
file << "p NK " << N << " " << K <<endl;
|
|
||||||
|
|
||||||
file << "p links" << endl;
|
|
||||||
for(int j=0; j<K+1; j++)
|
|
||||||
for(int i=0; i<N; i++)
|
|
||||||
file << links[i][j] << endl;
|
|
||||||
|
|
||||||
file << "p tables" << endl;
|
|
||||||
for(int j=0; j<(1<<(K+1)); j++) {
|
|
||||||
for(int i=0; i<N; i++)
|
|
||||||
file << tables[i][j] << " ";
|
|
||||||
file << endl;
|
|
||||||
}
|
|
||||||
file.close();
|
|
||||||
} else {
|
|
||||||
cerr <<"saveTables: impossible d'ouvrir " <<nomTables <<endl;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void affiche()
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
for(int i=0; i<N; i++) {
|
|
||||||
cout <<"link " <<i <<" : ";
|
|
||||||
for(j = 0; j <= K; j++)
|
|
||||||
cout <<links[i][j] <<" ";
|
|
||||||
cout <<endl;
|
|
||||||
}
|
|
||||||
cout <<endl;
|
|
||||||
|
|
||||||
for(int i=0; i<N; i++) {
|
|
||||||
cout <<"knils " <<i <<" : ";
|
|
||||||
for(j=0; j<knils[i].size(); j++)
|
|
||||||
cout <<knils[i][j] <<" ";
|
|
||||||
cout <<endl;
|
|
||||||
}
|
|
||||||
cout <<endl;
|
|
||||||
|
|
||||||
for(int i=0; i<N; i++) {
|
|
||||||
cout <<"table " <<i <<endl;
|
|
||||||
for(j=0; j<(1<<(K+1)); j++)
|
|
||||||
cout << tables[i][j] <<endl;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// calcul de la fitness
|
|
||||||
virtual void operator() (EOT & genome)
|
|
||||||
{
|
|
||||||
double accu = 0.0;
|
|
||||||
|
|
||||||
for(int i = 0; i < N; i++)
|
|
||||||
accu += tables[i][sigma(genome,i)];
|
|
||||||
// double M = 0.05;
|
|
||||||
// genome.fitness( M * ((unsigned) (accu / (N*M))) ); // affecte la fitness du genome
|
|
||||||
genome.fitness( accu / (double) N ); // affecte la fitness du genome
|
|
||||||
};
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
void initTirage(int tabTirage[]) {
|
|
||||||
for(int i = 0; i<N; i++)
|
|
||||||
tabTirage[i] = i;
|
|
||||||
};
|
|
||||||
|
|
||||||
void perm(int tabTirage[],int i, int j) {
|
|
||||||
int k = tabTirage[i];
|
|
||||||
tabTirage[i] = tabTirage[j];
|
|
||||||
tabTirage[j] = k;
|
|
||||||
};
|
|
||||||
|
|
||||||
void tire(int i,int tabTirage[]) {
|
|
||||||
int t[K+1];
|
|
||||||
for(int j=0; j<K+1; j++) {
|
|
||||||
if (j==0) t[j]=i;
|
|
||||||
else t[j] = rng.random(N-j);
|
|
||||||
links[i][j] = tabTirage[t[j]];
|
|
||||||
knils[tabTirage[t[j]]].push_back(i);
|
|
||||||
perm(tabTirage, t[j], N-1-j);
|
|
||||||
}
|
|
||||||
for(int j=K; j>=0; j--)
|
|
||||||
perm(tabTirage, t[j], N-1-j);
|
|
||||||
};
|
|
||||||
|
|
||||||
void consecutiveLinks(int i) {
|
|
||||||
for(int j=0; j<K+1; j++) {
|
|
||||||
links[i][j] = (i + j) % N;
|
|
||||||
knils[(i + j) % N].push_back(i);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// tables et liens aléatoires
|
|
||||||
virtual void randomTables() {
|
|
||||||
buildTables();
|
|
||||||
|
|
||||||
int tabTirage[N];
|
|
||||||
initTirage(tabTirage);
|
|
||||||
|
|
||||||
for(int i = 0; i < N; i++) {
|
|
||||||
// construit les loci epistatiquement liés au locus i
|
|
||||||
tire(i, tabTirage);
|
|
||||||
|
|
||||||
// la table Fi
|
|
||||||
for(int j = 0; j < (1<<(K+1)); j++)
|
|
||||||
tables[i][j] = rng.uniform();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// tables et liens aléatoires
|
|
||||||
virtual void consecutiveTables() {
|
|
||||||
buildTables();
|
|
||||||
|
|
||||||
for(int i = 0; i < N; i++) {
|
|
||||||
// construit les loci epistatiquement liés au locus i
|
|
||||||
consecutiveLinks(i);
|
|
||||||
|
|
||||||
// la table Fi
|
|
||||||
for(int j = 0; j < (1<<(K+1)); j++)
|
|
||||||
tables[i][j] = rng.uniform();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// extrait les bits liés au bit n°i
|
|
||||||
unsigned int sigma(EOT & genome, int i)
|
|
||||||
{
|
|
||||||
unsigned int n = 1;
|
|
||||||
unsigned int accu = 0;
|
|
||||||
for(int j=0; j<K+1; j++) {
|
|
||||||
if (genome[links[i][j]] == 1)
|
|
||||||
accu = accu | n;
|
|
||||||
n = n<<1;
|
|
||||||
}
|
|
||||||
return accu;
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// funcOneMax.h
|
|
||||||
// 25/11/2009 : copy from FuncU.h
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef __FuncOneMax
|
|
||||||
#define __FuncOneMax
|
|
||||||
|
|
||||||
template< class EOT >
|
|
||||||
class FuncOneMax : public eoEvalFunc<EOT>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
unsigned int N;
|
|
||||||
|
|
||||||
public:
|
|
||||||
FuncOneMax(unsigned int n) : N(n) {};
|
|
||||||
|
|
||||||
~FuncOneMax(void) {} ;
|
|
||||||
|
|
||||||
void operator() (EOT & genome) {
|
|
||||||
unsigned int sum = 0;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < N; i++)
|
|
||||||
sum += genome[i];
|
|
||||||
|
|
||||||
genome.fitness(sum);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
#ifndef __funcRoyalRoad
|
|
||||||
#define __funcRoyalRoad
|
|
||||||
|
|
||||||
#include <eoEvalFunc.h>
|
|
||||||
|
|
||||||
template< class EOT >
|
|
||||||
class FuncRoyalRoad : public eoEvalFunc<EOT>
|
|
||||||
{
|
|
||||||
// number of blocks
|
|
||||||
unsigned n;
|
|
||||||
|
|
||||||
// size of a block
|
|
||||||
unsigned k;
|
|
||||||
|
|
||||||
public:
|
|
||||||
FuncRoyalRoad(unsigned _n, unsigned _k) : n(_n), k(_k) {};
|
|
||||||
|
|
||||||
~FuncRoyalRoad(void) {} ;
|
|
||||||
|
|
||||||
virtual void operator() (EOT & _solution)
|
|
||||||
{
|
|
||||||
unsigned sum = 0;
|
|
||||||
unsigned i, j;
|
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
j = 0;
|
|
||||||
while (_solution[i * n + j] && j < k) j++;
|
|
||||||
|
|
||||||
if (j == k)
|
|
||||||
sum++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_solution.fitness(sum);
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
#ifndef _oneMaxBitNeighbor_h
|
|
||||||
#define _oneMaxBitNeighbor_h
|
|
||||||
|
|
||||||
#include <problems/bitString/moBitNeighbor.h>
|
|
||||||
#include <ga.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
contener of the neighbor information
|
|
||||||
*/
|
|
||||||
template< class Fitness >
|
|
||||||
class OneMaxBitNeighbor : public moBitNeighbor<Fitness>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef eoBit<Fitness> EOType ;
|
|
||||||
|
|
||||||
using moBitNeighbor<Fitness>::bit ;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* incremental evaluation of the solution for the oneMax problem
|
|
||||||
*/
|
|
||||||
virtual void eval(EOType & solution) {
|
|
||||||
if (solution[bit] == 0)
|
|
||||||
fitness(solution.fitness() + 1);
|
|
||||||
else
|
|
||||||
fitness(solution.fitness() - 1);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// Local Variables:
|
|
||||||
// coding: iso-8859-1
|
|
||||||
// mode: C++
|
|
||||||
// c-file-offsets: ((c . 0))
|
|
||||||
// c-file-style: "Stroustrup"
|
|
||||||
// fill-column: 80
|
|
||||||
// End:
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue