Skip to content

Commit

Permalink
Fixed wrong context being used to update crossover
Browse files Browse the repository at this point in the history
  • Loading branch information
gAldeia committed Oct 3, 2024
1 parent 4ccf09c commit fb776c4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/vary/variation.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,23 @@ class Variation {
*r.select_randomly(parents.begin(), parents.end())];

vector<Individual<T>> ind_parents;
VectorXf context = get_context(mom.program.Tree,
VectorXf root_context = get_context(mom.program.Tree,
mom.program.Tree.begin());

string choice = this->variation_bandit.choose(context);
VectorXf context;
string choice = this->variation_bandit.choose(root_context);

if (choice == "cx")
{
const Individual<T>& dad = pop[
*r.select_randomly(parents.begin(), parents.end())];


// std::cout << "Performing crossover" << std::endl;
auto variation_result = cross(mom, dad);
ind_parents = {mom, dad};
tie(opt, context) = variation_result;

context = root_context;
}
else
{
Expand Down

0 comments on commit fb776c4

Please sign in to comment.