Commit f350ee7f authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

optimizer: make bastert-insertion more random

parent 605afb6b
......@@ -376,14 +376,32 @@ public:
if (ctx.crossover_bastert_insertion(ctx.rng)) {
int first = m_indices[choose_a_solution(ctx)];
crossover(ctx, x, m_data[first].x, m_bastert);
to_log(stdout,
7u,
"- crossover between {} ({}) and bastert\n",
first,
m_data[first].value);
std::bernoulli_distribution b(0.5);
if (b(ctx.rng)) {
if (b(ctx.rng)) {
crossover(ctx, x, m_data[first].x, m_bastert);
to_log(stdout,
7u,
"- crossover between {} ({}) and bastert\n",
first,
m_data[first].value);
} else {
m_data[first].x = m_bastert;
}
} else {
init_with_random(m_random, ctx.rng, x.size(), 0.5);
if (b(ctx.rng)) {
crossover(ctx, x, m_data[first].x, m_random);
to_log(stdout,
7u,
"- crossover between {} ({}) and random\n",
first,
m_data[first].value);
} else {
m_data[first].x = m_random;
}
}
} else {
int first = m_indices[choose_a_solution(ctx)];
int second = m_indices[choose_a_solution(ctx)];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment