ParadiesEO cleanup
This commit is contained in:
parent
2ca5ddb186
commit
54a3b8d10e
10 changed files with 0 additions and 351 deletions
|
|
@ -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