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
BUG: least_squares
with method='trf'
with initial params at bound and solution outside of bounds results in division by zero warning
#19102
Labels
defect
A clear bug or issue that prevents SciPy from being installed or used as expected
scipy.optimize
Milestone
Comments
JoepVanlier
added
the
defect
A clear bug or issue that prevents SciPy from being installed or used as expected
label
Aug 21, 2023
JoepVanlier
changed the title
BUG: Trust region reflective option results in division by zero warning
BUG: Trust region reflective option with initial guess at bound results in division by zero warning
Aug 21, 2023
JoepVanlier
changed the title
BUG: Trust region reflective option with initial guess at bound results in division by zero warning
BUG: Aug 21, 2023
least_squares
with method='trf'
with initial params at bound and solution outside of bounds results in division by zero warning
This is a duplicate of my #19103. In my issue, I pinpoint what change has caused this problem, what change to the source code would satisfy the initial problem as well as the current problem, and I show a test case in which there is even a RuntimeError instead of a RuntimeWarning. |
Hit by this too. Hope it gets fixed quickly. |
hwalinga
added a commit
to hwalinga/scipy
that referenced
this issue
Aug 22, 2023
PR scipy#18896 removed make_strictly_feasible because it makes solutions worse if they are close to the boundary. However, the downstream algorithm that eventually solves the optimization problem has some trouble with starting points that are on the boundaries of a bounded optimization problem. This either results in division by zero warnings, see scipy#19102, or in failure of finding the correct solution at all, which is added as a regression test in this commit. This PR brings back make_strictly_feasible but with the smallest possible step from the boundary a floating point allows by setting rstep=0 on the function make_strictly_feasible, which uses np.nextafter to find such a point, hereby respecting the strictly feasible point condition and minimizing boundary effects. See strictly feasible points in interior-point methods for more context https://nmayorov.wordpress.com/2015/06/19/trust-region-reflective-algorithm/
hwalinga
added a commit
to hwalinga/scipy
that referenced
this issue
Aug 23, 2023
PR scipy#18896 removed make_strictly_feasible because it makes solutions worse if they are close to the boundary. However, the downstream algorithm that eventually solves the optimization problem has some trouble with starting points that are on the boundaries of a bounded optimization problem. This either results in division by zero warnings, see scipy#19102, or in failure of finding the correct solution at all, which is added as a regression test in this commit. This PR brings back make_strictly_feasible but with the smallest possible step from the boundary a floating point allows by setting rstep=0 on the function make_strictly_feasible, which uses np.nextafter to find such a point, hereby respecting the strictly feasible point condition and minimizing boundary effects. See strictly feasible points in interior-point methods for more context https://nmayorov.wordpress.com/2015/06/19/trust-region-reflective-algorithm/
Confirmed as fixed by #19111 |
tylerjereddy
pushed a commit
to tylerjereddy/scipy
that referenced
this issue
Sep 21, 2023
PR scipy#18896 removed make_strictly_feasible because it makes solutions worse if they are close to the boundary. However, the downstream algorithm that eventually solves the optimization problem has some trouble with starting points that are on the boundaries of a bounded optimization problem. This either results in division by zero warnings, see scipy#19102, or in failure of finding the correct solution at all, which is added as a regression test in this commit. This PR brings back make_strictly_feasible but with the smallest possible step from the boundary a floating point allows by setting rstep=0 on the function make_strictly_feasible, which uses np.nextafter to find such a point, hereby respecting the strictly feasible point condition and minimizing boundary effects. See strictly feasible points in interior-point methods for more context https://nmayorov.wordpress.com/2015/06/19/trust-region-reflective-algorithm/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
defect
A clear bug or issue that prevents SciPy from being installed or used as expected
scipy.optimize
Describe your issue.
Not sure if this is considered a regression, but since
1.11.2
, usingmethod='trf'
onscipy.optimize.least_squares
results in a warning about a division by zero when the initial guess is initially exactly at the bound while the solution is outside of the bounds.What I expected would be no warning with the resulting optimized value being the value at the bound.
Reproducing Code Example
Error message
SciPy/NumPy/Python version and system information
The text was updated successfully, but these errors were encountered: