The Objective

Within the optimization problem

\[\operatorname*{argmin}_{p \in \mathcal M} f(p)\]

the objective describes the cost $f(p)$ and its properties and relations. The general abstract type for these is

Manopt.AbstractManifoldObjectiveType
AbstractManifoldObjective

Describe the objective function $f: \mathcal{M} → ℝ$ and all its necessary ingredients, for example when it consists of several summands.

Subtypes might depend on the kind of objective in order to distinguish different available access functionality, e.g. to a gradient, or a proximal map.

Such a default component of the objective like the cost itself or the gradient should be implemented in the form

(M, v, args...) -> [...]; v

where M is a AbstractManifold, v is memory the result is computed in, as well as further arguments, most prominently usually the current iterate p.

For an allocating variant, internally the wrapper InplaceManifoldFunction should be used.

source

There is a hierarchy of objectives in order to provide default implementations for certain parts.

Decorated objectives

Following the decorator pattern approach, an objective can be “wrapped” to gain certain properties, for example to cache or count function evaluations.

Functions

Manopt.get_objectiveFunction
get_objective(o::AbstractManifoldObjective, recursive=true)

Return the undecorated AbstractManifoldObjective of the (possibly) decorated o. As long as your decorated objective stores the objective within o.objective and dispatch_objective_decorator is set to Val{true}, the internal objective is extracted automatically.

By default the objective that is stored within a decorated objective is assumed to be at o.objective. Overwrite _get_objective(o, ::Val{true}, recursive) to change this behaviour for your objective o 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.

source

Internal functions

A zeroth order objective

For the first and simplest objective, only the cost function itself is available. This is for example used in solvers like NelderMead or particle_swarm.

Manopt.AbstractManifoldCostObjectiveType
AbstractManifoldCostObjective{F} <: AbstractManifoldObjective

Representing objectives on manifolds with a cost function implemented. The parameter F represents the type of the cost function.

source

Internal structures and functions

Manopt.get_cost_functionFunction
get_cost_function(mco::AbstractManifoldCostObjective, recursive=false)

Return the function to evaluate (just) the cost $f(p)=c$ as a function (M,p) -> c. If mco has more than one decorator, recursive determines whether just one (false) or all wrappers (true) should be “unwrapped” at once.

In the non-recursive case, this implementation assumes that the cost function is stored in mco.cost. This way you only have to implement this function if your cost function is stored in a different field.

source

A first order objective

A smooth first order objective usually contains the gradient. This interface unifies the access to it.

Manopt.DirectionUpdateRuleType
DirectionUpdateRule

A general functor, that handles direction update rules. Its fields are usually only a StoreStateAction by default initialized to the fields required for the specific coefficient, but can also be replaced by a (common, global) individual one that provides these values.

source
Manopt.get_differentialMethod
 get_differential(amp::AbstractManoptProblem, p, X; kwargs...)
 get_differential(M::AbstractManifold, amfo::AbstractManifoldFirstOrderObjective, p, X; kwargs...)
 get_differential(M::AbstractManifold, admo::AbstractDecoratedManifoldObjective, p, X; kwargs...)

Evaluate the differential $Df(p)[X]$ of the function $f$ represented by the AbstractManifoldFirstOrderObjective. For an AbstractManoptProblem amp the inner manifold and objectives are used. Similarly, any objective decorator would “pass through” to its inner objective. By default this falls back to $Df(p)[X] = ⟨\operatorname{grad}f(p), X⟩$.

Keyword arguments

  • gradient=nothing: pass a tangent vector to be used internally as interim memory, for example in the default variant to evaluate the gradient in-place.
  • evaluated=false: indicate whether gradient is just memory (false, default) or already contains the evaluated gradient (true).
source

Internal structures and functions

Manopt.get_cost_and_differentialFunction
(c, d) = get_cost_and_differential(problem::AbstractManoptProblem, p, X; kwargs...)
(c, d) = get_cost_and_differential(M, objective::AbstractManifoldFirstOrderObjective, p, X; kwargs...)

Evaluate the cost and the differential of an AbstractManifoldFirstOrderObjective objective at a point p in direction X. For an AbstractManoptProblem problem the inner manifold and objectives are used. Similarly, any objective decorator would “pass through” to its inner objective.

Keyword arguments are passed down.

source
Manopt.get_cost_and_gradientMethod
(c, X) = get_cost_and_gradient(problem::AbstractManoptProblem, p)
(c, X) = get_cost_and_gradient(M, objective::AbstractManifoldFirstOrderObjective, p)
(c, X) = get_cost_and_gradient!(M, X, objective::AbstractManifoldFirstOrderObjective, p)

Evaluate the cost and the gradient of an AbstractManifoldFirstOrderObjective objective at a point p simultaneously. For an AbstractManoptProblem problem the inner manifold and objectives are used. Similarly, any objective decorator would “pass through” to its inner objective.

The gradient part can be evaluated in-place of X.

source
Manopt.get_differential_functionFunction
 get_differential_function(objective::AbstractManifoldFirstOrderObjective, recursive::Bool=false)

Return the function to evaluate (just) the differential $Df(p)[X]$. For a decorated objective, the recursive positional parameter determines whether to directly call this function on the next decorator or whether to get the “most inner” objective.

source
Manopt.get_gradient_functionFunction
get_gradient_function(amgo::AbstractManifoldFirstOrderObjective, recursive=false; evaluation=AllocatingEvaluation())

Return the function to evaluate (just) the gradient $\operatorname{grad} f(p)$, where either the gradient function using the decorator or without the decorator is used.

By default recursive is set to false, since usually to just pass the gradient function somewhere, one still wants for example the cached one or the one that still counts calls.

Use evaluation=InplaceEvaluation() and recursive=true to get access to the internally stored actual function. Note that this actual function might still be wrapped in an InplaceManifoldFunction.

source

A first order nonsmooth objective

First order nonsmooth objectives come in a variety of flavours, mainly splitting based, where the single summands themselves have certain properties. They are collected in the following.

Manopt.adjoint_linearized_operatorMethod
X = adjoint_linearized_operator(M::AbstractManifold, N::AbstractManifold, apdmo::AbstractPrimalDualManifoldObjective, m, n, Y)
adjoint_linearized_operator!(M::AbstractManifold, N::AbstractManifold, X, apdmo::AbstractPrimalDualManifoldObjective, m, n, Y)

Evaluate the adjoint of the linearized forward operator, $(DΛ(m))^*[Y]$, stored within the AbstractPrimalDualManifoldObjective (in place of X). Since $Y∈T_{n}\mathcal{N}$, both $m$ and $n=Λ(m)$ are necessary arguments, mainly because the forward operator $Λ$ might be missing.

source

A second order objective

The following types and functions provide the access to second-order information.

Internal structures and functions

A linear system in a tangent space

A linear system in a tangent space can be modelled in different ways. Most prominently either as a matrix as soon as a basis of the tangent space is fixed or as a linear operator in a basis-free representation.

Internal structures and functions

Manopt.AbstractSymmetricLinearSystemObjectiveType
AbstractSymmetricLinearSystemObjective <: AbstractManifoldObjective

Model the objective

\[f(X) = \frac{1}{2} \lVert \mathcal{A}[X] + b \rVert_{p}^2,\qquad X ∈ T_{p}\mathcal{M},\]

defined on the tangent space $T_{p}\mathcal{M}$ at $p$ on the manifold $\mathcal{M}$.

In other words this is an objective to solve $\mathcal{A}[X] = -b(p)$ for some linear symmetric operator $\mathcal{A}$ and a vector function $b$.

Concrete subtypes of this type should/could implement

Then the following functions are available directly

  • get_cost(TpM, aslso, X) to compute/evaluate the objective
  • get_gradient(TpM, aslso, X) to compute/evaluate the objective's gradient at X
  • get_linear_operator(TpM, aslso, X) to compute/evaluate the linear operator $\mathcal{A}$ at X
source

Subsolver objectives

Internal structures and functions

Manopt.AbstractLinearSurrogateObjectiveType
AbstractLinearSurrogateObjective{O <: AbstractManifoldObjective} <: AbstractManifoldSubObjective{O}

Provide a linear surrogate model for a given AbstractManifoldObjective of type O of the form

\[μ_p(X) = \frac{1}{2}\lVert \mathcal{L}(X) + y \rVert_{2}^2 + \frac{λ}{2}\lVert X \rVert_{p}^2, \qquad\text{ for }X ∈ T_{p}\mathcal{M}, λ ≥ 0,\]

where $\mathcal{L}$ is a linear operator on the tangent space at a point $p ∈ M$ that maps into some vector space $V$ and $y ∈ V$ is a fixed vector in that space and $\lVert ⋅ \rVert$ is a norm on $V$.

Both $\mathcal{L}$ and $y$ are derived from the objective O and usually depend on the base point $p ∈ M$.

Besides the usual methods defined for AbstractManifoldObjective that may be implemented like get_cost and get_gradient, the following methods should be implemented for a concrete subtype of AbstractLinearSurrogateObjective

See also the NormalEquationsObjective for the corresponding normal equations.

source
Manopt.get_linear_operatorFunction
get_linear_operator(M::AbstractManifold, lsmo::AbstractLinearSurrogateObjective, p)
get_linear_operator(M::AbstractManifold, lsmo::AbstractLinearSurrogateObjective, p, B::AbstractBasis)
get_linear_operator(M::AbstractManifold, lsmo::AbstractLinearSurrogateObjective, p, X)
get_linear_operator!(M::AbstractManifold, L, lsmo::AbstractLinearSurrogateObjective, p, B::AbstractBasis)
get_linear_operator!(M::AbstractManifold, Y, lsmo::AbstractLinearSurrogateObjective, p, X)

Return/Evaluate the linear operator $\mathcal{L}$ of the linear surrogate model lsmo at the point $p ∈ M$.

If a tangent vector X is provided, evaluate $\mathcal{L}(X)$. If a basis B is provided, return the matrix representation of $\mathcal{L}$ with respect to that basis. Otherwise return the operator as a function (TpM, X) -> Y.

source
Manopt.get_normal_linear_operatorFunction
get_normal_linear_operator(M::AbstractManifold, lsmo::AbstractLinearSurrogateObjective, p)
get_normal_linear_operator(M::AbstractManifold, lsmo::AbstractLinearSurrogateObjective, p, B::AbstractBasis)
get_normal_linear_operator(M::AbstractManifold, lsmo::AbstractLinearSurrogateObjective, p, X)
get_normal_linear_operator!(M::AbstractManifold, N, lsmo::AbstractLinearSurrogateObjective, p, B::AbstractBasis)
get_normal_linear_operator!(M::AbstractManifold, Y, lsmo::AbstractLinearSurrogateObjective, p, X)

Return/Evaluate the normal operator $\mathcal{L}^* \mathcal{L}$ of the linear surrogate model lsmo at the point $p ∈ M$.

If a tangent vector X is provided, evaluate $\mathcal{L}^* \mathcal{L}(X)$. If a basis B is provided, return the matrix representation of $\mathcal{L}^* \mathcal{L}$ with respect to that basis. Otherwise return the operator as a function (TpM, X) -> Y.

source