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
BaseCoreFun.m
Go to the documentation of this file.
1 namespace models{
2 namespace pcdi{
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 
39  public: /* ( Constant ) */
40 
41  static const .double ActivationTransitionTime = 10;
56  static const .double MaxActivationTime = 400;
79  public: /* ( Dependent ) */
80 
100  protected:
101 
103 
104 
106 
107 
109 
110 
111  Ji;
112 
113  Jj;
114 
115 
116  private:
117 
118  gaussian;
119 
120  fAFT = 1;
121 
122  fTau;
123 
124 
125  public:
126 
127  BaseCoreFun(dynsys) {
128  this = this@dscomponents.ACompEvalCoreFun(dynsys);
129  this.TimeDependent= true;
130 
131  this.fTau= dynsys.Model.tau;
132 
133  this.ActivationFunType= 2;
134  }
135 
136 
137  function copy = clone(copy) {
138  copy = clone@dscomponents.ACompEvalCoreFun(this, copy);
139  copy.gaussian= this.gaussian.clone;
140  copy.fTau= this.fTau;
141  copy.fAFT= this.fAFT;
142  }
154  function fx = evaluateCoreFun(colvec<double> x,double t) {
155  error(" This model overrides evaluate directly. ");
156  }
157 
158 
160  if nargin < 3
161  pm = PlotManager;
162  pm.LeaveOpen= true;
163  if nargin < 2
164  mu = this.System.Model.getRandomParam;
165 
166  end
167  end
168 
169  h = pm.nextPlot(" activation_fun "," External input activation function "," time "," factor ");
170  t = linspace(0,min(this.System.Model.T,this.MaxActivationTime*1.2),2000);
171  plot(h,t,this.activationFun(t/this.System.Model.tau,mu));
172 
173  if nargin < 3
174  pm.done;
175  end
176  }
177 
178 
179 
180 #if 0 //mtoc++: 'set.ActivationFunType'
181 function ActivationFunType(value) {
182  if value == 1
183  /* \gamma=28 is such that we have K(0,27)~<.4 (27=150/tau) */
184  k = kernels.GaussKernel(28.206364723698);
185  else
186  k = kernels.GaussKernel;
187  k.setGammaForDistance(this.ActivationTransitionTime/this.System.Model.tau,.001);
188  end
189  this.gaussian= k;
190  this.fAFT= value;
191  }
192 
193 #endif
194 
201 #if 0 //mtoc++: 'get.ActivationFunType'
202 function value = ActivationFunType() {
203  value = this.fAFT;
204  }
205 
206 #endif
207 
208 
209  protected:
210 
211 
212  function idx = nodepos(nr) {
213  n = this.nodes;
214  idx = zeros(1,n*length(nr));
215  for k=1:length(nr)
216  idx((k-1)*n+1:k*n) = (nr(k)-1)*this.nodes+1:nr(k)*this.nodes;
217  end
218  }
219 
220 
221  function f = activationFun(double t,colvec<double> mu) {
222  if this.fAFT == 1
223  f = (this.gaussian.evaluateScalar(t-27)-.4).*(t<=54)/.6;
224  else
225  tau = this.fTau;
226  ts = this.ActivationTransitionTime/tau;
227  if isscalar(t)
228  te = ts+(mu(3)*(this.MaxActivationTime-2*this.ActivationTransitionTime))/tau;
229  if t > te+ts
230  f = 0;
231  elseif t > ts && t <= te
232  f = 1;
233  elseif t <= ts
234  f = (this.gaussian.evaluateScalar(t-ts)-.001)/.999;
235  elseif t>te && t<=te+ts
236  f = (this.gaussian.evaluateScalar(t-te)-.001)/.999;
237  else
238  f = 0;
239  end
240  else
241  te = ts+(mu(3,:)*(this.MaxActivationTime-2*this.ActivationTransitionTime))/tau;
242  f = (this.gaussian.evaluateScalar(t-ts)-.001).*(t<=ts)/.999 ...
243  + (t>ts).*(t<=te) ...
244  + (this.gaussian.evaluateScalar(t-te)-.001).*(t>te).*(t<=te+ts)/.999;
245  end
246  end
247  }
248 
249 
255 };
256 }
257 }
258 
integer ActivationFunType
Type of the activation function.
Definition: BaseCoreFun.m:81
function idx = nodepos(nr)
Definition: BaseCoreFun.m:212
logical TimeDependent
Flag that indicates if the ACoreFun is (truly) time-dependent.
Definition: ACoreFun.m:84
Model
The Model this System is attached to.
An integer value.
PlotManager: Small class that allows the same plots generated by some script to be either organized a...
Definition: PlotManager.m:17
static const .double ActivationTransitionTime
The time in seconds needed before the activation function reaches its maximum value and decays back t...
Definition: BaseCoreFun.m:41
logical LeaveOpen
Flag indicating if the plots should be left open once the PlotManager is deleted (as variable) ...
Definition: PlotManager.m:213
models.BaseFirstOrderSystem System
The system associated with the current ACoreFun.
Definition: ACoreFun.m:193
function f = activationFun(double t,colvec< double > mu)
Definition: BaseCoreFun.m:221
colvec< double > mu
The current model parameter mu for evaluations. Will not be persisted as only valid for runtime durin...
Definition: ACoreFun.m:208
function fx = evaluateCoreFun(colvec< double > x,double t)
Actual method used to evaluate the dynamical sytems' core function.
Definition: BaseCoreFun.m:154
ACompEvalCoreFun: A normal CoreFun which supports single-component evaluation.
function copy = clone(copy)
Call superclass method.
Definition: BaseCoreFun.m:137
function plotActivationFun(colvec< double > mu, pm)
Definition: BaseCoreFun.m:159
static const .double MaxActivationTime
The maximum time in seconds that spans the support of the piecewise activation function. It is composed of gaussian-shaped increase/decrease ends and a constant one in between. For the default settings, we would have a maximum duration of 500s-2*30s=440s for the activation rate of level one. [s].
Definition: BaseCoreFun.m:56