Solver Status

In SimpleSolvers we can use the SimpleSolvers.NonlinearSolverStatus to provide a diagnostic tool for a NonlinearSolver. We first make an instance of NonlinearProblem:

x = [3., 1.3]
f = x -> tanh.(x)
F!(y, x, params) = y .= f(x)
nlp = NonlinearProblem(F!, x, f(x))
NonlinearProblem{Float64, false, typeof(Main.F!), Missing, Vector{Float64}, Vector{Float64}, Matrix{Float64}}(Main.F!, missing, [NaN, NaN], [NaN NaN; NaN NaN], [NaN, NaN], [NaN, NaN])

We now create an instance of NewtonSolver and allocate a SimpleSolvers.NonlinearSolverStatus:

solver = NewtonSolver(x, f(x); F = F!)
i=   0,
x= NaN,
f= NaN,
rxₐ= NaN,
rfₐ= NaN

Note that all variables are initialized with NaNs.

For the first step we therefore have to call update![1]:

params = nothing
update!(solver, x, params)
i=   0,
x=3.000000e+00,
f=9.950548e-01,
rxₐ= NaN,
rfₐ=1.316321e+00

Note that the residuals are still NaNs however as we need to perform at least two updates in order to compute them. As a next step we write:

x = [2., 1.2]
update!(solver, x, params)
i=   0,
x=2.000000e+00,
f=9.640276e-01,
rxₐ=1.004988e+00,
rfₐ=1.274492e+00