Skip to content

Commit

Permalink
Fix Nelder-Mead init_simplex_corner creation
Browse files Browse the repository at this point in the history
As pointed out in #175, the way `self.init_simplex_corner` is created for `NelderMeadLearner` is problematic because it is set equal to `self.min_boundary`. This means that when `self.init_simplex_corner` is later modified, `self.min_boundary` is modified as well. This PR resolves the issue using the approach suggested in #175, namely by assigning a copy of `self.min_boundary` to `self.init_simplex_corner` rather than assigning the original array itself.
  • Loading branch information
zakv committed Feb 25, 2024
1 parent 9331cf3 commit 64452ee
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mloop/learners.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ def __init__(self,
if initial_simplex_corner is None:
diff_roll = (self.diff_boundary - self.init_simplex_disp) * mlu.rng.random(self.num_params)
diff_roll[diff_roll==float('+inf')]= 0
self.init_simplex_corner = self.min_boundary
self.init_simplex_corner = np.copy(self.min_boundary)
self.init_simplex_corner[self.init_simplex_corner==float('-inf')]=0
self.init_simplex_corner += diff_roll
else:
Expand Down

0 comments on commit 64452ee

Please sign in to comment.