I'm using scipy to find the root(s) of a vector function and I want to have it ignore non-convergence. Basically, I set the function tolerance and maxiter, but if it doesn't converge within those constraints I don't really care. I'm using scipy.optimize.newton_krylov
and setting the arguments maxiter
and f_tol
. I just don't want non-convergence to raise an exception.
EDIT: I was a little unclear. I want to get the solution from the optimizer even if it doesn't "converge." I can handle this with a try/except
, but this is slow. It would require re-running the optimizer, which is computationally expensive. I know (for my problem) a good solution will be found after maxiter
iterations, but a good enough solution can often be found if |F| < f_tol
, which can cut down on the total number of iterations by a lot and save lots of time.