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
KernelTest.m
Go to the documentation of this file.
1 namespace models{
2 namespace synth{
3 
4 
5 /* (Autoinserted by mtoc++)
6  * This source code has been filtered by the mtoc++ executable,
7  * which generates code that can be processed by the doxygen documentation tool.
8  *
9  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
10  * Except for the comments, the function bodies of your M-file functions are untouched.
11  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
12  * attached source files that are highly readable by humans.
13  *
14  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
15  * the correct locations in the source code browser.
16  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
17  */
18 
20  :public models.BaseFullModel {
37  public: /* ( setObservable ) */
38 
39  dim;
52  public: /* ( setObservable ) */
53 
54 
55  KernelTest(dims,pos_flag) {
56 
57  this.registerProps(" dim ");
58 
59  if nargin < 2
60  pos_flag = false;
61  if nargin < 1
62  dims = 1000;
63  end
64  end
65  this.dim= dims;
66 
67 
68  /* % Model settings */
69  this.Name= " Kernel test model ";
70 
71  this.T= 5;
72  this.dt= .08;
73 
74  /* % System settings */
75  this.System= models.synth.KernelTestSys(this, pos_flag);
76  this.System.MaxTimestep= this.dt;
77 
78  this.Sampler= sampling.GridSampler;
79 
80  /* This class implements a fake Approx subclass to allow access
81  * to the this.Ma property for the error estimator. */
82  a = approx.KernelApprox(this.System);
83  a.Algorithm= approx.algorithms.Componentwise;
84  ec = kernels.config.ParamTimeExpansionConfig;
85  ec.StateConfig= kernels.config.GaussConfig(" G ",1);
86  ec.ParamConfig= kernels.config.GaussConfig(" G ",1);
87  ec.ParamConfig= kernels.config.GaussConfig(" G ",1);
88  a.Algorithm.ExpConfig= ec;
89 
90  a.TrainDataSelector= data.selection.LinspaceSelector;
91  a.TrainDataSelector.Size= 150;
92  this.Approx= a;
93 
94  s = spacereduction.PODReducer;
95  s.UseSVDS= true;
96  s.Mode= " abs ";
97  s.Value= 1;
98  this.SpaceReducer= s;
99 
100  /* % ODE Solver */
101  this.ODESolver= solvers.ExplEuler;
102 
103  /* % Error estimator */
104  this.ErrorEstimator= error.IterationCompLemmaEstimator;
105  }
106 
107 
108 
109 #if 0 //mtoc++: 'set.dim'
110 function dim(value) {
111  if ~isposintscalar(value)
112  error(" Value must be a positive integer scalar ");
113  end
114  this.dim= value;
115  }
116 
117 #endif
118 
119 
120  public: /* ( Static ) */ /* ( setObservable ) */
121 
122 
123  static function res = test_RunKernelTests() {
124  t = [];
125  for k=1:11
126  eval(sprintf(" t = models.synth.KernelTest.getTest%d; ",k))
127  fprintf(" --------------- Running test getTest%d ---------------\n ",k);
128  models.synth.KernelTest.runTest(t);
129  end
130  res = true;
131  }
132 
133 
134  static function r = runTest(models.BaseFullModel model) {
135  model.offlineGenerations;
136  r = model.buildReducedModel;
137  ma = ModelAnalyzer(r);
138  pm = ma.analyzeError(model.getRandomParam);
139  pm.LeaveOpen= true;
140  }
141 
142 
143  static function m = getTest1(varargin) {
144  m = models.synth.KernelTest(varargin[:]);
145 
146  V = ones(m.dim,1)*sqrt(1/m.dim);
147  m.SpaceReducer= spacereduction.ManualReduction(V);
148  }
149 
150 
151  static function m = getTest2(varargin) {
152  m = models.synth.KernelTest(varargin[:]);
153 
154  m.System.Inputs[1] = @(t)4;
155  m.System.B= dscomponents.LinearInputConv(ones(m.dim,1));
156  m.DefaultInput= 1;
157 
158  V = ones(m.dim,1)*sqrt(1/m.dim);
159  m.SpaceReducer= spacereduction.ManualReduction(V);
160  }
161 
162 
163  static function m = getTest3(varargin) {
164  m = models.synth.KernelTest(varargin[:]);
165  m.System.x0= dscomponents.ConstInitialValue(rand(m.dim,1));
166  }
167 
168 
169  static function m = getTest4(varargin) {
170  m = models.synth.KernelTest(varargin[:]);
171  m.System.x0= dscomponents.ConstInitialValue(rand(m.dim,1));
172  V = ones(m.dim,1)*sqrt(1/m.dim);
173  m.SpaceReducer= spacereduction.ManualReduction(V);
174  }
175 
176 
177  static function m = getTest5(varargin) {
178  m = models.synth.KernelTest(varargin[:]);
179 
180  m.System.B= dscomponents.LinearInputConv(rand(m.dim,1));
181  m.System.Inputs[1] = @(t)4;
182  m.DefaultInput= 1;
183  }
184 
185 
186  static function m = getTest6(varargin) {
187  m = models.synth.KernelTest(varargin[:]);
188 
189  m.System.B= dscomponents.LinearInputConv(rand(m.dim,1));
190  m.System.Inputs[1] = @(t)4;
191  m.DefaultInput= 1;
192 
193  V = ones(m.dim,1)*sqrt(1/m.dim);
194  m.SpaceReducer= spacereduction.ManualReduction(V);
195  }
196 
197 
198  static function m = getTest7(varargin) {
199  m = models.synth.KernelTest(varargin[:]);
200 
201  m.System.Inputs[1] = @(t)4;
202  m.DefaultInput= 1;
203 
204  B = ones(m.dim,1);
205  B(1:m.dim/2) = -1;
206  m.System.B= dscomponents.LinearInputConv(B);
207  }
208 
209 
210  static function m = getTest8(varargin) {
211  m = models.synth.KernelTest(varargin[:]);
212 
213  m.System.Inputs[1] = @(t)4;
214  m.DefaultInput= 1;
215 
216  B = ones(m.dim,1);
217  B(1:m.dim/2) = -1;
218  m.System.B= dscomponents.LinearInputConv(B);
219 
220  V = ones(m.dim,1)*sqrt(1/m.dim);
221  m.SpaceReducer= spacereduction.ManualReduction(V);
222  }
223 
224 
225  static function m = getTest9(varargin) {
226  m = models.synth.KernelTest(varargin[:]);
227 
228  m.System.Inputs[1] = @(t)4;
229  m.DefaultInput= 1;
230 
231  m.System.x0= dscomponents.ConstInitialValue((rand(m.dim,1)-.5)*3);
232 
233  B = ones(m.dim,1);
234  B(1:m.dim/2) = -1;
235  m.System.B= dscomponents.LinearInputConv(B);
236 
237  V = ones(m.dim,1)*sqrt(1/m.dim);
238  m.SpaceReducer= spacereduction.ManualReduction(V);
239  }
240 
241 
242  static function m = getTest10(varargin) {
243  m = models.synth.KernelTest(varargin[:]);
244  m.T= 20;
245 
246  m.System.Inputs[1] = @(t)sin(2*t);
247  m.DefaultInput= 1;
248 
249  m.System.x0= dscomponents.ConstInitialValue((rand(m.dim,1)-.5)*3);
250 
251  B = ones(m.dim,1);
252  B(1:m.dim/2) = -1;
253  m.System.B= dscomponents.LinearInputConv(B);
254 
255  V = ones(m.dim,1)*sqrt(1/m.dim);
256  m.SpaceReducer= spacereduction.ManualReduction(V);
257  }
258 
259 
260  static function m = getTest11(varargin) {
261  m = models.synth.KernelTest(varargin[:]);
262  m.T= 20;
263 
264  m.System.B= dscomponents.LinearInputConv(rand(m.dim,1));
265  m.System.Inputs[1] = @(t)sin(2*t);
266  m.DefaultInput= 1;
267  }
268 
269 
275 };
276 }
277 }
278 
279 
280 
ModelAnalyzer: Analysis tools for reduced models and approximations.
Definition: ModelAnalyzer.m:17
static function r = runTest(models.BaseFullModel model)
Definition: KernelTest.m:134
char Name
The name of the Model.
Definition: BaseModel.m:117
static function m = getTest6(varargin)
Definition: KernelTest.m:186
error.BaseEstimator ErrorEstimator
The associated error estimator for this model.
function [ models.ReducedModel reduced , double time ] = buildReducedModel(varargin)
Builds a reduced model from a full model.
The base class for any KerMor detailed model.
Definition: BaseFullModel.m:18
double dt
The desired time-stepsize for simulations.
Definition: BaseModel.m:291
sampling.BaseSampler Sampler
The sampling strategy the Model uses.
models.BaseFirstOrderSystem System
The actual dynamical system used in the model.
Definition: BaseModel.m:102
static function m = getTest11(varargin)
Definition: KernelTest.m:260
function registerProps(varargin)
Call this method at any class that defines DPCM observed properties.
Definition: DPCMObject.m:125
An integer value.
KernelTest(dims, pos_flag)
Definition: KernelTest.m:55
dim
The system's dimension.
Definition: KernelTest.m:39
static function m = getTest2(varargin)
Definition: KernelTest.m:151
A variable number of input arguments.
static function m = getTest5(varargin)
Definition: KernelTest.m:177
solvers.BaseSolver ODESolver
The solver to use for the ODE. Must be an instance of any solvers.BaseSolver subclass.
Definition: BaseModel.m:315
static function m = getTest9(varargin)
Definition: KernelTest.m:225
approx.BaseApprox Approx
The approximation method for the CoreFunction.
double T
The final timestep up to which to simulate.
Definition: BaseModel.m:271
spacereduction.BaseSpaceReducer SpaceReducer
The reduction algorithm for subspaces.
static function m = getTest10(varargin)
Definition: KernelTest.m:242
function offlineGenerations()
Performs all large offline computations for model reduction.
Kernel core function test model 1.
Definition: KernelTest.m:19
static function m = getTest4(varargin)
Definition: KernelTest.m:169
static function m = getTest8(varargin)
Definition: KernelTest.m:210
function res = isposintscalar(value)
isposintscalar: Backwards-compatibility function for matlab versions greater than 2012a ...
static function m = getTest3(varargin)
Definition: KernelTest.m:163
static function m = getTest7(varargin)
Definition: KernelTest.m:198
double MaxTimestep
The maximum timestep allowed for any ODE solvers.
function matrix< double > mu = getRandomParam(integer num,integer seed)
Gets a random parameter sample from the system's parameter domain P.
Definition: BaseModel.m:763
static function m = getTest1(varargin)
Definition: KernelTest.m:143
static function res = test_RunKernelTests()
Definition: KernelTest.m:123