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
AffParamKernelTest.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  AffParamKernelTest(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  this.Sampler= sampling.GridSampler;
75 
76  /* This class implements a fake Approx subclass to allow access
77  * to the this.Ma property for the error estimator. */
78  this.Approx= [];
79 
80  s = spacereduction.PODReducer;
81  s.UseSVDS= true;
82  s.Mode= " abs ";
83  s.Value= 1;
84  this.SpaceReducer= s;
85 
86  this.ODESolver= solvers.ExplEuler;
87 
88  /* % System settings */
89  this.System= models.synth.AffParamKernelTestSys(this, pos_flag);
90  this.DefaultInput= 1;
91  this.TrainingInputs= 1;
92 
93  /* % Error estimator */
94  this.ErrorEstimator= error.IterationCompLemmaEstimator;
95  }
96 
97 
98 
99 #if 0 //mtoc++: 'set.dim'
100 function dim(value) {
101  if round(value) ~= value || ~isscalar(value) || value <= 0
102  error(" Value must be a positive integer scalar ");
103  end
104  this.dim= value;
105  }
106 
107 #endif
108 
109 
110  public: /* ( Static ) */ /* ( setObservable ) */
111 
112 
113  static function res = test_RunAffParamKernelTests() {
114  t = [];
115  for k=1:11
116  eval(sprintf(" t = models.synth.AffParamKernelTest.getTest%d; ",k))
117  fprintf(" --------------- Running test getTest%d ---------------\n ",k);
118  models.synth.AffParamKernelTest.runTest(t);
119  end
120  res = true;
121  }
122 
123 
124  static function r = runTest(models.BaseFullModel model) {
125  model.offlineGenerations;
126  r = model.buildReducedModel;
127  ma = ModelAnalyzer(r);
128  pm = ma.analyzeError;
129  pm.LeaveOpen= true;
130  }
131 
132 
133  static function m = getTest1(varargin) {
134  m = models.synth.AffParamKernelTest(varargin[:]);
135 
136  V = ones(m.dim,1)*sqrt(1/m.dim);
137  m.SpaceReducer= spacereduction.ManualReduction(V);
138  }
139 
140 
141  static function m = getTest2(varargin) {
142  m = models.synth.AffParamKernelTest(varargin[:]);
143 
144  m.System.Inputs[1] = @(t)4;
145  m.System.B= dscomponents.LinearInputConv(ones(m.dim,1));
146 
147  V = ones(m.dim,1)*sqrt(1/m.dim);
148  m.SpaceReducer= spacereduction.ManualReduction(V);
149  }
150 
151 
152  static function m = getTest3(varargin) {
153  m = models.synth.AffParamKernelTest(varargin[:]);
154  m.System.x0= dscomponents.ConstInitialValue(rand(m.dim,1));
155  }
156 
157 
158  static function m = getTest4(varargin) {
159  m = models.synth.AffParamKernelTest(varargin[:]);
160  m.System.x0= dscomponents.ConstInitialValue(rand(m.dim,1));
161  V = ones(m.dim,1)*sqrt(1/m.dim);
162  m.SpaceReducer= spacereduction.ManualReduction(V);
163  }
164 
165 
166  static function m = getTest5(varargin) {
167  m = models.synth.AffParamKernelTest(varargin[:]);
168 
169  m.System.B= dscomponents.LinearInputConv(rand(m.dim,1));
170  m.System.Inputs[1] = @(t)4;
171  }
172 
173 
174  static function m = getTest6(varargin) {
175  m = models.synth.AffParamKernelTest(varargin[:]);
176 
177  m.System.B= dscomponents.LinearInputConv(rand(m.dim,1));
178  m.System.Inputs[1] = @(t)4;
179 
180  V = ones(m.dim,1)*sqrt(1/m.dim);
181  m.SpaceReducer= spacereduction.ManualReduction(V);
182  }
183 
184 
185  static function m = getTest7(varargin) {
186  m = models.synth.AffParamKernelTest(varargin[:]);
187 
188  m.System.Inputs[1] = @(t)4;
189 
190  B = ones(m.dim,1);
191  B(1:m.dim/2) = -1;
192  m.System.B= dscomponents.LinearInputConv(B);
193  }
194 
195 
196  static function m = getTest8(varargin) {
197  m = models.synth.AffParamKernelTest(varargin[:]);
198 
199  m.System.Inputs[1] = @(t)4;
200 
201  B = ones(m.dim,1);
202  B(1:m.dim/2) = -1;
203  m.System.B= dscomponents.LinearInputConv(B);
204 
205  V = ones(m.dim,1)*sqrt(1/m.dim);
206  m.SpaceReducer= spacereduction.ManualReduction(V);
207  }
208 
209 
210  static function m = getTest9(varargin) {
211  m = models.synth.AffParamKernelTest(varargin[:]);
212 
213  m.System.Inputs[1] = @(t)4;
214 
215  m.System.x0= dscomponents.ConstInitialValue((rand(m.dim,1)-.5)*3);
216 
217  B = ones(m.dim,1);
218  B(1:m.dim/2) = -1;
219  m.System.B= dscomponents.LinearInputConv(B);
220 
221  V = ones(m.dim,1)*sqrt(1/m.dim);
222  m.SpaceReducer= spacereduction.ManualReduction(V);
223  }
224 
225 
226  static function m = getTest10(varargin) {
227  m = models.synth.AffParamKernelTest(varargin[:]);
228  m.T= 20;
229 
230  m.System.Inputs[1] = @(t)sin(2*t);
231 
232  m.System.x0= dscomponents.ConstInitialValue((rand(m.dim,1)-.5)*3);
233 
234  B = ones(m.dim,1);
235  B(1:m.dim/2) = -1;
236  m.System.B= dscomponents.LinearInputConv(B);
237 
238  V = ones(m.dim,1)*sqrt(1/m.dim);
239  m.SpaceReducer= spacereduction.ManualReduction(V);
240  }
241 
242 
243  static function m = getTest11(varargin) {
244  m = models.synth.AffParamKernelTest(varargin[:]);
245  m.T= 20;
246 
247  m.System.B= dscomponents.LinearInputConv(rand(m.dim,1));
248  m.System.Inputs[1] = @(t)sin(2*t);
249  }
250 
251 
257 };
258 }
259 }
260 
261 
262 
ModelAnalyzer: Analysis tools for reduced models and approximations.
Definition: ModelAnalyzer.m:17
char Name
The name of the Model.
Definition: BaseModel.m:117
Kernel core function test model 1.
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
integer TrainingInputs
The indices of inputs to use for training data generation. Uses the DefaultInput if not set (and Defa...
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 = getTest2(varargin)
static function r = runTest(models.BaseFullModel model)
function registerProps(varargin)
Call this method at any class that defines DPCM observed properties.
Definition: DPCMObject.m:125
static function m = getTest11(varargin)
static function m = getTest8(varargin)
static function m = getTest1(varargin)
static function m = getTest10(varargin)
static function res = test_RunAffParamKernelTests()
A variable number of input arguments.
static function m = getTest7(varargin)
static function m = getTest3(varargin)
solvers.BaseSolver ODESolver
The solver to use for the ODE. Must be an instance of any solvers.BaseSolver subclass.
Definition: BaseModel.m:315
integer DefaultInput
The default input to use if none is given.
Definition: BaseModel.m:189
approx.BaseApprox Approx
The approximation method for the CoreFunction.
double T
The final timestep up to which to simulate.
Definition: BaseModel.m:271
dim
The system's dimension.
static function m = getTest4(varargin)
spacereduction.BaseSpaceReducer SpaceReducer
The reduction algorithm for subspaces.
static function m = getTest6(varargin)
static function m = getTest9(varargin)
function offlineGenerations()
Performs all large offline computations for model reduction.
static function m = getTest5(varargin)