KerMor
0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
|
KernelExpansion: Base class for state-space kernel expansions. More...
KernelExpansion: Base class for state-space kernel expansions.
The KernelExpansion class represents a function \(f\) in the space induced by a given kernel \(\K\) as
\[f(x) = \sum\limits_{i=1}^N c_i\K(x,x_i)\]
This class has been introduced in order to allow standalone use of kernel expansions in approximation contexts outside of the intended model reduction scheme.
off
This class is part of the framework
Homepage
http://www.morepas.org/software/index.htmlDocumentation
http://www.morepas.org/software/kermor/index.htmlLicense
KerMor license conditions Definition at line 18 of file KernelExpansion.m.
Public Member Functions | |
KernelExpansion () | |
Default constructor. More... | |
function fx = | evaluate (matrix x, varargin) |
Evaluates the kernel expansion. More... | |
function phi = | getKernelVector (matrix x, varargin) |
Evaluates the kernel expansion. More... | |
function row = | getKernelMatrixColumn (integer idx,matrix x, varargin) |
Evaluates the kernel expansion. More... | |
function J = | getStateJacobian (x, varargin) |
Evaluates the jacobian matrix of this function at the given point. More... | |
function K = | getKernelMatrix () |
Computes the kernel matrix for the currently set center data. More... | |
function v = | scalarProductWith (f) |
function | normalize () |
function | setCentersFromATD (data.ApproxTrainData atd,rowvec< integer > idx) |
Sets the centers according to the indices idx of the data.ApproxTrainData. More... | |
function
kernels.KernelExpansion kexp = | toTranslateBase () |
Returns the same kernel expansion with the canonical translate base used. More... | |
function subexp = | getSubExpansion (arg) |
function c = | getGlobalLipschitz (double t,colvec< double > mu) |
For some error estimators, a global Lipschitz constant estimation is performed. This function has to yield the global lipschitz constant for the spatial/state part of a CoreFunction \(f(x,t,mu)\). More... | |
function target = | project (V, W) |
function copy = | clone (copy) |
The interface method with returns a copy of the current class instance. More... | |
function | clear () |
Removes all centers and coefficients from the expansion and leaves the associated kernels untouched. More... | |
function sum = | plus (B) |
Adds two kernel expansions and will clone the frist argument's class as result type. More... | |
function diff = | minus (B) |
Adds two kernel expansions and will clone the frist argument's class as result type. More... | |
function neg = | uminus () |
function | exportToDirectory (dir) |
function json = | toJSON (filename) |
function res = | test_getStateJacobianInstance () |
Public Member Functions inherited from KerMorObject | |
KerMorObject () | |
Constructs a new KerMor object. More... | |
function | display () |
disp(object2str(this)); More... | |
function bool = | eq (B) |
Checks equality of two KerMor objects. More... | |
function bool = | ne (B) |
Checks if two KerMorObjects are different. More... | |
function cn = | getClassName () |
Returns the simple class name of this object without packages. More... | |
Public Member Functions inherited from DPCMObject | |
DPCMObject () | |
Creates a new DPCM object. More... | |
DPCMObject () | |
Public Member Functions inherited from general.AProjectable | |
function handle target = | project (matrix< double > V,matrix< double > W,handle target) |
Returns a NEW INSTANCE of the projected object that does not rely on data of the old one via references (everything must be copied to ensure separability of reduced(=projected) versions and full versions, unless. More... | |
Static Public Member Functions | |
static function res = | test_getStateJacobian () |
Public Attributes | |
kernels.BaseKernel | Kernel |
The Kernel to use for system variables. More... | |
rowvec | Ma_norms |
The norms of the coefficient matrix of the kernel expansion. More... | |
double | NativeNorm |
Returns the norm \(||f||^2_{\H^q}\) of \(f\) in the RKHS \(\H^q,\quad q\in\N\). More... | |
colvec< double > | ComponentNorms |
Returns the native space norms \(||f_j||^2_\H\) for each component function \(j \equiv\)size(Ma,1) More... | |
MBnd | |
Returns the M upper bound for this KernelExpansion, which is \(M := \max\limits_{j=1}^d\sum\limits_{i=1}^m |c^d_i|\). More... | |
logical | HasCustomBase |
Flag that indicates if a base other than the direct translate base is used for this kernel expansion. More... | |
Size | |
The size of the kernel expansion. More... | |
struct | Centers = struct("'xi',[]") |
The kernel centers used in the approximation. More... | |
matrix< double > | Ma = "[]" |
The coefficient data for each dimension. More... | |
matrix< double > | Base = 1 |
This property lets the user store a custom base, for which the coefficients are set. The custom base tells which linear combinations of center elements belong to which base. More... | |
Public Attributes inherited from DPCMObject | |
WorkspaceVariableName = "" | |
The workspace variable name of this class. Optional. More... | |
ID = "[]" | |
An ID that allows to uniquely identify this DPCMObject (at least within the current MatLab session/context). More... | |
PropertiesChanged = "[]" | |
The Dictionary containing all the property settings as key/value pairs. More... | |
Public Attributes inherited from handle | |
addlistener | |
Creates a listener for the specified event and assigns a callback function to execute when the event occurs. More... | |
notify | |
Broadcast a notice that a specific event is occurring on a specified handle object or array of handle objects. More... | |
delete | |
Handle object destructor method that is called when the object's lifecycle ends. More... | |
disp | |
Handle object disp method which is called by the display method. See the MATLAB disp function. More... | |
display | |
Handle object display method called when MATLAB software interprets an expression returning a handle object that is not terminated by a semicolon. See the MATLAB display function. More... | |
findobj | |
Finds objects matching the specified conditions from the input array of handle objects. More... | |
findprop | |
Returns a meta.property objects associated with the specified property name. More... | |
fields | |
Returns a cell array of string containing the names of public properties. More... | |
fieldnames | |
Returns a cell array of string containing the names of public properties. See the MATLAB fieldnames function. More... | |
isvalid | |
Returns a logical array in which elements are true if the corresponding elements in the input array are valid handles. This method is Sealed so you cannot override it in a handle subclass. More... | |
eq | |
Relational functions example. See details for more information. More... | |
transpose | |
Transposes the elements of the handle object array. More... | |
permute | |
Rearranges the dimensions of the handle object array. See the MATLAB permute function. More... | |
reshape | |
hanges the dimensions of the handle object array to the specified dimensions. See the MATLAB reshape function. More... | |
sort | |
ort the handle objects in any array in ascending or descending order. More... | |
Public Attributes inherited from general.AProjectable | |
V | |
The \(V\) matrix of the biorthogonal pair \(V,W\). More... | |
W | |
The \(W\) matrix of the biorthogonal pair \(V,W\). More... | |
Static Protected Member Functions | |
static function this = | loadobj (this, from) |
As the constant properties are transient, they have to be re-computed upon loading. More... | |
Static Protected Member Functions inherited from DPCMObject | |
static function obj = | loadobj (obj, from) |
Re-register any registered change listeners! More... | |
static function obj = | loadobj (obj, from) |
Static Protected Member Functions inherited from general.AProjectable | |
static function obj = | loadobj (obj, from) |
Protected Attributes | |
kernels.BaseKernel | fSK |
The inner (state) kernel object. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from KerMorObject | |
function | checkType (obj, type) |
Object typechecker. More... | |
Protected Member Functions inherited from DPCMObject | |
function | registerProps (varargin) |
Call this method at any class that defines DPCM observed properties. More... | |
function | registerProps (varargin) |
kernels.KernelExpansion.KernelExpansion | ( | ) |
Default constructor.
Initializes default kernels.
Definition at line 249 of file KernelExpansion.m.
References fSK, KerMorObject.KerMorObject(), and DPCMObject.registerProps().
Referenced by testing.Speed.KernelExpCustomBaseEval().
function kernels.KernelExpansion.clear | ( | ) |
Removes all centers and coefficients from the expansion and leaves the associated kernels untouched.
Definition at line 487 of file KernelExpansion.m.
Referenced by approx.algorithms.AAdaptiveBase.initExpansion().
|
virtual |
The interface method with returns a copy of the current class instance.
target | If clone was called for a subclass of this class, target must contain the new instance of the subclass that is to be the cloned result. |
Reimplemented from general.AProjectable.
Reimplemented in kernels.ParamTimeKernelExpansion.
Definition at line 475 of file KernelExpansion.m.
References Base, Centers, kernels.BaseKernel.clone(), fSK, and Ma.
Referenced by dscomponents.ParamTimeKernelCoreFun.clone(), approx.KernelEI.clone(), getSubExpansion(), project(), toTranslateBase(), and uminus().
function fx = kernels.KernelExpansion.evaluate | ( | matrix | x, |
varargin | |||
) |
Evaluates the kernel expansion.
x | The state space vector(s) to evaluate at |
varargin | Dummy variable to also allow calls to this class with \(t_i,\mu_i\) parameters as in ParamTimeKernelExpansion. |
fxi | The evaluation \(f(x) = \sumi c_i \K(x,x_i)\) |
Definition at line 271 of file KernelExpansion.m.
Referenced by dscomponents.ParamTimeKernelCoreFun.evaluate(), approx.KernelEI.evaluateCoreFun(), dscomponents.ParamTimeKernelCoreFun.evaluateMulti(), approx.algorithms.ABase.getError(), and test_getStateJacobianInstance().
function kernels.KernelExpansion.exportToDirectory | ( | dir | ) |
Definition at line 528 of file KernelExpansion.m.
References Centers, Utils.ensureDir(), k, Kernel, Ma, Util.saveRealMatrix(), and Util.saveRealVector().
For some error estimators, a global Lipschitz constant estimation is performed. This function has to yield the global lipschitz constant for the spatial/state part of a CoreFunction \(f(x,t,mu)\).
t | The current time(s) \(t \in [0, T]\) |
mu | The currently used parameter \(\vmu\). Set to \([]\) if not used. |
Implements dscomponents.IGlobalLipschitz.
Reimplemented in kernels.ParamTimeKernelExpansion.
Definition at line 450 of file KernelExpansion.m.
References kernels.BaseKernel.getGlobalLipschitz(), Kernel, and Ma_norms.
Referenced by dscomponents.ParamTimeKernelCoreFun.getGlobalLipschitz().
function K = kernels.KernelExpansion.getKernelMatrix | ( | ) |
Computes the kernel matrix for the currently set center data.
Convenience method, equal to call evaluateAtCenters with passing the center data as arguments. However, this method is (possibly, depends on kernel implementation) faster as it calls the kernels kernels.BaseKernel.evaluate -method with one argument.
Definition at line 341 of file KernelExpansion.m.
References Centers, kernels.BaseKernel.evaluate(), and fSK.
Referenced by general.regression.KernelLS.init(), and general.regression.BaseScalarSVR.init().
Evaluates the kernel expansion.
idx | The column index |
x | The state space vector(s) to evaluate at Default: this.Centers.xi |
varargin | Dummy variable to also allow calls to this class with \(t_i,\mu_i\) parameters as in ParamTimeKernelExpansion. |
phi | The kernel vector \(\varphi(x) =\left(\K(x,x_i)\right)_{i}\). |
Definition at line 301 of file KernelExpansion.m.
References Centers, kernels.BaseKernel.evaluate(), and fSK.
function phi = kernels.KernelExpansion.getKernelVector | ( | matrix | x, |
varargin | |||
) |
Evaluates the kernel expansion.
x | The state space vector(s) to evaluate at |
varargin | Dummy variable to also allow calls to this class with \(t_i,\mu_i\) parameters as in ParamTimeKernelExpansion. |
phi | The kernel vector \(\varphi(x) =\left(\K(x,x_i)\right)_{i}\). |
Definition at line 286 of file KernelExpansion.m.
References Centers, kernels.BaseKernel.evaluate(), and fSK.
function J = kernels.KernelExpansion.getStateJacobian | ( | x, | |
varargin | |||
) |
Evaluates the jacobian matrix of this function at the given point.
As this is a component-wise kernel expansion, the jacobian is easily computed using the coefficient vectors and the state variable nablas.
x | The state vector at which the jacobian is required. |
varargin | Dummy parameter to satisfy the interface calls for kernels.ParamTimeKernelExpansion classes, which also give a \(t\) and \(\mu\) parameter. |
Definition at line 321 of file KernelExpansion.m.
References Centers, Ma, and t.
Referenced by dscomponents.ParamTimeKernelCoreFun.getStateJacobian(), and test_getStateJacobianInstance().
function subexp = kernels.KernelExpansion.getSubExpansion | ( | arg | ) |
Definition at line 429 of file KernelExpansion.m.
References Centers, and clone().
Referenced by demos.ResponseSurfaceApprox.iterationPlots().
|
staticprotected |
As the constant properties are transient, they have to be re-computed upon loading.
Any subclasser MUST call this superclasses loadobj function explicitly!
Definition at line 761 of file KernelExpansion.m.
References Base, Centers, fSK, KerMorObject.KerMorObject(), Kernel, and Ma.
function diff = kernels.KernelExpansion.minus | ( | B | ) |
Adds two kernel expansions and will clone the frist argument's class as result type.
Definition at line 510 of file KernelExpansion.m.
function kernels.KernelExpansion.normalize | ( | ) |
Definition at line 381 of file KernelExpansion.m.
References Ma, and NativeNorm.
function sum = kernels.KernelExpansion.plus | ( | B | ) |
Adds two kernel expansions and will clone the frist argument's class as result type.
Definition at line 498 of file KernelExpansion.m.
Referenced by test_getStateJacobianInstance().
function target = kernels.KernelExpansion.project | ( | V, | |
W | |||
) |
Definition at line 455 of file KernelExpansion.m.
References all(), Centers, clone(), k, Ma, t, and general.AProjectable.V.
Referenced by dscomponents.ParamTimeKernelCoreFun.project(), and approx.KernelEI.project().
function v = kernels.KernelExpansion.scalarProductWith | ( | f | ) |
Definition at line 367 of file KernelExpansion.m.
function kernels.KernelExpansion.setCentersFromATD | ( | data.ApproxTrainData | atd, |
rowvec< integer > | idx | ||
) |
Sets the centers according to the indices idx
of the data.ApproxTrainData.
atd | The approximation training data instance |
idx | The indices of the entries in the approx train data to use |
Definition at line 386 of file KernelExpansion.m.
References Centers, and data.ApproxTrainData.xi.
|
static |
Definition at line 729 of file KernelExpansion.m.
References k.
function res = kernels.KernelExpansion.test_getStateJacobianInstance | ( | ) |
Definition at line 564 of file KernelExpansion.m.
References Centers, evaluate(), getStateJacobian(), k, Kernel, plus(), and X.
function json = kernels.KernelExpansion.toJSON | ( | filename | ) |
Definition at line 547 of file KernelExpansion.m.
References Base, Centers, HasCustomBase, Ma, and Util.matrixToJSON().
function kernels.KernelExpansion kexp = kernels.KernelExpansion.toTranslateBase | ( | ) |
Returns the same kernel expansion with the canonical translate base used.
If no custom base is used, a simple copy will be returned.
Using a non-standard base may be the result of a Newton-base type approximation algorithm. However, evaluating the kernel expansion in a different base is less effective. If the coefficients of the direct translates are not too bad (i.e. large values with opposite signs), using the direct translate base might give the same results at an improved evaluation speed.
kexp | A cloned instance with the direct translate base. |
Definition at line 402 of file KernelExpansion.m.
References clone().
function neg = kernels.KernelExpansion.uminus | ( | ) |
kernels.KernelExpansion.Base = 1 |
This property lets the user store a custom base, for which the coefficients are set. The custom base tells which linear combinations of center elements belong to which base.
In KerMor, this is typically set by the interpolating algorithms like approx.algorithm.VKOGA or general.interpolation.KernelInterpol
Default: 1
SetObservable
set to true. Definition at line 210 of file KernelExpansion.m.
kernels.KernelExpansion.Centers = struct("'xi',[]") |
The kernel centers used in the approximation.
This is the union of all center data used within the kernel function as a struct
xi
The state variable centersti
The times at which the state xi is takenmui
The parameter used to obtain the state xiThe only required field is xi, others can be set to [] if not used.
Default: struct(xi
,[])
SetObservable
set to true. Definition at line 170 of file KernelExpansion.m.
Referenced by kernels.ParamTimeKernelExpansion.clear(), clear(), clone(), exportToDirectory(), approx.algorithms.AAdaptiveBase.extendExpansion(), kernels.ParamTimeKernelExpansion.getGlobalLipschitz(), kernels.ParamTimeKernelExpansion.getKernelMatrix(), getKernelMatrix(), kernels.ParamTimeKernelExpansion.getKernelMatrixColumn(), getKernelMatrixColumn(), kernels.ParamTimeKernelExpansion.getKernelVector(), getKernelVector(), kernels.ParamTimeKernelExpansion.getStateJacobian(), getStateJacobian(), getSubExpansion(), demos.ResponseSurfaceApprox.iterationPlots(), loadobj(), kernels.ParamTimeKernelExpansion.ParamTimeKernelExpansion(), project(), scalarProductWith(), kernels.ParamTimeKernelExpansion.setCentersFromATD(), setCentersFromATD(), test_getStateJacobianInstance(), and toJSON().
kernels.KernelExpansion.ComponentNorms |
Returns the native space norms \(||f_j||^2_\H\) for each component function \(j \equiv\)size(Ma,1)
Dependent
set to true. Definition at line 117 of file KernelExpansion.m.
|
protected |
The inner (state) kernel object.
Default: kernels.GaussKernel;
SetAccess = Private, GetAccess = Protected
Definition at line 234 of file KernelExpansion.m.
Referenced by clone(), getKernelMatrix(), getKernelMatrixColumn(), kernels.ParamTimeKernelExpansion.getKernelVector(), getKernelVector(), kernels.ParamTimeKernelExpansion.getStateJacobian(), KernelExpansion(), and loadobj().
kernels.KernelExpansion.HasCustomBase |
Flag that indicates if a base other than the direct translate base is used for this kernel expansion.
Default: false
Dependent
set to true. Definition at line 143 of file KernelExpansion.m.
Referenced by toJSON().
kernels.KernelExpansion.Kernel |
The Kernel to use for system variables.
Default: kernels.GaussKernel
Dependent
set to true. SetObservable
set to true. Definition at line 68 of file KernelExpansion.m.
Referenced by exportToDirectory(), kernels.ParamTimeKernelExpansion.getGlobalLipschitz(), getGlobalLipschitz(), loadobj(), and test_getStateJacobianInstance().
kernels.KernelExpansion.Ma = "[]" |
The coefficient data for each dimension.
Default: []
SetObservable
set to true. Definition at line 195 of file KernelExpansion.m.
Referenced by clear(), clone(), kernels.ParamTimeKernelExpansion.evaluate(), evaluate(), exportToDirectory(), kernels.ParamTimeKernelExpansion.getStateJacobian(), getStateJacobian(), loadobj(), normalize(), approx.KernelEI.project(), project(), scalarProductWith(), toJSON(), and uminus().
kernels.KernelExpansion.Ma_norms |
The norms of the coefficient matrix of the kernel expansion.
Dependent
set to true. Definition at line 89 of file KernelExpansion.m.
Referenced by kernels.ParamTimeKernelExpansion.getGlobalLipschitz(), and getGlobalLipschitz().
kernels.KernelExpansion.MBnd |
Returns the M upper bound for this KernelExpansion, which is \(M := \max\limits_{j=1}^d\sum\limits_{i=1}^m |c^d_i|\).
Dependent
set to true. Definition at line 131 of file KernelExpansion.m.
kernels.KernelExpansion.NativeNorm |
Returns the norm \(||f||^2_{\H^q}\) of \(f\) in the RKHS \(\H^q,\quad q\in\N\).
Returns the native norm of the kernel expansion.
For \(q=1\) this equals the ComponentNorms output.
Dependent
set to true. Definition at line 102 of file KernelExpansion.m.
Referenced by normalize().
kernels.KernelExpansion.Size |
The size of the kernel expansion.
Dependent
set to true. Definition at line 157 of file KernelExpansion.m.