Skip to contents

Trace levels for the trace_level option of solve() with the bounded solvers (TrustRegionReflective() and the others, and BoundedTrustRegion()) and with NewtonRaphson(), GaussNewton(), SimpleTrustRegion(), Broyden(), Klement() and LevenbergMarquardt(). show_trace = TRUE prints one line per step, store_trace = TRUE keeps the entries in sol$trace. TraceMinimal() records the iteration, the residual norm (infinity norm, or 2-norm for least squares) and the 2-norm of the step; TraceWithJacobianConditionNumber() adds the condition number of the Jacobian (-1 when the solver keeps no Jacobian, as in Julia) and TraceAll() also stores u, fu, the step and the Jacobian. A single freq sets both frequencies.

Usage

TraceMinimal(freq = NULL, print_frequency = 1L, store_frequency = 1L)

TraceWithJacobianConditionNumber(
  freq = NULL,
  print_frequency = 1L,
  store_frequency = 1L
)

TraceAll(freq = NULL, print_frequency = 1L, store_frequency = 1L)

Arguments

freq

Print and store frequency.

print_frequency, store_frequency

Print every so many steps, store every so many steps.

Value

A NonlinearSolveTracing object.

Examples

f <- function(u, p) c(u[1] * u[1] - 2, u[2] - 1)
prob <- NonlinearProblem(f, u0 = c(1, 0), lb = c(0, 0), ub = c(2, 2))
sol <- solve(prob, Dogbox(), store_trace = TRUE, trace_level = TraceMinimal())
sol$trace
#> ----    	-------------       	-----------         
#> Iter    	f(u) inf-norm       	Step 2-norm         
#> ----    	-------------       	-----------         
#> 0       	1.00000000e+00      	0.00000000e+00      
#> 1       	2.50000000e-01      	1.11803399e+00      
#> 2       	6.94444445e-03      	8.33333333e-02      
#> 3       	6.00730488e-06      	2.45098039e-03      
#> 4       	4.51061410e-12      	2.12389982e-06      
#> 5       	4.44089210e-16      	1.59472435e-12