Skip to content

Commit

Permalink
Fixed incorrect variable being used in mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
gAldeia committed Aug 15, 2023
1 parent 7ea04d3 commit efe419e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/brush/deap_api/nsga2.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ def calculate_statistics(ind):
offspring = []

for ind1, ind2 in zip(parents[::2], parents[1::2]):
off1, off2 = None, None
if rnd_flt() < CXPB:
off1, off2 = toolbox.mate(ind1, ind2)
else:
off1 = toolbox.mutate(off1)
off2 = toolbox.mutate(off2)
off1 = toolbox.mutate(ind1)
off2 = toolbox.mutate(ind2)

# avoid inserting empty solutions
if off1 is not None: offspring.extend([off1])
Expand Down
2 changes: 1 addition & 1 deletion src/brush/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def fit(self, X, y):
"""
_brush.set_params(self.get_params())

if self.random_state != None:
if self.random_state is not None:
_brush.set_random_state(self.random_state)

self.data_ = self._make_data(X,y, validation_size=self.validation_size)
Expand Down

0 comments on commit efe419e

Please sign in to comment.