Always use an initial guess in bounds for the sources#44
Merged
lispandfound merged 2 commits intomainfrom Jun 4, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Addresses the issue where the default optimization starting point (0.5,0.5,…,0.5) could lie outside user-specified bounds by always initializing the solver within the provided ranges.
- Compute midpoint-based initial guesses for both source A and source B parameters.
- Replace the hardcoded default
[1/2, 1/2, 1/2, 1/2]with the newly computed initial points.
Comments suppressed due to low confidence (2)
source_modelling/sources.py:1422
- Consider adding a unit test for cases where the default (0.5, 0.5, 0.5, 0.5) lies outside the provided bounds to ensure the solver correctly uses the new midpoint-based initial guesses.
initial_point_a = (
source_modelling/sources.py:1421
- [nitpick] Add a brief comment above the initial-point computation explaining that you’re choosing the midpoint of each parameter’s bounds as the initial guess to guarantee feasibility.
res = sp.optimize.least_squares(
joelridden
approved these changes
May 25, 2025
sungeunbae
reviewed
May 26, 2025
| res = sp.optimize.least_squares( | ||
| fault_coordinate_distance, | ||
| np.array([1 / 2, 1 / 2, 1 / 2, 1 / 2]), | ||
| np.array([*initial_point_a, *initial_point_b]), |
sungeunbae
approved these changes
May 26, 2025
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.
Default initial guess was (1/2,1/2), which doesn't work if the constraints on the optimisation are say (0.7-0.9, 0.6-1.0), as then the default optimisation point is not in the bounds for the process.