fix offspring/pop misconception in FastGA foundry
This commit is contained in:
parent
530a12af20
commit
75f1d9524f
3 changed files with 62 additions and 57 deletions
|
|
@ -41,10 +41,10 @@ eoAlgoFoundryFastGA<Bits>& make_foundry(
|
||||||
|
|
||||||
/***** Offsprings size *****/
|
/***** Offsprings size *****/
|
||||||
// for(size_t i=5; i<100; i+=10) {
|
// for(size_t i=5; i<100; i+=10) {
|
||||||
// foundry.pop_sizes.add<size_t>(i);
|
// foundry.offspring_sizes.add<size_t>(i);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
foundry.pop_sizes.add<size_t>(0); // 0 = use parents fixed pop size.
|
foundry.offspring_sizes.add<size_t>(0); // 0 = use parents fixed pop size.
|
||||||
|
|
||||||
/***** Crossovers ****/
|
/***** Crossovers ****/
|
||||||
for(double i=0.1; i<0.9; i+=0.1) {
|
for(double i=0.1; i<0.9; i+=0.1) {
|
||||||
|
|
@ -155,14 +155,14 @@ int main(int argc, char* argv[])
|
||||||
'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();
|
||||||
|
|
||||||
auto instance_p = parser.getORcreateParam<size_t>(1,
|
auto instance_p = parser.getORcreateParam<size_t>(0,
|
||||||
"instance", "Instance ID",
|
"instance", "Instance ID",
|
||||||
'i', "Problem", /*required=*/true);
|
'i', "Problem", /*required=*/true);
|
||||||
const size_t instance = instance_p.value();
|
const size_t instance = instance_p.value();
|
||||||
|
|
||||||
auto continuator_p = parser.getORcreateParam<size_t>(0,
|
auto continuator_p = parser.getORcreateParam<size_t>(0,
|
||||||
"continuator", "Stopping criterion",
|
"continuator", "Stopping criterion",
|
||||||
'o', "Operator Choice", /*required=*/true);
|
'o', "Operator Choice", /*required=*/false); // Single alternative, not required.
|
||||||
const size_t continuator = continuator_p.value();
|
const size_t continuator = continuator_p.value();
|
||||||
|
|
||||||
auto crossover_rate_p = parser.getORcreateParam<size_t>(0,
|
auto crossover_rate_p = parser.getORcreateParam<size_t>(0,
|
||||||
|
|
@ -182,7 +182,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
auto aftercross_selector_p = parser.getORcreateParam<size_t>(0,
|
auto aftercross_selector_p = parser.getORcreateParam<size_t>(0,
|
||||||
"aftercross-selector", "How to selects between the two individuals altered by cross-over which one will mutate",
|
"aftercross-selector", "How to selects between the two individuals altered by cross-over which one will mutate",
|
||||||
'a', "Operator Choice", /*required=*/true);
|
'a', "Operator Choice", /*required=*/false); // Single alternative, not required.
|
||||||
const size_t aftercross_selector = aftercross_selector_p.value();
|
const size_t aftercross_selector = aftercross_selector_p.value();
|
||||||
|
|
||||||
auto mutation_rate_p = parser.getORcreateParam<size_t>(0,
|
auto mutation_rate_p = parser.getORcreateParam<size_t>(0,
|
||||||
|
|
@ -207,7 +207,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
auto offspring_size_p = parser.getORcreateParam<size_t>(0,
|
auto offspring_size_p = parser.getORcreateParam<size_t>(0,
|
||||||
"offspring-size", "Offsprings size (0 = same size than the parents pop, see --pop-size)",
|
"offspring-size", "Offsprings size (0 = same size than the parents pop, see --pop-size)",
|
||||||
'P', "Operator Choice", /*required=*/true);
|
'P', "Operator Choice", /*required=*/false); // Single alternative, not required.
|
||||||
const size_t offspring_size = offspring_size_p.value();
|
const size_t offspring_size = offspring_size_p.value();
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -234,7 +234,7 @@ int main(int argc, char* argv[])
|
||||||
* fake_foundry.mutations.size()
|
* fake_foundry.mutations.size()
|
||||||
* fake_foundry.replacements.size()
|
* fake_foundry.replacements.size()
|
||||||
* fake_foundry.continuators.size()
|
* fake_foundry.continuators.size()
|
||||||
* fake_foundry.pop_sizes.size();
|
* fake_foundry.offspring_sizes.size();
|
||||||
std::clog << std::endl;
|
std::clog << std::endl;
|
||||||
std::clog << n << " possible algorithms instances." << std::endl;
|
std::clog << n << " possible algorithms instances." << std::endl;
|
||||||
|
|
||||||
|
|
@ -251,7 +251,7 @@ int main(int argc, char* argv[])
|
||||||
print_param_range( mutation_selector_p, fake_foundry.mutation_selectors .size(), std::cout);
|
print_param_range( mutation_selector_p, fake_foundry.mutation_selectors .size(), std::cout);
|
||||||
print_param_range( mutation_p, fake_foundry.mutations .size(), std::cout);
|
print_param_range( mutation_p, fake_foundry.mutations .size(), std::cout);
|
||||||
print_param_range( replacement_p, fake_foundry.replacements .size(), std::cout);
|
print_param_range( replacement_p, fake_foundry.replacements .size(), std::cout);
|
||||||
print_param_range( offspring_size_p, fake_foundry.pop_sizes .size(), std::cout);
|
print_param_range( offspring_size_p, fake_foundry.offspring_sizes .size(), std::cout);
|
||||||
|
|
||||||
// std::ofstream irace_param("fastga.params");
|
// std::ofstream irace_param("fastga.params");
|
||||||
// irace_param << "# name\tswitch\ttype\tvalues" << std::endl;
|
// irace_param << "# name\tswitch\ttype\tvalues" << std::endl;
|
||||||
|
|
@ -274,30 +274,30 @@ int main(int argc, char* argv[])
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<size_t, Problem> problem_config_mapping {
|
std::map<size_t, Problem> problem_config_mapping {
|
||||||
{0, {0, 0, 1, 0, 1000}},
|
{ 0, {0, 0, 1, 0, 1000}},
|
||||||
{1, {0, 0, 3, 0, 333}},
|
{ 1, {0, 0, 3, 0, 333}},
|
||||||
{2, {0, 0, 5, 0, 200}},
|
{ 2, {0, 0, 5, 0, 200}},
|
||||||
{3, {0, 2, 1, 0, 1000}},
|
{ 3, {0, 2, 1, 0, 1000}},
|
||||||
{4, {0, 2, 3, 0, 333}},
|
{ 4, {0, 2, 3, 0, 333}},
|
||||||
{5, {0, 2, 3, 0, 200}},
|
{ 5, {0, 2, 3, 0, 200}},
|
||||||
{6, {0, 4, 1, 0, 1000}},
|
{ 6, {0, 4, 1, 0, 1000}},
|
||||||
{7, {0, 4, 3, 0, 333}},
|
{ 7, {0, 4, 3, 0, 333}},
|
||||||
{8, {0, 4, 5, 0, 200}},
|
{ 8, {0, 4, 5, 0, 200}},
|
||||||
{9, {0.5, 0, 1, 0, 500}},
|
{ 9, {0.5, 0, 1, 0, 500}},
|
||||||
{10, {0.5, 0, 3, 0, 166}},
|
{10, {0.5, 0, 3, 0, 166}},
|
||||||
{11, {0.5, 0, 5, 0, 100}},
|
{11, {0.5, 0, 5, 0, 100}},
|
||||||
{12, {0.5, 2, 1, 0, 500}},
|
{12, {0.5, 2, 1, 0, 500}},
|
||||||
{13, {0.5, 2, 3, 0, 166}},
|
{13, {0.5, 2, 3, 0, 166}},
|
||||||
{14, {0.5, 2, 5, 0, 100}},
|
{14, {0.5, 2, 5, 0, 100}},
|
||||||
{15, {0.5, 4, 1, 0, 500}},
|
{15, {0.5, 4, 1, 0, 500}},
|
||||||
{16, {0.5, 4, 3, 0, 166}},
|
{16, {0.5, 4, 3, 0, 166}},
|
||||||
{17, {0.5, 4, 5, 0, 100}},
|
{17, {0.5, 4, 5, 0, 100}},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***** IOH logger *****/
|
/***** IOH logger *****/
|
||||||
auto max_target_para = problem_config_mapping[instance - 1].max_target;
|
auto max_target_para = problem_config_mapping[instance].max_target;
|
||||||
IOHprofiler_RangeLinear<size_t> target_range(0, max_target_para, buckets);
|
IOHprofiler_RangeLinear<size_t> target_range(0, max_target_para, buckets);
|
||||||
IOHprofiler_RangeLinear<size_t> budget_range(0, max_evals, buckets);
|
IOHprofiler_RangeLinear<size_t> budget_range(0, max_evals, buckets);
|
||||||
IOHprofiler_ecdf_logger<int, size_t, size_t> logger(target_range, budget_range);
|
IOHprofiler_ecdf_logger<int, size_t, size_t> logger(target_range, budget_range);
|
||||||
|
|
@ -307,10 +307,10 @@ int main(int argc, char* argv[])
|
||||||
logger.activate_logger();
|
logger.activate_logger();
|
||||||
|
|
||||||
/***** IOH problem *****/
|
/***** IOH problem *****/
|
||||||
double w_model_suite_dummy_para = problem_config_mapping[instance - 1].dummy;
|
double w_model_suite_dummy_para = problem_config_mapping[instance].dummy;
|
||||||
int w_model_suite_epitasis_para = problem_config_mapping[instance - 1].epistasis;
|
int w_model_suite_epitasis_para = problem_config_mapping[instance].epistasis;
|
||||||
int w_model_suite_neutrality_para = problem_config_mapping[instance - 1].neutrality;
|
int w_model_suite_neutrality_para = problem_config_mapping[instance].neutrality;
|
||||||
int w_model_suite_ruggedness_para = problem_config_mapping[instance - 1].ruggedness;
|
int w_model_suite_ruggedness_para = problem_config_mapping[instance].ruggedness;
|
||||||
|
|
||||||
W_Model_OneMax w_model_om;
|
W_Model_OneMax w_model_om;
|
||||||
std::string problem_name = "OneMax";
|
std::string problem_name = "OneMax";
|
||||||
|
|
@ -329,8 +329,8 @@ int main(int argc, char* argv[])
|
||||||
w_model_om.IOHprofiler_set_problem_name(problem_name);
|
w_model_om.IOHprofiler_set_problem_name(problem_name);
|
||||||
|
|
||||||
/// Set problem_id as 1
|
/// Set problem_id as 1
|
||||||
w_model_om.IOHprofiler_set_problem_id(1);
|
w_model_om.IOHprofiler_set_problem_id(0); // FIXME check what that means
|
||||||
w_model_om.IOHprofiler_set_instance_id(instance);
|
w_model_om.IOHprofiler_set_instance_id(instance); // FIXME check what that means
|
||||||
|
|
||||||
/// Set dimension.
|
/// Set dimension.
|
||||||
w_model_om.IOHprofiler_set_number_of_variables(dimension);
|
w_model_om.IOHprofiler_set_number_of_variables(dimension);
|
||||||
|
|
@ -338,14 +338,14 @@ int main(int argc, char* argv[])
|
||||||
/***** Bindings *****/
|
/***** Bindings *****/
|
||||||
logger.track_problem(w_model_om);
|
logger.track_problem(w_model_om);
|
||||||
|
|
||||||
eoEvalIOHproblem<Bits> onemax_eval(w_model_om, logger);
|
eoEvalIOHproblem<Bits> onemax_pb(w_model_om, logger);
|
||||||
eoPopLoopEval<Bits> pop_onemax(onemax_eval);
|
eoPopLoopEval<Bits> onemax_eval(onemax_pb);
|
||||||
|
|
||||||
/***** Instanciate and run the algo *****/
|
/***** Instanciate and run the algo *****/
|
||||||
|
|
||||||
eoUniformGenerator<int> ugen(0, 1);
|
eoUniformGenerator<int> ugen(0, 1);
|
||||||
eoInitFixedLength<Bits> onemax_init(/*bitstring size=*/dimension, ugen);
|
eoInitFixedLength<Bits> onemax_init(/*bitstring size=*/dimension, ugen);
|
||||||
auto& foundry = make_foundry(store, onemax_init, onemax_eval, max_evals, generations);
|
auto& foundry = make_foundry(store, onemax_init, onemax_pb, max_evals, generations);
|
||||||
|
|
||||||
Ints encoded_algo(foundry.size());
|
Ints encoded_algo(foundry.size());
|
||||||
|
|
||||||
|
|
@ -358,7 +358,7 @@ int main(int argc, char* argv[])
|
||||||
encoded_algo[foundry.mutations .index()] = mutation;
|
encoded_algo[foundry.mutations .index()] = mutation;
|
||||||
encoded_algo[foundry.replacements .index()] = replacement;
|
encoded_algo[foundry.replacements .index()] = replacement;
|
||||||
encoded_algo[foundry.continuators .index()] = continuator;
|
encoded_algo[foundry.continuators .index()] = continuator;
|
||||||
encoded_algo[foundry.pop_sizes .index()] = offspring_size;
|
encoded_algo[foundry.offspring_sizes .index()] = offspring_size;
|
||||||
|
|
||||||
std::clog << "Encoded algorithm:" << std::endl;
|
std::clog << "Encoded algorithm:" << std::endl;
|
||||||
foundry.select(encoded_algo);
|
foundry.select(encoded_algo);
|
||||||
|
|
@ -366,7 +366,10 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
// Evaluation of a forged encoded_algo on the sub-problem
|
// Evaluation of a forged encoded_algo on the sub-problem
|
||||||
eoEvalFoundryFastGA<Ints, Bits> eval_foundry(
|
eoEvalFoundryFastGA<Ints, Bits> eval_foundry(
|
||||||
foundry, onemax_init, pop_onemax, /*penalization=*/ 0);
|
foundry, pop_size,
|
||||||
|
onemax_init, onemax_eval,
|
||||||
|
/*penalization=*/ dimension, // Worst case penalization.
|
||||||
|
/*normalized=*/ false); // Use direct integer encoding.
|
||||||
|
|
||||||
// Actually instanciate and run the algorithm.
|
// Actually instanciate and run the algorithm.
|
||||||
eval_foundry(encoded_algo);
|
eval_foundry(encoded_algo);
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ class eoAlgoFoundryFastGA : public eoAlgoFoundry<EOT>
|
||||||
|
|
||||||
replacements(7, false),
|
replacements(7, false),
|
||||||
continuators(8, true), // Always re-instantiate continuators, because they hold a state.
|
continuators(8, true), // Always re-instantiate continuators, because they hold a state.
|
||||||
pop_sizes(9, false),
|
offspring_sizes(9, false),
|
||||||
_eval(eval),
|
_eval(eval),
|
||||||
_init(init),
|
_init(init),
|
||||||
_max_evals(max_evals),
|
_max_evals(max_evals),
|
||||||
|
|
@ -122,7 +122,7 @@ class eoAlgoFoundryFastGA : public eoAlgoFoundry<EOT>
|
||||||
|
|
||||||
eoOperatorFoundry< eoReplacement<EOT> > replacements;
|
eoOperatorFoundry< eoReplacement<EOT> > replacements;
|
||||||
eoOperatorFoundry< eoContinue<EOT> > continuators;
|
eoOperatorFoundry< eoContinue<EOT> > continuators;
|
||||||
eoOperatorFoundry< size_t > pop_sizes;
|
eoOperatorFoundry< size_t > offspring_sizes;
|
||||||
/* @} */
|
/* @} */
|
||||||
|
|
||||||
/** instantiate and call the pre-selected algorithm.
|
/** instantiate and call the pre-selected algorithm.
|
||||||
|
|
@ -138,7 +138,7 @@ class eoAlgoFoundryFastGA : public eoAlgoFoundry<EOT>
|
||||||
assert( mutations.size() > 0); assert(this->at( mutations.index()) < mutations.size());
|
assert( mutations.size() > 0); assert(this->at( mutations.index()) < mutations.size());
|
||||||
assert( replacements.size() > 0); assert(this->at( replacements.index()) < replacements.size());
|
assert( replacements.size() > 0); assert(this->at( replacements.index()) < replacements.size());
|
||||||
assert( continuators.size() > 0); assert(this->at( continuators.index()) < continuators.size());
|
assert( continuators.size() > 0); assert(this->at( continuators.index()) < continuators.size());
|
||||||
assert( pop_sizes.size() > 0); assert(this->at( pop_sizes.index()) < pop_sizes.size());
|
assert( offspring_sizes.size() > 0); assert(this->at( offspring_sizes.index()) < offspring_sizes.size());
|
||||||
|
|
||||||
// Objective function calls counter
|
// Objective function calls counter
|
||||||
eoEvalCounterThrowException<EOT> eval(_eval, _max_evals);
|
eoEvalCounterThrowException<EOT> eval(_eval, _max_evals);
|
||||||
|
|
@ -156,7 +156,7 @@ class eoAlgoFoundryFastGA : public eoAlgoFoundry<EOT>
|
||||||
pop_eval,
|
pop_eval,
|
||||||
this->replacement(),
|
this->replacement(),
|
||||||
this->continuator(),
|
this->continuator(),
|
||||||
this->pop_size()
|
this->offspring_size()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Restart wrapper
|
// Restart wrapper
|
||||||
|
|
@ -188,7 +188,7 @@ class eoAlgoFoundryFastGA : public eoAlgoFoundry<EOT>
|
||||||
name << this->at( mutations.index()) << " (" << this-> mutation().className() << ") + ";
|
name << this->at( mutations.index()) << " (" << this-> mutation().className() << ") + ";
|
||||||
name << this->at( replacements.index()) << " (" << this-> replacement().className() << ") + ";
|
name << this->at( replacements.index()) << " (" << this-> replacement().className() << ") + ";
|
||||||
name << this->at( continuators.index()) << " (" << this-> continuator().className() << ") + ";
|
name << this->at( continuators.index()) << " (" << this-> continuator().className() << ") + ";
|
||||||
name << this->at( pop_sizes.index()) << " (" << this-> pop_size() << ")";
|
name << this->at( offspring_sizes.index()) << " (" << this-> offspring_size() << ")";
|
||||||
return name.str();
|
return name.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -247,10 +247,10 @@ class eoAlgoFoundryFastGA : public eoAlgoFoundry<EOT>
|
||||||
return mutation_selectors.instantiate(this->at(mutation_selectors.index()));
|
return mutation_selectors.instantiate(this->at(mutation_selectors.index()));
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t& pop_size()
|
size_t& offspring_size()
|
||||||
{
|
{
|
||||||
assert(this->at(pop_sizes.index()) < pop_sizes.size());
|
assert(this->at(offspring_sizes.index()) < offspring_sizes.size());
|
||||||
return pop_sizes.instantiate(this->at(pop_sizes.index()));
|
return offspring_sizes.instantiate(this->at(offspring_sizes.index()));
|
||||||
}
|
}
|
||||||
|
|
||||||
eoReplacement<EOT>& replacement()
|
eoReplacement<EOT>& replacement()
|
||||||
|
|
|
||||||
|
|
@ -47,17 +47,19 @@ public:
|
||||||
*
|
*
|
||||||
* @param foundry The set of algorithms among which to select.
|
* @param foundry The set of algorithms among which to select.
|
||||||
* @param subpb_init An initilizer for sub-problem encoding.
|
* @param subpb_init An initilizer for sub-problem encoding.
|
||||||
* @param pop_size Population size for the sub-problem solver.
|
* @param offspring_size Population size for the sub-problem solver.
|
||||||
* @param subpb_eval The sub-problem itself.
|
* @param subpb_eval The sub-problem itself.
|
||||||
* @param penalization If any solution to the high-level algorithm selection problem is out of bounds, set it to this value.
|
* @param penalization If any solution to the high-level algorithm selection problem is out of bounds, set it to this value.
|
||||||
*/
|
*/
|
||||||
eoEvalFoundryFastGA(
|
eoEvalFoundryFastGA(
|
||||||
eoAlgoFoundryFastGA<SUB>& foundry,
|
eoAlgoFoundryFastGA<SUB>& foundry,
|
||||||
|
const size_t pop_size,
|
||||||
eoInit<SUB>& subpb_init,
|
eoInit<SUB>& subpb_init,
|
||||||
eoPopEvalFunc<SUB>& subpb_eval,
|
eoPopEvalFunc<SUB>& subpb_eval,
|
||||||
const typename SUB::Fitness penalization,
|
const typename SUB::Fitness penalization,
|
||||||
const bool normalized = false
|
const bool normalized = false
|
||||||
) :
|
) :
|
||||||
|
_pop_size(pop_size),
|
||||||
_subpb_init(subpb_init),
|
_subpb_init(subpb_init),
|
||||||
_subpb_eval(subpb_eval),
|
_subpb_eval(subpb_eval),
|
||||||
_foundry(foundry),
|
_foundry(foundry),
|
||||||
|
|
@ -72,7 +74,7 @@ public:
|
||||||
i_muta(foundry.mutations.index()),
|
i_muta(foundry.mutations.index()),
|
||||||
i_repl(foundry.replacements.index()),
|
i_repl(foundry.replacements.index()),
|
||||||
i_cont(foundry.continuators.index()),
|
i_cont(foundry.continuators.index()),
|
||||||
i_pops(foundry.pop_sizes.index())
|
i_offs(foundry.offspring_sizes.index())
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -85,7 +87,7 @@ protected:
|
||||||
const size_t i_muta;
|
const size_t i_muta;
|
||||||
const size_t i_repl;
|
const size_t i_repl;
|
||||||
const size_t i_cont;
|
const size_t i_cont;
|
||||||
const size_t i_pops;
|
const size_t i_offs;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
@ -111,7 +113,7 @@ public:
|
||||||
size_t muta;
|
size_t muta;
|
||||||
size_t repl;
|
size_t repl;
|
||||||
size_t cont;
|
size_t cont;
|
||||||
size_t pops;
|
size_t offs;
|
||||||
|
|
||||||
if(_normalized) {
|
if(_normalized) {
|
||||||
crat = static_cast<size_t>(std::ceil( sol[i_crat] * _foundry.crossover_rates.size() ));
|
crat = static_cast<size_t>(std::ceil( sol[i_crat] * _foundry.crossover_rates.size() ));
|
||||||
|
|
@ -123,7 +125,7 @@ public:
|
||||||
muta = static_cast<size_t>(std::ceil( sol[i_muta] * _foundry.mutations.size() ));
|
muta = static_cast<size_t>(std::ceil( sol[i_muta] * _foundry.mutations.size() ));
|
||||||
repl = static_cast<size_t>(std::ceil( sol[i_repl] * _foundry.replacements.size() ));
|
repl = static_cast<size_t>(std::ceil( sol[i_repl] * _foundry.replacements.size() ));
|
||||||
cont = static_cast<size_t>(std::ceil( sol[i_cont] * _foundry.continuators.size() ));
|
cont = static_cast<size_t>(std::ceil( sol[i_cont] * _foundry.continuators.size() ));
|
||||||
pops = static_cast<size_t>(std::ceil( sol[i_pops] * _foundry.pop_sizes.size() ));
|
offs = static_cast<size_t>(std::ceil( sol[i_offs] * _foundry.offspring_sizes.size() ));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
crat = static_cast<size_t>(std::ceil( sol[i_crat] ));
|
crat = static_cast<size_t>(std::ceil( sol[i_crat] ));
|
||||||
|
|
@ -135,9 +137,9 @@ public:
|
||||||
muta = static_cast<size_t>(std::ceil( sol[i_muta] ));
|
muta = static_cast<size_t>(std::ceil( sol[i_muta] ));
|
||||||
repl = static_cast<size_t>(std::ceil( sol[i_repl] ));
|
repl = static_cast<size_t>(std::ceil( sol[i_repl] ));
|
||||||
cont = static_cast<size_t>(std::ceil( sol[i_cont] ));
|
cont = static_cast<size_t>(std::ceil( sol[i_cont] ));
|
||||||
pops = static_cast<size_t>(std::ceil( sol[i_pops] ));
|
offs = static_cast<size_t>(std::ceil( sol[i_offs] ));
|
||||||
}
|
}
|
||||||
return {crat, crsl, cros, afcr, mrat, musl, muta, repl, cont, pops};
|
return {crat, crsl, cros, afcr, mrat, musl, muta, repl, cont, offs};
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Perform a sub-problem search with the configuration encoded in the given solution
|
/** Perform a sub-problem search with the configuration encoded in the given solution
|
||||||
|
|
@ -160,7 +162,7 @@ public:
|
||||||
double muta = config[i_muta];
|
double muta = config[i_muta];
|
||||||
double repl = config[i_repl];
|
double repl = config[i_repl];
|
||||||
double cont = config[i_cont];
|
double cont = config[i_cont];
|
||||||
double pops = config[i_pops];
|
double offs = config[i_offs];
|
||||||
|
|
||||||
if(
|
if(
|
||||||
0 <= crat and crat < _foundry.crossover_rates.size()
|
0 <= crat and crat < _foundry.crossover_rates.size()
|
||||||
|
|
@ -172,14 +174,13 @@ public:
|
||||||
and 0 <= muta and muta < _foundry.mutations.size()
|
and 0 <= muta and muta < _foundry.mutations.size()
|
||||||
and 0 <= repl and repl < _foundry.replacements.size()
|
and 0 <= repl and repl < _foundry.replacements.size()
|
||||||
and 0 <= cont and cont < _foundry.continuators.size()
|
and 0 <= cont and cont < _foundry.continuators.size()
|
||||||
and 0 <= pops and pops < _foundry.pop_sizes.size()
|
and 0 <= offs and offs < _foundry.offspring_sizes.size()
|
||||||
) {
|
) {
|
||||||
_foundry.select(config);
|
_foundry.select(config);
|
||||||
|
|
||||||
// FIXME should pop_size belong to this eval and moved out from the foundry?
|
|
||||||
// Reset pop
|
// Reset pop
|
||||||
eoPop<SUB> pop;
|
eoPop<SUB> pop;
|
||||||
pop.append( _foundry.pop_size(), _subpb_init);
|
pop.append( _pop_size, _subpb_init);
|
||||||
_subpb_eval(pop,pop);
|
_subpb_eval(pop,pop);
|
||||||
|
|
||||||
// Actually perform a search
|
// Actually perform a search
|
||||||
|
|
@ -194,6 +195,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
const size_t _pop_size;
|
||||||
eoInit<SUB>& _subpb_init;
|
eoInit<SUB>& _subpb_init;
|
||||||
eoPopEvalFunc<SUB>& _subpb_eval;
|
eoPopEvalFunc<SUB>& _subpb_eval;
|
||||||
eoAlgoFoundryFastGA<SUB>& _foundry;
|
eoAlgoFoundryFastGA<SUB>& _foundry;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue