Skip to content

Fixed minimizer behaviour on exceeded iterations#231

Open
rozyczko wants to merge 9 commits intodevelopfrom
consistent_minimizers
Open

Fixed minimizer behaviour on exceeded iterations#231
rozyczko wants to merge 9 commits intodevelopfrom
consistent_minimizers

Conversation

@rozyczko
Copy link
Copy Markdown
Member

@rozyczko rozyczko commented Apr 9, 2026

This adds improvements to the fitting result reporting and evaluation tracking across all minimizer engines, ensuring that the number of function evaluations and relevant messages are consistently captured and propagated.

  • All minimizer engines (Bumps, DFO, LMFit) now populate n_evaluations (number of function evaluations) and message (status or error message) fields in FitResults, and these fields are propagated in multi-dataset fitting.

  • The Bumps minimizer uses a new _EvalCounter wrapper to count function evaluations and detect when the maximum evaluation budget is reached, updating the success flag and message accordingly.

  • The DFO minimizer now raises FitError only for real failures, and considers both success and max function evaluation warnings as successful fits, improving error reporting and testability.

@rozyczko rozyczko added [scope] enhancement Adds/improves features (major.MINOR.patch) [priority] medium Normal/default priority labels Apr 9, 2026
Copy link
Copy Markdown
Member

@henrikjacobsenfys henrikjacobsenfys left a comment

Choose a reason for hiding this comment

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

Looks good to me apart from a tiny nitpick.

This may also be a good opportunity to make a __repr__ method for the FitResults class?

Comment thread tests/integration/fitting/test_fitter.py
@rozyczko
Copy link
Copy Markdown
Member Author

rozyczko commented Apr 13, 2026

This may also be a good opportunity to make a __repr__ method for the FitResults class?

Good idea!
Added these

   lines = [
        f"FitResults(success={self.success}",
        f"  n_pars={self.n_pars}, n_points={len(self.x)}",
        f"  chi2={self.chi2:.4g}, reduced_chi={self.reduced_chi:.4g}",
        f"  n_evaluations={self.n_evaluations}",
        f"  minimizer={self.minimizer_engine.__name__ if self.minimizer_engine else None}",
    ]

Comment thread src/easyscience/fitting/minimizers/utils.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[priority] medium Normal/default priority [scope] enhancement Adds/improves features (major.MINOR.patch)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants