Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to pass options to SciPy minimizers #1060

Merged
merged 17 commits into from
Dec 13, 2024

Conversation

lvarriano
Copy link
Contributor

The various SciPy minimizers have different options that can be adjusted to change and improve performance. Presently, the iminuit API does not allow passing options to these minimizers, which limits their usefulness for some minimization problems (specifically mine). I added a parameter to minuit.scipy() to allow passing options to scipy.optimize.minimize(). It keeps the existing default options that were being passed and allows for these defaults to be overwritten by the user.

src/iminuit/minuit.py Outdated Show resolved Hide resolved
src/iminuit/minuit.py Outdated Show resolved Hide resolved
src/iminuit/minuit.py Outdated Show resolved Hide resolved
src/iminuit/minuit.py Outdated Show resolved Hide resolved
src/iminuit/minuit.py Outdated Show resolved Hide resolved
tests/test_scipy.py Outdated Show resolved Hide resolved
@HDembinski
Copy link
Member

Thanks, I am happy to include this patch, after some refinement.

lvarriano and others added 3 commits December 5, 2024 07:42
Co-authored-by: Hans Dembinski <HDembinski@users.noreply.github.com>
Co-authored-by: Hans Dembinski <HDembinski@users.noreply.github.com>
src/iminuit/minuit.py Outdated Show resolved Hide resolved
@HDembinski
Copy link
Member

@lvarriano Are you still working on that test? Looks like this is almost done and it would be nice to merge soon.

The test should be something simple, but you would certainly know better. You said that by setting certain options you were able to improve performance. I suggest to add a toy example where this can be seen. Performance would be measured in numbers of function calls until convergence.

@lvarriano
Copy link
Contributor Author

Sorry for the delay! We've added a simple test to show the precision of the result improves when the SciPy tolerances are adjusted. This is a stand-in for a problem we're having performing extended unbinned analyses with low amounts of data, which is typical for our experiment.

@HDembinski
Copy link
Member

Thanks, that is a good demonstration. Without options you cannot manipulate the stopping criterion. Minuit has its own tolerance, but it cannot be easily mapped to the multiple tolerances that scipy offers.

@HDembinski HDembinski merged commit 3d3e14e into scikit-hep:develop Dec 13, 2024
9 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.

3 participants