ParadiesEO cleanup
This commit is contained in:
parent
2ca5ddb186
commit
54a3b8d10e
10 changed files with 0 additions and 351 deletions
|
|
@ -1,17 +0,0 @@
|
|||
noinst_PROGRAMS = MasterDistEvalBitEA SlaveDistEvalBitEA
|
||||
|
||||
LIBEO = $(top_builddir)/src/libeo.a
|
||||
LIBEOUTILS = $(top_builddir)/src/utils/libeoutils.a
|
||||
|
||||
CXX = $(MPICXX)
|
||||
LD = $(MPICXX)
|
||||
AM_CXXFLAGS = -I$(top_srcdir)/src
|
||||
DEPS = $(LIBEOUTILS) $(LIBEO)
|
||||
LIBS = $(LIBEOUTILS) $(LIBEO)
|
||||
|
||||
|
||||
noinst_HEADERS = binary_value.h
|
||||
|
||||
MasterDistEvalBitEA_SOURCES = MasterDistEvalBitEA.cpp
|
||||
|
||||
SlaveDistEvalBitEA_SOURCES = SlaveDistEvalBitEA.cpp
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
MPICC = mpiCC
|
||||
|
||||
ALL = MasterDistEvalBitEA SlaveDistEvalBitEA
|
||||
|
||||
lesson2 : MasterDistEvalBitEA SlaveDistEvalBitEA
|
||||
|
||||
all : $(ALL)
|
||||
|
||||
clean :
|
||||
@/bin/rm $(ALL) *.o *~
|
||||
|
||||
MasterDistEvalBitEA : MasterDistEvalBitEA.o
|
||||
$(MPICC) -DPACKAGE=\"eo\" -o MasterDistEvalBitEA MasterDistEvalBitEA.o ../../../src/utils/libeoutils.a ../../../src/libeo.a
|
||||
|
||||
MasterDistEvalBitEA.o : MasterDistEvalBitEA.cpp binary_value.h
|
||||
$(MPICC) -DPACKAGE=\"eo\" -I. -I../../../src -c MasterDistEvalBitEA.cpp
|
||||
|
||||
SlaveDistEvalBitEA : SlaveDistEvalBitEA.o
|
||||
$(MPICC) -DPACKAGE=\"eo\" -o SlaveDistEvalBitEA SlaveDistEvalBitEA.o ../../../src/utils/libeoutils.a ../../../src/libeo.a
|
||||
|
||||
SlaveDistEvalBitEA.o : SlaveDistEvalBitEA.cpp binary_value.h
|
||||
$(MPICC) -DPACKAGE=\"eo\" -I. -I../../../src -c SlaveDistEvalBitEA.cpp
|
||||
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#ifdef HAVE_SSTREAM
|
||||
#include <sstream>
|
||||
#else
|
||||
#include <strstream>
|
||||
#endif
|
||||
|
||||
#include <paradiseo.h>
|
||||
#include <ga.h>
|
||||
|
||||
typedef eoBit<double> Indi ; // A bitstring with fitness double
|
||||
|
||||
#include "binary_value.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void main_function(int argc, char **argv) {
|
||||
|
||||
// Some parameters
|
||||
const unsigned int SEED = 42 ; // Seed for random number generator
|
||||
const unsigned int T_SIZE = 3 ; // Size for tournament selection
|
||||
const unsigned int VEC_SIZE = 8 ; // Number of bits in genotypes
|
||||
const unsigned int POP_SIZE = 100 ; // Size of population
|
||||
|
||||
const unsigned int MAX_GEN = 20 ; // Maximum number of generation before STOP
|
||||
|
||||
const double P_CROSS = 0.8 ; // Crossover probability
|
||||
const double P_MUT = 1.0 ; // Mutation probability
|
||||
const double P_MUT_PER_BIT = 0.01 ; // Internal probability for bit-flip mutation
|
||||
const double onePointRate = 0.5 ; // Rate for 1-pt Xover
|
||||
const double bitFlipRate = 0.5 ; // Rate for bit-flip mutation
|
||||
|
||||
rng.reseed (SEED) ;
|
||||
|
||||
eoEvalFuncPtr <Indi, double, const vector <bool>& > eval (binary_value) ;
|
||||
|
||||
eoUniformGenerator <bool> uGen ;
|
||||
eoInitFixedLength <Indi> random (VEC_SIZE, uGen) ;
|
||||
|
||||
eoPop <Indi> pop (POP_SIZE, random) ;
|
||||
|
||||
apply <Indi> (eval, pop) ;
|
||||
|
||||
eoDetTournamentSelect <Indi> selectOne (T_SIZE) ;
|
||||
|
||||
eoSelectPerc<Indi> select (selectOne) ;
|
||||
|
||||
eoGenerationalReplacement <Indi> replace ;
|
||||
|
||||
eo1PtBitXover<Indi> xover1 ;
|
||||
|
||||
eoBitMutation<Indi> mutationBitFlip(P_MUT_PER_BIT) ;
|
||||
|
||||
// The operators are encapsulated into an eoTRansform object
|
||||
eoSGATransform<Indi> transform(xover1, P_CROSS, mutationBitFlip, P_MUT);
|
||||
|
||||
eoGenContinue<Indi> genCont (MAX_GEN);
|
||||
|
||||
eoEasyEA<Indi> gga (genCont, eval, select, transform, replace);
|
||||
|
||||
eoListener <Indi> listen (argc, argv) ;
|
||||
|
||||
eoDistEvalEasyEA <Indi> dist_gga (listen, gga, "Mars") ;
|
||||
|
||||
dist_gga (pop) ;
|
||||
|
||||
listen.destroy ("Mars") ;
|
||||
|
||||
// OUTPUT
|
||||
// Print (sorted) intial population
|
||||
pop.sort();
|
||||
cout << "FINAL Population\n" << pop << endl;
|
||||
// GENERAL
|
||||
}
|
||||
|
||||
// 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,51 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept> // runtime_error
|
||||
#ifdef HAVE_SSTREAM
|
||||
#include <sstream>
|
||||
#else
|
||||
#include <strstream>
|
||||
#endif
|
||||
|
||||
#include <paradiseo.h>
|
||||
#include <ga.h>
|
||||
|
||||
typedef eoBit<double> Indi; // A bitstring with fitness double
|
||||
|
||||
#include "binary_value.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void main_function(int argc, char **argv) {
|
||||
|
||||
eoEvalFuncPtr <Indi, double, const vector <bool> & > eval (binary_value) ;
|
||||
|
||||
eoListener <Indi> listen (argc, argv) ;
|
||||
|
||||
eoEvaluator <Indi> evaluator ("Mars",
|
||||
listen,
|
||||
eval) ;
|
||||
|
||||
// Runs
|
||||
evaluator () ;
|
||||
}
|
||||
|
||||
// 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,17 +0,0 @@
|
|||
#include <eo>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** Just a simple function that takes binary value of a chromosome and sets
|
||||
the fitnes.
|
||||
@param _chrom A binary chromosome
|
||||
*/
|
||||
// INIT
|
||||
double binary_value(const std::vector<bool>& _chrom)
|
||||
{
|
||||
double sum = 0;
|
||||
for (unsigned i = 0; i < _chrom.size(); i++)
|
||||
sum += _chrom[i];
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
${MACHINE0} 0 ${HOME}/eo/tutorial/ParadisEO/Lesson2/MasterDistEvalBitEA
|
||||
${MACHINE0} 1 ${HOME}/eo/tutorial/ParadisEO/Lesson2/SlaveDistEvalBitEA
|
||||
${MACHINE1} 1 ${HOME}/eo/tutorial/ParadisEO/Lesson2/SlaveDistEvalBitEA
|
||||
${MACHINE2} 1 ${HOME}/eo/tutorial/ParadisEO/Lesson2/SlaveDistEvalBitEA
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept> // runtime_error
|
||||
#ifdef HAVE_SSTREAM
|
||||
#include <sstream>
|
||||
#else
|
||||
#include <strstream>
|
||||
#endif
|
||||
|
||||
#include <eo>
|
||||
#include <ga.h>
|
||||
|
||||
typedef eoBit<double> Indi;
|
||||
|
||||
#include "binary_value.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void main_function(int argc, char **argv)
|
||||
{
|
||||
|
||||
const unsigned int SEED = 42;
|
||||
const unsigned int VEC_SIZE = 8;
|
||||
const unsigned int POP_SIZE = 25;
|
||||
|
||||
const unsigned int MAX_GEN = 100;
|
||||
|
||||
const double P_MUT_PER_BIT = 0.01;
|
||||
|
||||
rng.reseed(SEED);
|
||||
|
||||
eoEvalFuncPtr<Indi, double, const vector<bool>& > eval( binary_value );
|
||||
|
||||
eoUniformGenerator<bool> uGen;
|
||||
eoInitFixedLength<Indi> random(VEC_SIZE, uGen);
|
||||
|
||||
eoPop<Indi> pop(POP_SIZE, random);
|
||||
|
||||
|
||||
apply<Indi>(eval, pop);
|
||||
|
||||
pop.sort();
|
||||
|
||||
cout << "Initial Population" << endl;
|
||||
cout << pop;
|
||||
|
||||
eo1PtBitXover<Indi> xover1;
|
||||
|
||||
eoBitMutation<Indi> mutationBitFlip(P_MUT_PER_BIT);
|
||||
|
||||
eoGenContinue<Indi> genCont(MAX_GEN);
|
||||
|
||||
eoBestSelect <Indi> select ;
|
||||
|
||||
eoToricCellularEasyEA <Indi> gga (genCont,
|
||||
eval,
|
||||
select,
|
||||
xover1,
|
||||
mutationBitFlip,
|
||||
select,
|
||||
select) ;
|
||||
|
||||
cout << "\n Here we go\n\n";
|
||||
gga(pop);
|
||||
|
||||
pop.sort();
|
||||
cout << "FINAL Population\n" << pop << endl;
|
||||
|
||||
}
|
||||
|
||||
// A main that catches the exceptions
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
// rng.reseed(42);
|
||||
int flag = _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);
|
||||
flag |= _CRTDBG_LEAK_CHECK_DF;
|
||||
_CrtSetDbgFlag(flag);
|
||||
// _CrtSetBreakAlloc(100);
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
main_function(argc, argv);
|
||||
}
|
||||
catch(exception& e)
|
||||
{
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
noinst_PROGRAMS = CellularBitEA
|
||||
|
||||
LIBEO = $(top_builddir)/src/libeo.a
|
||||
LIBEOUTILS = $(top_builddir)/src/utils/libeoutils.a
|
||||
|
||||
CXX = $(MPICXX)
|
||||
LD = $(MPICXX)
|
||||
AM_CXXFLAGS = -I$(top_srcdir)/src
|
||||
DEPS = $(LIBEOUTILS) $(LIBEO)
|
||||
LIBS = $(LIBEOUTILS) $(LIBEO)
|
||||
|
||||
|
||||
noinst_HEADERS = binary_value.h
|
||||
|
||||
CellularBitEA_SOURCES = CellularBitEA.cpp
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
.SUFFIXES: .cpp
|
||||
.cpp: ; c++ -DPACKAGE=\"eo\" -DVERSION=\"0.9.1\" -I. -I../../../src -Wall -g -o $@ $*.cpp ../../../src/utils/libeoutils.a ../../../src/libeo.a
|
||||
|
||||
.cpp.o: ; c++ -DPACKAGE=\"eo\" -DVERSION=\"0.9.1\" -I. -I../../../src -Wall -g -c $*.cpp
|
||||
|
||||
ALL = CellularBitEA
|
||||
|
||||
lesson3 : $(firstEA)
|
||||
|
||||
all : $(ALL)
|
||||
|
||||
clean :
|
||||
@/bin/rm $(ALL) *.o *~
|
||||
|
||||
CellularBitEA : binary_value.h
|
||||
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
#include <eo>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** Just a simple function that takes binary value of a chromosome and sets
|
||||
the fitnes.
|
||||
@param _chrom A binary chromosome
|
||||
*/
|
||||
// INIT
|
||||
double binary_value(const std::vector<bool>& _chrom)
|
||||
{
|
||||
double sum = 0;
|
||||
for (unsigned i = 0; i < _chrom.size(); i++)
|
||||
sum += _chrom[i];
|
||||
return sum;
|
||||
}
|
||||
|
||||
Reference in a new issue