From e2b74349e153d759c1da1aca9f4e0256ae7a9832 Mon Sep 17 00:00:00 2001 From: nojhan Date: Fri, 30 Jul 2021 11:16:30 +0200 Subject: [PATCH] [fastga] adds a fitness stoping criterion --- eo/contrib/irace/fastga.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/eo/contrib/irace/fastga.cpp b/eo/contrib/irace/fastga.cpp index 9dd0c0d47..73f0e5388 100644 --- a/eo/contrib/irace/fastga.cpp +++ b/eo/contrib/irace/fastga.cpp @@ -26,14 +26,20 @@ eoAlgoFoundryFastGA& make_foundry( eoInit& init, eoEvalFunc& eval, const size_t max_evals, - const size_t generations + const size_t generations, + const double optimum ) { // FIXME using max_restarts>1 does not allow to honor max evals. auto& foundry = store.pack< eoAlgoFoundryFastGA >(init, eval, max_evals, /*max_restarts=*/1); /***** Continuators ****/ - foundry.continuators.add< eoGenContinue >(generations); + auto& fitcont = store.pack< eoFitContinue >(optimum); + auto& gencont = store.pack< eoGenContinue >(generations); + auto combconts = std::make_shared< std::vector*> >(); + combconts->push_back( &fitcont ); + combconts->push_back( &gencont ); + foundry.continuators.add< eoCombinedContinue >( *combconts ); // for(size_t i=1; i<10; i++) { // foundry.continuators.add< eoGenContinue >(i); // } @@ -453,7 +459,7 @@ int main(int argc, char* argv[]) eoEvalFuncPtr fake_eval(fake_func); eoUniformGenerator fake_gen(0, 1); eoInitFixedLength fake_init(/*bitstring size=*/1, fake_gen); - auto fake_foundry = make_foundry(store, fake_init, fake_eval, max_evals, /*generations=*/ 1); + auto fake_foundry = make_foundry(store, fake_init, fake_eval, max_evals, /*generations=*/ 1, 0); std::clog << std::endl << "Available operators:" << std::endl; print_operators( continuator_p, fake_foundry.continuators , std::clog); @@ -616,7 +622,7 @@ int main(int argc, char* argv[]) eoBooleanGenerator bgen; eoInitFixedLength onemax_init(/*bitstring size=*/dimension, bgen); - auto& foundry = make_foundry(store, onemax_init, eval_count, max_evals, generations); + auto& foundry = make_foundry(store, onemax_init, eval_count, max_evals, generations, max_target); Ints encoded_algo(foundry.size());