BUG: line_search_wolfe2 fails to converge due to a wrong condition #20340
Labels
defect
A clear bug or issue that prevents SciPy from being installed or used as expected
scipy.optimize
Milestone
Describe your issue.
In scipy/optimize/_linesearch.py#L330, there is a function called scalar_search_wolfe2 that finds alpha that satisfies strong Wolfe conditions. In L403, there is a condition to clip the initial step length alpha1 no more than the maximum step length amax
In the main loop of the algorithm (L416):
When i == 1, alpha0 will be alpha1, which could be amax, if alpha was clipped. This leads to an error
msg = "The line search algorithm could not find a solution " + \ "less than or equal to amax: %s" % amax
. Therefore, the conditionif alpha1 == 0 or (amax is not None and alpha0 == amax):
should be avoided to check in this iteration.Reproducing Code Example
Error message
LineSearchWarning: The line search algorithm did not converge alpha, *_ = line_search(self._loss, self._gradient, w, d, args=(A, Pindicate, Zindicate, cs), amax = amax, maxiter=40)
SciPy/NumPy/Python version and system information
The text was updated successfully, but these errors were encountered: