Polyalgorithms and multistart for nonlinear problems
Source:R/nonlinear-polyalg.R
nonlinear_polyalgorithms.RdNonlinearSolvePolyAlgorithm(algs) tries the algorithms in algs in
turn, each from the initial guess, and returns the first successful
solution ("StalledSuccess" does not count); when none succeeds it
returns the one with the smallest residual (infinity norm for
NonlinearProblem, 2-norm for least squares). The statistics in
sol$stats add up the work of every stage tried. When every stage handles
bounds natively an initial guess outside the box is projected onto it.
Usage
NonlinearSolvePolyAlgorithm(algs, start_index = 1L, store_original = FALSE)
FastShortcutBoundedPolyalg(
concrete_jac = NULL,
linsolve = NULL,
autodiff = NULL,
jvp_autodiff = NULL,
vjp_autodiff = NULL,
gtol = NULL,
must_support_postcondition = FALSE
)
SobolMultistart(
alg = FastShortcutBoundedPolyalg(),
nstarts = 16L,
search_scale = 10,
early_exit = TRUE,
restoration = TRUE,
restoration_alg = NULL
)Arguments
- algs
A list of algorithms.
- start_index
The stage to start at.
- store_original
Keep the solution of the winning stage in
sol$original.- concrete_jac, linsolve, autodiff, jvp_autodiff, vjp_autodiff, gtol
Passed to the stages.
- must_support_postcondition
Only use stages that apply the
postconditioncorrector.- alg
The local algorithm of
SobolMultistart().- nstarts
The number of start points, the initial guess included.
- search_scale
Half width factor of the sampling window of unbounded components.
- early_exit
Stop at the first successful start.
- restoration
Continue stalled starts without the bounds.
- restoration_alg
The algorithm of the restoration probes (default
alg).
Details
FastShortcutBoundedPolyalg() is the polyalgorithm of NonlinearSolve for
problems with bounds: BoundedTrustRegion(), then
BoundedGaussNewton() with its projected line search (only the first
with must_support_postcondition = TRUE).
SobolMultistart(alg) runs alg from nstarts start points: the initial
guess, then points of a Sobol sequence over the box (components with an
infinite bound are sampled search_scale * max(1, |u0_i|) around
u0_i). With early_exit the first successful solve is returned;
otherwise every start runs and the feasible solution with the smallest
residual 2-norm is returned. With restoration, a start that stalls on an
active bound is continued without the bounds that are not fixed: a root
found inside the box replaces the stalled result, and a root outside it
shows that the stalled point is a genuine constrained solution (a warning
says so). When no start succeeds the retcode is "Stalled". This is the
default of NonlinearSolve for problems with lb or ub, wrapping
FastShortcutBoundedPolyalg(). The Sobol points (Joe and Kuo direction
numbers, as Sobol.jl) are available for up to 1024 unknowns.
Examples
f <- function(u, p) c(10 * (u[2] - u[1] * u[1]), 1 - u[1])
prob <- NonlinearProblem(f, u0 = c(-1.2, 1), lb = c(-2, -2), ub = c(2, 2))
sol <- solve(prob, NonlinearSolvePolyAlgorithm(list(Dogbox(), TrustRegionReflective())))
sol$u; sol$stats$nf
#> [1] 1 1
#> [1] 17
solve(prob, FastShortcutBoundedPolyalg())$retcode
#> [1] "Success"
solve(prob, SobolMultistart(nstarts = 4))$u
#> [1] 1 1