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

don't propagate non-finite residuals #230

Open
tpapp opened this issue Jan 16, 2020 · 1 comment
Open

don't propagate non-finite residuals #230

tpapp opened this issue Jan 16, 2020 · 1 comment

Comments

@tpapp
Copy link

tpapp commented Jan 16, 2020

Problem

When the residuals are not finite (eg Inf or NaN), the solver propagates them into the next call, which usually leads to things silently iterating until the maximum number of iterations are exhausted, without a warning.

An MWE is

using NLsolve

function f(x)
    any(isnan, x) && printstyled("things went south\n"; color = :red)
    @show x
    map(x -> 0.2 < abs(x) < 1 ? oftype(x, NaN) : x^3, x)
end

nlsolve(f, fill(1.1, 3), autodiff = :forward, iterations = 50, method = :newton)

Not sure if #228 is related.

Suggestions

  1. At least a sanity check terminating the solver and returning as non-converged would avoid doing meaningless iterations. This would be a quick fix.

  2. A heuristic algorithm could potentially recover from this by shrinking the steps taken until everything is finite, but that's more complex.

@pkofod
Copy link
Member

pkofod commented Jan 23, 2020

If the static line search is used, this should definitely be caught somewhere, and the solver should stop. If a line search is used, it will keep halving the steps until a finite value is encountered. Thanks

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

No branches or pull requests

2 participants