Record values

To record values during the iterations of a solver run, there are in general two possibilities. On the one hand, the high-level interfaces provide a record= keyword, that accepts several different inputs. For more details see How to record.

For example recording the gradient from the GradientDescentState is automatically available, as explained in the gradient_descent solver.

Record solver states

Manopt.RecordActionType
RecordAction

A RecordAction is a small functor to record values. The usual call is given by (amp::AbstractManoptProblem, ams::AbstractManoptSolverState, i) -> s that performs the record, where i is the current iteration.

By convention i<=0 is interpreted as "For Initialization only", i.e. only initialize internal values, but not trigger any record, the same holds for i=typemin(Inf) which is used to indicate stop, i.e. that the record is called from within stop_solver! which returns true afterwards.

Fields (assumed by subtypes to exist)

  • recorded_values an Array of the recorded values.
source
Manopt.RecordChangeType
RecordChange <: RecordAction

debug for the amount of change of the iterate (stored in o.x of the AbstractManoptSolverState) during the last iteration.

Additional Fields

  • storage a StoreStateAction to store (at least) o.x to use this as the last value (to compute the change
  • inverse_retraction_method - (default_inverse_retraction_method(manifold, p)) the inverse retraction to be used for approximating distance.

Constructor

RecordChange(M=DefaultManifold();)

with the above fields as keywords. For the DefaultManifold only the field storage is used. Providing the actual manifold moves the default storage to the efficient point storage.

source
Manopt.RecordEntryType
RecordEntry{T} <: RecordAction

record a certain fields entry of type {T} during the iterates

Fields

source
Manopt.RecordEntryChangeType
RecordEntryChange{T} <: RecordAction

record a certain entries change during iterates

Additional Fields

  • recorded_values – the recorded Iterates
  • field – Symbol the field can be accessed with within AbstractManoptSolverState
  • distance – function (p,o,x1,x2) to compute the change/distance between two values of the entry
  • storage – a StoreStateAction to store (at least) getproperty(o, d.field)
source
Manopt.RecordEveryType
RecordEvery <: RecordAction

record only every $i$th iteration. Otherwise (optionally, but activated by default) just update internal tracking values.

This method does not perform any record itself but relies on it's childrens methods

source
Manopt.RecordGroupType
RecordGroup <: RecordAction

group a set of RecordActions into one action, where the internal RecordActions act independently, but the results can be collected in a grouped fashion, i.e. tuples per calls of this group. The entries can be later addressed either by index or semantic Symbols

Constructors

RecordGroup(g::Array{<:RecordAction, 1})

construct a group consisting of an Array of RecordActions g,

RecordGroup(g, symbols)

Examples

r = RecordGroup([RecordIteration(), RecordCost()])

A RecordGroup to record the current iteration and the cost. The cost can then be accessed using get_record(r,2) or r[2].

r = RecordGroup([RecordIteration(), RecordCost()], Dict(:Cost => 2))

A RecordGroup to record the current iteration and the cost, which can then be accessed using get_record(:Cost) or r[:Cost].

r = RecordGroup([RecordIteration(), :Cost => RecordCost()])

A RecordGroup identical to the previous constructor, just a little easier to use.

source
Manopt.RecordIterateType
RecordIterate <: RecordAction

record the iterate

Constructors

RecordIterate(x0)

initialize the iterate record array to the type of x0, e.g. your initial data.

RecordIterate(P)

initialize the iterate record array to the data type T.

source
Manopt.RecordSolverStateType
RecordSolverState <: AbstractManoptSolverState

append to any AbstractManoptSolverState the decorator with record functionality, Internally a Dictionary is kept that stores a RecordAction for several concurrent modes using a Symbol as reference. The default mode is :Iteration, which is used to store information that is recorded during the iterations. RecordActions might be added to :Start or :Stop to record values at the beginning or for the stopping time point, respectively

The original options can still be accessed using the get_state function.

Fields

  • options – the options that are extended by debug information
  • recordDictionary – a Dict{Symbol,RecordAction} to keep track of all different recorded values

Constructors

RecordSolverState(o,dR)

construct record decorated AbstractManoptSolverState, where dR can be

  • a RecordAction, then it is stored within the dictionary at :Iteration
  • an Array of RecordActions, then it is stored as a recordDictionary(@ref) within the dictionary at :All.
  • a Dict{Symbol,RecordAction}.
source
Manopt.RecordTimeType
RecordTime <: RecordAction

record the time elapsed during the current iteration.

The three possible modes are

  • :cumulative record times without resetting the timer
  • :iterative record times with resetting the timer
  • :total record a time only at the end of an algorithm (see stop_solver!)

The default is :cumulative, and any non-listed symbol default to using this mode.

Constructor

RecordTime(; mode::Symbol=:cumulative)
source
Base.getindexMethod
getindex(r::RecordGroup, s::Symbol)
r[s]
getindex(r::RecordGroup, sT::NTuple{N,Symbol})
r[sT]
getindex(r::RecordGroup, i)
r[i]

return an array of recorded values with respect to the s, the symbols from the tuple sT or the index i. See get_record for details.

source
Base.getindexMethod
get_index(rs::RecordSolverState, s::Symbol)
ro[s]

Get the recorded values for recorded type s, see get_record for details.

get_index(rs::RecordSolverState, s::Symbol, i...)
ro[s, i...]

Access the recording type of type s and call its RecordAction with [i...].

source
Manopt.RecordActionFactoryMethod
RecordActionFactory(s)

create a RecordAction where

  • a RecordAction is passed through
  • a [Symbol] creates RecordEntry of that symbol, with the exceptions of
    • :Change - to record the change of the iterates in o.x`
    • :Iterate - to record the iterate
    • :Iteration - to record the current iteration number
    • :Cost - to record the current cost function value
    • :Time - to record the total time taken after every iteration
    • :IterativeTime – to record the times taken for each iteration.
source
Manopt.RecordFactoryMethod
RecordFactory(s::AbstractManoptSolverState, a)

given an array of Symbols and RecordActions and Ints

source
Manopt.get_recordFunction
get_record(s::AbstractManoptSolverState, [,symbol=:Iteration])
get_record(s::RecordSolverState, [,symbol=:Iteration])

return the recorded values from within the RecordSolverState s that where recorded with respect to the Symbol symbol as an Array. The default refers to any recordings during an :Iteration.

When called with arbitrary AbstractManoptSolverState, this method looks for the RecordSolverState decorator and calls get_record on the decorator.

source
Manopt.get_recordMethod
get_record(r::RecordGroup)

return an array of tuples, where each tuple is a recorded set, e.g. per iteration / record call.

get_record(r::RecordGruop, i::Int)

return an array of values corresponding to the ith entry in this record group

get_record(r::RecordGruop, s::Symbol)

return an array of recorded values with respect to the s, see RecordGroup.

get_record(r::RecordGroup, s1::Symbol, s2::Symbol,...)

return an array of tuples, where each tuple is a recorded set corresponding to the symbols s1, s2,... per iteration / record call.

source
Manopt.record_or_reset!Method
record_or_reset!(r,v,i)

either record (i>0 and not Inf) the value v within the RecordAction r or reset (i<0) the internal storage, where v has to match the internal value type of the corresponding Recordaction.

source

see recording values for details on the decorated solver.

Further specific RecordActions can be found when specific types of AbstractManoptSolverState define them on their corresponding site.

Technical details

Manopt.initialize_solver!Method
initialize_solver!(ams::AbstractManoptProblem, rss::RecordSolverState)

Extend the initialization of the solver by a hook to run records that were added to the :Start entry.

source
Manopt.step_solver!Method
step_solver!(amp::AbstractManoptProblem, rss::RecordSolverState, i)

Extend the ith step of the solver by a hook to run records, that were added to the :Iteration entry.

source
Manopt.stop_solver!Method
stop_solver!(amp::AbstractManoptProblem, rss::RecordSolverState, i)

Extend the check, whether to stop the solver by a hook to run records, that were added to the :Stop entry.

source