ProblemUpdater

MTKHelpers.get_ode_problemupdaterFunction
get_ode_problemupdater(par_getter::AbstractProblemParGetter, u0, p)
get_ode_problemupdater(par_getter::AbstractProblemParGetter, sys::AbstractODESystem)

Construct a ProblemUpdater based on an constructed ODEProblemParSetterConcrete.

source
get_ode_problemupdater(par_getter::AbstractProblemParGetter, u0, p)
get_ode_problemupdater(par_getter::AbstractProblemParGetter, sys::AbstractODESystem)

Construct a ProblemUpdater based on an constructed ODEProblemParSetterConcrete.

source

ProblemParGetter

In order to provide computations for parameters to set, declare a concrete subtype of AbstractProblemParGetter, and implement a custom method (pg::MyProblemParGetter)(pu::ProblemUpdater, prob) that returns a vector of parameter values.

MTKHelpers.AbstractProblemParGetterType

Supertype for callables that implement (::AbstractProblemParGetter)(problem) -> updated_problem

Concrete subtypes should implement function keys, so that an appropriate AbstractODEProblemParSetter can be constructed for ProblemUpdater.

source

One simple subtype of AbstractProblemParGetter is KeysProblemParGetter, which just extracts variables from the original problem to update other parameters. It can be used to ensure that some parameter of a problem will always equal another parameter of the problem.

MTKHelpers.KeysProblemParGetterType
KeysProblemParGetter(mapping::NTuple{N,Pair{Symbol, Symbol}, keys_state)

Provices callable (pg::KeysProblemParGetter)(pu::ProblemUpdater, prob), keys_state]. To be used to get the parameters/state vector to be set by ProblemUpdater.

Initialize with an mapping of NTuples of symbols (source -> target) that index into either get_state_labeled(pu.pset, prob) or get_par_labeled(pu.pset, prob)). Argument keys_state is a Tuple or Vector that iterates the Symbols in the state of an ODEProblem. It is required to know from which part of the problem to extract.

source

ProblemParSetter

MTKHelpers.AbstractProblemParSetterType

During an optimization, one does not want to recreate the problem from a symbolic system, but only update the problem. This can be difficult, because the parameters to update may be spread across initial state and other parameters. Further, the order of parameters after simplifying a system is not fixed.

A AbstractProblemUpdater helps with

  • remake: translate the set of parameters -> an updated problem
  • get_paropt: problem -> extract/approximate subset of parameters to optimize

The structure of optimized parameter Vector is described by an Axis object of ComponentArrays.jl. And several functions are defined to work with it. Specifically, the ComponentVector it employs a classification (classes_paropt), ,e.g. :state and :par for ODEProblems, below which, ComponentVectors of actual parameters are listed (keys_paropt](@ref)). Further functions extract information about the ComponentVector: axis_paropt, , count_paropt, symbols_paropt or attach information to a plain vector for convenient access or display: label_paropt, name_paropt.

source

Translating between parameters and Problem

SciMLBase.remakeMethod
remake(prob::AbstractSciMLProblem, popt, ps::AbstractProblemParSetter)

Return an updated problem given the parameters. Subtypes need to implement method remake_pset(prob, popt, pset)

source
MTKHelpers.get_paroptMethod
get_paropt(pset::AbstractProblemParSetter, prob::SciMLBase.AbstractSciMLProblem; kwargs...)
get_paropt_labeled(pset::AbstractProblemParSetter, prob::SciMLBase.AbstractSciMLProblem; kwargs...)

Extract optimized parameters from the Problem. The labeled versions additionally calls label_paropt on the return value.

source

Helper functions to access optimized parameters

MTKHelpers.axis_paroptMethod
axis_paropt(pset::AbstractProblemParSetter)
axis_paropt_scalar(pset::AbstractProblemParSetter)
axis_paropt_flat1(pset::AbstractProblemParSetter)

Report the Axis of a CompoenentVector of parameters. The second version has a scalarized entry for state for each subvector of state. The third version provides an axis corresponding to flatten1(paropt).

source
MTKHelpers.classes_paroptMethod
function classes_paropt(pset::AbstractProblemParSetter)

Get the classes (as NTuple{Symbol}) which the AbstractProblemParSetter supports and requires in paropt.

source
MTKHelpers.count_paroptMethod
count_paropt(::AbstractProblemParSetter)

Report length of the optimized parameters vector. This generally is different from the length of keys, because each key can describe a array.

source
MTKHelpers.symbols_paroptMethod
symbols_paropt(pset::AbstractProblemParSetter)

Report the names, i.e. symbols of optimized parameters respectively, i.e. the concatenation of components. Similar to ComponentArrays.label, but inferred from Axis object. Returns a Vector of length count_paropt

source

Labeling parameter vectors

MTKHelpers.label_paroptMethod
label_paropt(pset::AbstractProblemParSetter, popt::AbstractVector) 
label_paropt_flat1(pset::AbstractProblemParSetter, popt::AbstractVector)

Produce a labeled version, i.e. a ComponentVector of optimized parameters. The second version omits the highest level of labels, e.g. state and par in ODEProblemParSetter.

source
MTKHelpers.name_paroptMethod
name_paropt(pset, popt::AbstractVector) 
name_paropt(pset, prob::AbstractSciMLProblem)

Produce a NamedVector of given state optimized parameters vector. Similar to label_paropt, but may print nicer. The second form calls get_paropt on the Problem.

source