KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ParamTimeKernelExpansion.m
Go to the documentation of this file.
1 namespace kernels{
2 
3 
4 /* (Autoinserted by mtoc++)
5  * This source code has been filtered by the mtoc++ executable,
6  * which generates code that can be processed by the doxygen documentation tool.
7  *
8  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
9  * Except for the comments, the function bodies of your M-file functions are untouched.
10  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
11  * attached source files that are highly readable by humans.
12  *
13  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
14  * the correct locations in the source code browser.
15  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
16  */
17 
19  :public kernels.KernelExpansion {
72  public: /* ( Dependent, setObservable ) */
73 
112  public: /* ( setObservable ) */
113 
114  SubKernelCombinationFun = @("t,s,p")t .* s .* p;
133  StateNablaCombinationFun = @("t,s,p)bsxfun(\@times, s, t.*p");
151  private:
152 
153  fTK;
154 
155  fPK;
156 
157 
158  public:
159 
161 
162  /* Set custom projection to true as the project method is
163  * overridden */
164  this = this@kernels.KernelExpansion;
165 
166  this.Centers.ti= [];
167  this.Centers.mui= [];
168 
169  /* The default kernels for time and parameters are neutral (=1)
170  * kernels as not all models have time or parameter dependent
171  * system functions. */
172  this.fTK= kernels.NoKernel;
173  this.fPK= kernels.NoKernel;
174 
175  /* DONT CHANGE THIS LINE unless you know what you are doing or
176  * you are me :-)
177  * this.updateRotInv; */
178 
179  this.registerProps(" TimeKernel "," ParamKernel ",...
180  " SubKernelCombinationFun "," StateNablaCombinationFun ");
181  }
190  function fx = evaluate(colvec<double> x,double t,colvec<double> mu) {
191  fx = this.Ma * (this.Base \ this.getKernelVector(x, t, mu)^t);
192  }
193 
194 
195  function phi = getKernelVector(colvec<double> x,double t,colvec<double> mu) {
196  phi = this.SubKernelCombinationFun(...
197  this.fTK.evaluate(t, this.Centers.ti), ...
198  this.fSK.evaluate(x, this.Centers.xi), ...
199  this.fPK.evaluate(mu, this.Centers.mui));
200  }
213  function J = getStateJacobian(colvec<double> x,double t,colvec<double> mu) {
214  if size(x, 2) > 1
215  error(" Derivaties only possible for single vector/point, as already returning a matrix with derivatives at all centers. ");
216  end
217  N = this.StateNablaCombinationFun(...
218  this.fTK.evaluate(t, this.Centers.ti),...
219  this.fSK.getNabla(x, this.Centers.xi),...
220  this.fPK.evaluate(mu, this.Centers.mui));
221  J = this.Ma * N^t;
222  }
239  function c = getGlobalLipschitz(double t,colvec<double> mu) {
240  k = this.TimeKernel.evaluate(this.Centers.ti,t).*this.ParamKernel.evaluate(this.Centers.mui,mu);
241  c = sum(this.Ma_norms .* k^t) * this.Kernel.getGlobalLipschitz;
242  /* warning('KerMor:globallipschitz','not yet implemented/validated correctly!'); */
243  }
255  function K = getKernelMatrix() {
256  K = [];
257  if ~isempty(this.Centers)
258  K = this.SubKernelCombinationFun(...
259  this.fTK.evaluate(this.Centers.ti,[]), ...
260  getKernelMatrix@kernels.KernelExpansion(this), ...
261  this.fPK.evaluate(this.Centers.mui,[]));
262  end
263  }
279  function K = getKernelMatrixColumn(idx,colvec<double> x,double t,colvec<double> mu) {
280  K = [];
281  if nargin < 3
282  x = this.Centers.xi;
283  t = this.Centers.ti;
284  mu = this.Centers.mui;
285  end
286  if ~isempty(this.Centers)
287  K = this.SubKernelCombinationFun(...
288  this.fTK.evaluate(t,t(idx)), ...
289  getKernelMatrixColumn@kernels.KernelExpansion(this, idx, x), ...
290  this.fPK.evaluate(mu,mu(:,idx)));
291  end
292  }
313  setCentersFromATD@kernels.KernelExpansion(this, atd, idx);
314  if atd.hasTime
315  this.Centers.ti= atd.ti(:,idx);
316  end
317  if atd.hasParams
318  this.Centers.mui= atd.mui(:,idx);
319  end
320  }
334  function copy = clone(copy) {
335  if nargin == 1
336  copy = kernels.ParamTimeKernelExpansion;
337  end
338  /* Copy local variables */
339  copy = clone@kernels.KernelExpansion(this, copy);
340  copy.SubKernelCombinationFun= this.SubKernelCombinationFun;
341  copy.StateNablaCombinationFun= this.StateNablaCombinationFun;
342  copy.fTK= this.fTK.clone;
343  copy.fPK= this.fPK.clone;
344  }
345 
346 
347  function clear() {
348  clear@kernels.KernelExpansion(this);
349  this.Centers.ti= [];
350  this.Centers.mui= [];
351  }
359  /* % Getter & Setter */
360  public:
361 
362 
363 #if 0 //mtoc++: 'set.SubKernelCombinationFun'
364 function SubKernelCombinationFun(fhandle) {
365  if ~isa(fhandle," function_handle ")
366  error(" SubKernelCombinationFun must be a function handle. ");
367  elseif nargin(fhandle) ~= 3
368  error(" SubKernelCombinationFun must take exactly three input arguments. ");
369  end
370  this.SubKernelCombinationFun= fhandle;
371  }
372 
373 #endif
374 
375 
376 
377 #if 0 //mtoc++: 'get.ParamKernel'
378 function k = ParamKernel() {
379  k = this.fPK;
380  }
381 
382 #endif
383 
384 
385 
386 #if 0 //mtoc++: 'get.TimeKernel'
387 function k = TimeKernel() {
388  k = this.fTK;
389  }
390 
391 #endif
392 
393 
394 
395 #if 0 //mtoc++: 'set.ParamKernel'
396 function ParamKernel(value) {
397  if isa(value," kernels.BaseKernel ")
398  this.fPK= value;
399  else
400  error(" ParamKernel must be a subclass of kernels.BaseKernel. ");
401  end
402  }
403 
404 #endif
405 
406 
407 
408 #if 0 //mtoc++: 'set.TimeKernel'
409 function TimeKernel(value) {
410  if isa(value," kernels.BaseKernel ")
411  this.fTK= value;
412  else
413  error(" TimeKernel must be a subclass of kernels.BaseKernel. ");
414  end
415  }
416 
417 #endif
418 
432 };
433 }
434 
kernels.BaseKernel ParamKernel
The Kernel to use for parameter variables.
matrix< double > Ma
The coefficient data for each dimension.
logical hasParams
Flag that indicates if param samples are present.
function K = getKernelMatrixColumn(idx,colvec< double > x,double t,colvec< double > mu)
Computes the kernel matrix for the currently set center data.
function clear()
Removes all centers and coefficients from the expansion and leaves the associated kernels untouched...
function phi = getKernelVector(colvec< double > x,double t,colvec< double > mu)
Returns the kernel vector . (for the case of a product SubKernelCombinationFun
ParamTimeKernelExpansion()
Default constructor.
function registerProps(varargin)
Call this method at any class that defines DPCM observed properties.
Definition: DPCMObject.m:125
virtual function Nabla = getNabla(x, y)
Computes the partial derivatives with respect to each component of the first argument.
virtual function c = getGlobalLipschitz()
Returns the global lipschitz constant of this kernel.
function fx = evaluate(colvec< double > x,double t,colvec< double > mu)
Matlab's base handle class (documentation generation substitute)
rowvec ti
The time samples .
function c = getGlobalLipschitz(double t,colvec< double > mu)
Overrides the implementation in KernelExpansion.
kernels.BaseKernel fSK
The inner (state) kernel object.
rowvec Ma_norms
The norms of the coefficient matrix of the kernel expansion.
kernels.BaseKernel Kernel
The Kernel to use for system variables.
logical hasTime
Flag that indicates if time samples are present.
matrix mui
The parameter samples used computing the parent trajectories of .
StateNablaCombinationFun
The combination function for the nabla of the system/state kernel with the other kernels.
ParamTimeKernelExpansion: Kernel expansion class for time and/or parameter dependent kernels...
kernels.BaseKernel TimeKernel
The Kernel to use for time variables.
function J = getStateJacobian(colvec< double > x,double t,colvec< double > mu)
Evaluates the jacobian matrix of this function at the given point.
function K = getKernelMatrix()
Computes the kernel matrix for the currently set center data.
function setCentersFromATD(data.ApproxTrainData atd,rowvec< integer > idx)
Sets the centers according to the indices idx of the training data.
ApproxTrainData: Data class for approximation training data, containing several useful bounding box p...
struct Centers
The kernel centers used in the approximation.
SubKernelCombinationFun
The function that combines the sub (time/system/param) kernels. Must be a function handle that takes ...
function copy = clone(copy)
The interface method with returns a copy of the current class instance.
virtual function K = evaluate(matrix< double > x,matrix< double > y)
Evaluation method for the current kernel.
Base class for all KerMor Kernels.
Definition: BaseKernel.m:18
KernelExpansion: Base class for state-space kernel expansions.