[fastga] adds a fitness stoping criterion
This commit is contained in:
parent
558d476ef3
commit
e2b74349e1
1 changed files with 10 additions and 4 deletions
|
|
@ -26,14 +26,20 @@ eoAlgoFoundryFastGA<Bits>& make_foundry(
|
||||||
eoInit<Bits>& init,
|
eoInit<Bits>& init,
|
||||||
eoEvalFunc<Bits>& eval,
|
eoEvalFunc<Bits>& eval,
|
||||||
const size_t max_evals,
|
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.
|
// FIXME using max_restarts>1 does not allow to honor max evals.
|
||||||
auto& foundry = store.pack< eoAlgoFoundryFastGA<Bits> >(init, eval, max_evals, /*max_restarts=*/1);
|
auto& foundry = store.pack< eoAlgoFoundryFastGA<Bits> >(init, eval, max_evals, /*max_restarts=*/1);
|
||||||
|
|
||||||
/***** Continuators ****/
|
/***** Continuators ****/
|
||||||
foundry.continuators.add< eoGenContinue<Bits> >(generations);
|
auto& fitcont = store.pack< eoFitContinue<Bits> >(optimum);
|
||||||
|
auto& gencont = store.pack< eoGenContinue<Bits> >(generations);
|
||||||
|
auto combconts = std::make_shared< std::vector<eoContinue<Bits>*> >();
|
||||||
|
combconts->push_back( &fitcont );
|
||||||
|
combconts->push_back( &gencont );
|
||||||
|
foundry.continuators.add< eoCombinedContinue<Bits> >( *combconts );
|
||||||
// for(size_t i=1; i<10; i++) {
|
// for(size_t i=1; i<10; i++) {
|
||||||
// foundry.continuators.add< eoGenContinue<Bits> >(i);
|
// foundry.continuators.add< eoGenContinue<Bits> >(i);
|
||||||
// }
|
// }
|
||||||
|
|
@ -453,7 +459,7 @@ int main(int argc, char* argv[])
|
||||||
eoEvalFuncPtr<Bits> fake_eval(fake_func);
|
eoEvalFuncPtr<Bits> fake_eval(fake_func);
|
||||||
eoUniformGenerator<int> fake_gen(0, 1);
|
eoUniformGenerator<int> fake_gen(0, 1);
|
||||||
eoInitFixedLength<Bits> fake_init(/*bitstring size=*/1, fake_gen);
|
eoInitFixedLength<Bits> 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;
|
std::clog << std::endl << "Available operators:" << std::endl;
|
||||||
print_operators( continuator_p, fake_foundry.continuators , std::clog);
|
print_operators( continuator_p, fake_foundry.continuators , std::clog);
|
||||||
|
|
@ -616,7 +622,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
eoBooleanGenerator<int> bgen;
|
eoBooleanGenerator<int> bgen;
|
||||||
eoInitFixedLength<Bits> onemax_init(/*bitstring size=*/dimension, bgen);
|
eoInitFixedLength<Bits> 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());
|
Ints encoded_algo(foundry.size());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue