Manopt Solver Callbacks
The callback functionality is meant to provide a user with direct access to the solver (problem and state) at certain points of a solver run to inspect or modify it.
Functions
Manopt.provided_callbacks — Method
provided_callbacks(state_type::Type{S}) where {S<:AbstractManoptSolverState})For a solver of type S return the callbacks the solver provides, i.e. all ones that are called during the solver run. This function returns a vector Symbols representing the hooks. These can be kays in a dictionary of callbacks.
Internal functions
Manopt._callbacks_summary — Method
_callbacks_summary(state::AbstractManoptSolverState)Generate callback summary for a given solver state s. This function returns a string that contains the active callbacks in the solver state. If no callbacks are active, an empty string is returned.
Manopt.active_callbacks — Method
active_callbacks(state::AbstractManoptSolverState)For a given state, indicate, which callbacks are in use, i.e. stored and also called from this solver.
See also: provided_callbacks.
Manopt.callback — Method
callback(name::Symbol, problem::AbstractManoptProblem, state::AbstractManoptState, iteration::Int)Perform a callback.
This function performs a call to both possible approaches
- if a callback exists in the dictionary under the symbol
nameit is called with the parametersproblem, state, iteration - if a callback exists in the dictionary that shall be called
:Anytime, this one is called withname, problem, state, iteration
Manopt.get_callbacks — Method
get_callbacks(state::AbstractManoptSolverState)Access the callbacks dictionary of the AbstractManoptSolverState state.
Manopt.process_callbacks_arg — Function
process_callbacks_arg(callback, statetype = missing)Passing a single callback handles this as if it is an array of length one with this element in the process_callbacks_arg array case.
Manopt.process_callbacks_arg — Function
process_callbacks_arg(callbacks::Vector, statetype=missing)
process_callbacks_arg(callbacks::Dict, statetype=missing) = callbacksGiven a vector callbacks a user has passed to a solver, this helper function processes the vector in the following way
- a pair
:Hook => fctis kept as is, where thefct` can also be some callable structure - a single element
functionis turned into:Any => fctallowing the case a single callback to be specified just with the function - a pair
[Hook1, Hook2] => fctis a shortcut for an array of pairs and split into these here.
The result is then wrapped into a dictionary. Be aware that from an array of pairs this function reduces, the dictionary “takes” the last :Hook pair as the entry in the dictionary. This function does not check for duplicates.
This function keeps a dictionary unchanged. Hence they are only processed once even if this function is applied multiple times.
If a statetype is provided, the final dictionary of callbacks is validated against the provided callback hooks by that state and a warning is issued if there are hooks that do not have an effect.