#ifdef HAVE_CONFIG_H #include #endif #include #include // runtime_error #ifdef HAVE_SSTREAM #include #else #include #endif #include #include typedef eoBit 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& > eval( binary_value ); eoUniformGenerator uGen; eoInitFixedLength random(VEC_SIZE, uGen); eoPop pop(POP_SIZE, random); apply(eval, pop); pop.sort(); cout << "Initial Population" << endl; cout << pop; eo1PtBitXover xover1; eoBitMutation mutationBitFlip(P_MUT_PER_BIT); eoGenContinue genCont(MAX_GEN); eoBestSelect select ; eoToricCellularEasyEA 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; }