Customization

Subtypes of Downhill.Wrapper are used to add custom behavior to optimization, such as stopping after reaching certain criteria, limiting timesteps etc.

A wrapper around an object of AbstractOptBuffer type should at a minimum provide the base_method(M::Wrapper) to return the wrapped object.

The wrappers can modify the optimization behavior by overloading the following methods:

Downhill.init!Function

optfn! must be the 3-arg closure that computes fdf(x + α*d) and overwrites M's gradient

source
Downhill.callfn!Function
callfn!(fdf, M::AbstractOptBuffer, x, α, d)

Return the value of fdf(x + α * d) overwriting the internal buffers of M as needed. fdf(x, g) must return a tuple (f(x), ∇f(x)) and, if g is mutable, overwrite it with the gradient (see optimize!).

source
Downhill.reset!Function
reset!(M::AbstractOptBuffer, args...; kwargs...)

Reset the solver parameters to the default (or to specific value – see the documentation for the specific types).

Each method has to implement a parameter-free reset!(M) method.

source
Downhill.step!Function
step!(fdf, M::AbstractOptBuffer; kw...)

Make one iteration of optimization routine from the current state of M using fdf as the objective function and modifying the internal buffers as needed.

source
Downhill.stopcondFunction
stopcond(M::AbstractOptBuffer)

Decide if the optimization should be stopped from the state of M.

source
Downhill.conv_successFunction
conv_success(M::AbstractOptBuffer)

Decide if the optimization has converged from the state of M (useful to distinguish between stopping by convergence and stopping by iterations count when the convergence has been achieved on the limiting iteration).

source

Predefined Wrappers

Downhill.BasicConvergenceStatsType
BasicConvergenceStats

Wrapper type to provide basic stop conditions: magnitude of gradient is less than the specified value, objective function call count exceeds threshold, iteration count exceeds threshold.

source
Downhill.ConstrainStepSizeType
ConstrainStepSize

Wrapper type to limit step sizes attempted in optimization, given a function (origin, direction) -> max_step.

source