The Manopt.jl Solver state
The solver state represents all parameters that determine the solver's setup as well as interim memory, e.g. to avoid allocations or to keep certain variables in between iterations. These should also allow insight into how the solver is performing.
A state contains callbacks and a stopping criterion as mandatory elements and usually the iterate is stored in the field p. A state can be decorated to add functionality.
Further elements a state can use are:
Abstract state
Manopt.AbstractGradientSolverState — Type
AbstractGradientSolverState <: AbstractManoptSolverStateA generic AbstractManoptSolverState type for gradient based solver states.
It assumes that
- the iterate is stored in the field
p - the gradient at
pis stored inX.
See also
GradientDescentState, StochasticGradientDescentState, SubGradientMethodState, QuasiNewtonState.
Manopt.AbstractHessianSolverState — Type
AbstractHessianSolverState <: AbstractGradientSolverStateAn AbstractManoptSolverState type to represent algorithms that employ the Hessian. These states are assumed to have a field X to store the current gradient $\operatorname{grad}f(p)$.
Manopt.AbstractManoptSolverState — Type
AbstractManoptSolverStateA general super type for all solver states.
Fields
The following fields are assumed to be available by default. If you use different ones, adapt the access functions get_iterate, get_stopping_criterion, and get_callbacks accordingly.
p::P: a point on the manifold $\mathcal{M}$ storing the current iteratecallbacks::D: provided callback functions given as a dictionary with symbols as keysstop::StoppingCriterion: a functor indicating that the stopping criterion is fulfilled
Manopt.AbstractPrimalDualSolverState — Type
AbstractPrimalDualSolverStateA general type for all primal dual based states to be used within primal dual based algorithms.
Manopt.AbstractRestartCondition — Type
AbstractRestartConditionA general struct that indicates when to restart. It is used within the ConjugateGradientDescentState.
It is implemented to work as a functor (problem, state, iteration) -> true|false and what is done in the restart case (true) is decided by the single solver.
Access functions
Manopt.get_count — Method
get_count(ams::AbstractManoptSolverState, ::Symbol)Obtain the count for a certain countable size, for example the :Iterations. This function returns 0 if there was nothing to count.
Available symbols from within the solver state:
:Iterationsis passed on to thestopfield to obtain the iteration at which the solver stopped.
Manopt.get_gradient — Method
get_gradient(agst::AbstractGradientSolverState)Return the gradient stored within the gradient solver state. The default returns agst.X.
Manopt.get_gradient — Method
get_gradient(s::AbstractManoptSolverState)Return the (last stored) gradient within the AbstractManoptSolverState s. By default this also undecorates the state beforehand.
Manopt.get_iterate — Method
get_iterate(agst::AbstractGradientSolverState)Return the iterate stored within the gradient solver state. The default returns agst.p.
Manopt.get_iterate — Method
get_iterate(state::AbstractManoptSolverState)Return the (last stored) iterate within the AbstractManoptSolverState state. This should usually refer to a single point on the manifold the solver is working on.
By default this also removes all decorators of the state beforehand.
Manopt.get_solver_result — Method
get_solver_result(state::AbstractManoptSolverState)
get_solver_result(tos::Tuple{AbstractManifoldObjective,AbstractManoptSolverState})
get_solver_result(objective::AbstractManifoldObjective, state::AbstractManoptSolverState)
get_solver_result(problem::AbstractManoptProblem, state::AbstractManoptSolverState)Return the final result after all iterations that is stored within the AbstractManoptSolverState state, which was modified during the iterations.
For the case that an AbstractManifoldObjective objective is passed as well – either as a tuple or as two parameters –, by default the objective is ignored, and the solver result for the state is returned; this is for display reasons in the REPL related to statistics, where such a tuple might appear.
For the case that an AbstractManoptProblem problem is passed as a first optional parameter, by default the problem is ignored. This can be used to change the representation of a result stored in a state, for example when a tangent vector is (part of) the result, changing between representations in coefficients and different tangent vector representations could be performed as a final step, depending on which problem was aimed to be solved.
Note that the returned value or point might still be aliased to the original state.
Manopt.get_state — Function
get_state(s::AbstractManoptSolverState, recursive::Bool=true)Return the undecorated AbstractManoptSolverState of the (possibly) decorated s. As long as your decorated state stores the state within s.state and dispatch_state_decorator is set to Val{true}, the internal state is extracted automatically.
By default the state that is stored within a decorated state is assumed to be at s.state. Overwrite _get_state(s, ::Val{true}, recursive) to change this behaviour for your state s for both the recursive and the direct case.
If recursive is set to false, only the most outer decorator is taken away instead of all.
Manopt.get_stopping_criterion — Method
get_stopping_criterion(ams::AbstractManoptSolverState)Return the StoppingCriterion stored within the AbstractManoptSolverState ams.
For an undecorated state, this is assumed to be in ams.stop. Overwrite _get_stopping_criterion(yms::YMS) to change this for your Manopt.jl solver yms, assuming it has type YMS.
Manopt.has_converged — Method
has_converged(ams::AbstractManoptSolverState)Return whether the solver has converged, based on the internal StoppingCriterion.
Manopt.set_gradient! — Method
set_gradient!(state::AbstractGradientSolverState, M, p, X)Set the (current) gradient stored within an AbstractGradientSolverState to X. The default function modifies state.X.
Manopt.set_gradient! — Method
set_gradient!(s::AbstractManoptSolverState, M::AbstractManifold, p, X)Set the gradient within a (possibly decorated) AbstractManoptSolverState to some (start) value X in the tangent space at p.
Manopt.set_iterate! — Method
set_iterate!(s::AbstractManoptSolverState, M::AbstractManifold, p)Set the iterate within an AbstractManoptSolverState to some (start) value p.
Manopt.stopped_at — Method
stopped_at(state::AbstractManoptSolverState)Return the number of iterations the solver represented by the state took to stop. If the solver has not yet stopped, this function returns -1.
By default, this function calls the get_count function on the state's stopping criterion to access its :Iterations count.
Internal functions
Manopt.get_message — Method
get_message(du::AbstractManoptSolverState)Get a message (String) from internal functors, in a summary. This should return any message a sub-step might have issued as well.
Manopt.get_solver_return — Method
get_solver_return(o::AbstractManifoldObjective, s::AbstractManoptSolverState)Determine the result value of a call to a solver.
By default this returns the same as get_solver_result.
Manopt.get_solver_return — Method
get_solver_return(s::AbstractManoptSolverState)Determine the result value of a call to a solver.
By default this returns the same as get_solver_result.
Manopt.get_solver_return — Method
get_solver_return(o::ReturnManifoldObjective, s::AbstractManoptSolverState)Return both the objective and the state as a tuple.
Manopt.set_parameter! — Method
set_parameter!(ams::AbstractManoptSolverState, element::Symbol, args...)Set a certain field or semantic element from the AbstractManoptSolverState ams to a value specified by args.... This function passes to Val(element) and specific setters should dispatch on Val{element}.
By default, this function just does nothing.