fix fastga: eval minus pop_size for init
This commit is contained in:
parent
6d465c6c2f
commit
70e79aba3d
1 changed files with 13 additions and 15 deletions
|
|
@ -24,8 +24,7 @@ eoAlgoFoundryFastGA<Bits>& make_foundry(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// 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_onemax, max_evals, /*max_restarts=*/1);
|
auto& foundry = store.pack< eoAlgoFoundryFastGA<Bits> >(init, eval_onemax, generations, max_evals, /*max_restarts=*/1);
|
||||||
auto& foundry = store.pack< eoAlgoFoundryFastGA<Bits> >(init, eval_onemax, max_evals);
|
|
||||||
|
|
||||||
/***** Continuators ****/
|
/***** Continuators ****/
|
||||||
foundry.continuators.add< eoGenContinue<Bits> >(generations);
|
foundry.continuators.add< eoGenContinue<Bits> >(generations);
|
||||||
|
|
@ -36,7 +35,7 @@ eoAlgoFoundryFastGA<Bits>& make_foundry(
|
||||||
// foundry.continuators.add< eoSteadyFitContinue<Bits> >(10,i);
|
// foundry.continuators.add< eoSteadyFitContinue<Bits> >(10,i);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
for(double i=0.1; i<1.0; i+=0.2) {
|
for(double i=0.0; i<1.0; i+=0.2) {
|
||||||
foundry.crossover_rates.add<double>(i);
|
foundry.crossover_rates.add<double>(i);
|
||||||
foundry.mutation_rates.add<double>(i);
|
foundry.mutation_rates.add<double>(i);
|
||||||
}
|
}
|
||||||
|
|
@ -164,7 +163,7 @@ int main(int argc, char* argv[])
|
||||||
const size_t problem = problem_p.value();
|
const size_t problem = problem_p.value();
|
||||||
|
|
||||||
|
|
||||||
auto pop_size_p = parser.getORcreateParam<size_t>(5,
|
auto pop_size_p = parser.getORcreateParam<size_t>(1,
|
||||||
"pop-size", "Population size",
|
"pop-size", "Population size",
|
||||||
'P', "Operator Choice", /*required=*/false);
|
'P', "Operator Choice", /*required=*/false);
|
||||||
const size_t pop_size = pop_size_p.value();
|
const size_t pop_size = pop_size_p.value();
|
||||||
|
|
@ -273,10 +272,10 @@ int main(int argc, char* argv[])
|
||||||
exit(NO_ERROR);
|
exit(NO_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// const size_t generations = static_cast<size_t>(std::floor(
|
const size_t generations = static_cast<size_t>(std::floor(
|
||||||
// static_cast<double>(max_evals) / static_cast<double>(pop_size)));
|
static_cast<double>(max_evals) / static_cast<double>(pop_size)));
|
||||||
const size_t generations = std::numeric_limits<size_t>::max();
|
// const size_t generations = std::numeric_limits<size_t>::max();
|
||||||
|
eo::log << eo::debug << "Number of generations: " << generations << std::endl;
|
||||||
|
|
||||||
// Problem configuration code.
|
// Problem configuration code.
|
||||||
struct Problem {
|
struct Problem {
|
||||||
|
|
@ -356,17 +355,16 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
eoEvalIOHproblem<Bits> onemax_pb(w_model_om, logger);
|
eoEvalIOHproblem<Bits> onemax_pb(w_model_om, logger);
|
||||||
|
|
||||||
|
// eoEvalPrint<Bits> eval_print(onemax_pb, std::clog, "\n");
|
||||||
eoEvalFuncCounter<Bits> eval_count(onemax_pb);
|
eoEvalFuncCounter<Bits> eval_count(onemax_pb);
|
||||||
|
|
||||||
// eoPopLoopEval<Bits> onemax_eval(onemax_pb);
|
|
||||||
eoPopLoopEval<Bits> onemax_eval(eval_count);
|
eoPopLoopEval<Bits> onemax_eval(eval_count);
|
||||||
|
|
||||||
/***** Instanciate and run the algo *****/
|
/***** Instanciate and run the algo *****/
|
||||||
|
|
||||||
eoUniformGenerator<int> ugen(0, 1);
|
eoBooleanGenerator<int> bgen;
|
||||||
eoInitFixedLength<Bits> onemax_init(/*bitstring size=*/dimension, ugen);
|
eoInitFixedLength<Bits> onemax_init(/*bitstring size=*/dimension, bgen);
|
||||||
// auto& foundry = make_foundry(store, onemax_init, onemax_pb, max_evals, generations);
|
auto& foundry = make_foundry(store, onemax_init, eval_count, max_evals - pop_size, generations);
|
||||||
auto& foundry = make_foundry(store, onemax_init, eval_count, max_evals, generations);
|
|
||||||
|
|
||||||
Ints encoded_algo(foundry.size());
|
Ints encoded_algo(foundry.size());
|
||||||
|
|
||||||
|
|
@ -411,7 +409,7 @@ int main(int argc, char* argv[])
|
||||||
<< ", check the bounds or the algorithm." << std::endl;
|
<< ", check the bounds or the algorithm." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::clog << "After " << eval_count.getValue() << " / " << max_evals << " evaluations" << std::endl;
|
// std::clog << "After " << eval_count.getValue() << " / " << max_evals << " evaluations" << std::endl;
|
||||||
|
|
||||||
// Output
|
// Output
|
||||||
std::cout << -1 * perf << std::endl;
|
std::cout << -1 * perf << std::endl;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue