fix: ensure minimum sigma of 1.0 in Hill Climbing for fine search grids (#86)#99
Open
mohammed18salah wants to merge 1 commit into
Open
Conversation
When epsilon is very small and the search grid is fine (e.g. np.arange(-10, 10, 0.01)), the noise sigma calculated as max_positions * epsilon can fall well below 0.5. Since discrete positions are represented as integer indices and noise is rounded, a sigma < 0.5 causes the noise to round to zero on almost every step, making the optimizer permanently stuck at its initial position. This fix enforces a minimum sigma of 1.0 (one index step), ensuring the optimizer always has a chance to move to an adjacent grid point, regardless of epsilon magnitude. Fixes SimonBlanke#86
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When epsilon is very small and the search grid is fine (e.g. np.arange(-10, 10, 0.01)), the noise sigma calculated as max_positions * epsilon can fall well below 0.5. Since discrete positions are represented as integer indices and noise is rounded, a sigma < 0.5 causes the noise to round to zero on almost every step, making the optimizer permanently stuck at its initial position.
This fix enforces a minimum sigma of 1.0 (one index step), ensuring the optimizer always has a chance to move to an adjacent grid point, regardless of epsilon magnitude.
Fixes #86
Motivation
When using fine search grids (e.g.,
np.arange(-10, 10, 0.01)) which have thousandsof discrete index positions, setting a small
epsiloncauses the noise sigma(
max_positions * epsilon) to fall below 0.5. This makes the rounding of discretenoise always evaluate to zero, leaving the optimizer permanently stuck at its starting
position and unable to explore the search space at all.
Description of the changes
The fix is a single-line change in
_iterate_discrete_batchinsidehill_climbing_optimizer.py.Before:
sigmas = maximum(sigmas, 1e-10) # Too small — still causes stuck behavior
After:
sigmas = maximum(sigmas, 1.0) # Ensures at least 1 index step of noise
By enforcing a minimum sigma of 1.0 (one index unit), the Gaussian noise generator
will always have a non-zero probability of producing a value >= 0.5, which allows
the optimizer to step to an adjacent grid point. This preserves the original intent
of
epsilon(controlling exploration scale) while preventing a complete halt whenepsilonis very small.Tested on: sphere function with
np.arange(-10, 10, 0.01)(2000 indices per dim).