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

MAINT: optimize._chandrupatla: reduce xatol #20501

Merged
merged 3 commits into from Apr 30, 2024

Conversation

mdhaber
Copy link
Contributor

@mdhaber mdhaber commented Apr 17, 2024

Reference issue

NA

What does this implement/fix?

The default absolute x-tolerance on the bracketing (scalar) root finders is quite large, which can lead to premature termination when the root is near zero. If the root is near zero, we can and probably should find the root more precisely. In preparation for a PR to make this feature public, this PR reduces the absolute x-tolerance for _chandrupatla.

Additional information

Before merge:
@steppi Should the default maximum number of iterations be increased? Assuming the algorithm resorts to bisection, it takes 2048 iterations to converge from the largest possible floating point bracket to the smallest normal floating point bracket. The current default is only 100 iterations, so we run the risk of converging due to the iteration limit well before successful convergence would occur.

@mdhaber mdhaber added enhancement A new feature or improvement scipy.optimize labels Apr 17, 2024
@mdhaber mdhaber requested a review from steppi April 17, 2024 06:11
@github-actions github-actions bot added the maintenance Items related to regular maintenance tasks label Apr 17, 2024
@mdhaber mdhaber marked this pull request as ready for review April 23, 2024 17:17
@mdhaber mdhaber requested a review from andyfaff as a code owner April 23, 2024 17:17
Copy link
Contributor

@steppi steppi left a comment

Choose a reason for hiding this comment

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

I think it's sensible to try to compute roots near zero more accurately in the default case. A roughly 20-fold increase in the maximum number of iterations for dtype double is not so bad really, unless someone is using this with a very costly function.

I saw that you set the xatol and xrtol based on the dtype so had one suggestion to do this for maxiter as well. On the whole I think this looks good.

scipy/optimize/_chandrupatla.py Outdated Show resolved Hide resolved
@steppi steppi merged commit fa9852c into scipy:main Apr 30, 2024
30 checks passed
@tylerjereddy tylerjereddy added this to the 1.14.0 milestone Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature or improvement maintenance Items related to regular maintenance tasks scipy.optimize
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants