Skip to content

Always use an initial guess in bounds for the sources#44

Merged
lispandfound merged 2 commits intomainfrom
source_bounds_check
Jun 4, 2025
Merged

Always use an initial guess in bounds for the sources#44
lispandfound merged 2 commits intomainfrom
source_bounds_check

Conversation

@lispandfound
Copy link
Copy Markdown
Contributor

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.

@lispandfound lispandfound requested a review from Copilot May 16, 2025 01:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(

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]),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@lispandfound lispandfound merged commit 0c5d6bc into main Jun 4, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants