Skip to content

Commit

Permalink
Updated python to work with new variation interface
Browse files Browse the repository at this point in the history
  • Loading branch information
gAldeia committed Sep 23, 2024
1 parent df17aa3 commit 8a1d2f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions pybrush/DeapEstimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ def assign_fit(ind, validation=False):

toolbox.register("Clone", lambda ind: self.Individual(ind.program.copy()))

toolbox.register("mate", self.variator_.cross)
toolbox.register("mutate", self.variator_.mutate)
# crossover and mutation will return a tuple, the individual and context. Here
# we are interested only in the context part
toolbox.register("mate", lambda ind1, ind2: self.variator_.cross(ind1, ind2)[0])
toolbox.register("mutate", lambda ind: self.variator_.mutate(ind, "")[0])
toolbox.register("vary_pop", lambda pop: self.variator_.vary_pop(pop, self.parameters_))

# When solving multi-objective problems, selection and survival must
Expand Down
2 changes: 1 addition & 1 deletion src/vary/variation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ std::tuple<std::optional<Individual<T>>, VectorXf> Variation<T>::mutate(const In
{
if (choice.empty())
{
std::cout << "Will sample a mut choice" << std::endl;
// std::cout << "Will sample a mut choice" << std::endl;
auto options = parameters.mutation_probs;

bool all_zero = true;
Expand Down

0 comments on commit 8a1d2f4

Please sign in to comment.