1 | using System;
|
---|
2 | using HeuristicLab.Common;
|
---|
3 | using HeuristicLab.Core;
|
---|
4 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
5 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
6 | using HeuristicLab.Random;
|
---|
7 |
|
---|
8 | namespace HeuristicLab.Problems.GaussianProcessTuning {
|
---|
9 |
|
---|
10 | [StorableClass]
|
---|
11 | public sealed class EmptyTerminalTreeNode : SymbolicExpressionTreeTerminalNode {
|
---|
12 | [StorableConstructor]
|
---|
13 | private EmptyTerminalTreeNode(bool deserializing) : base(deserializing) { }
|
---|
14 | private EmptyTerminalTreeNode(EmptyTerminalTreeNode original, Cloner cloner)
|
---|
15 | : base(original, cloner) {
|
---|
16 | }
|
---|
17 | public EmptyTerminalTreeNode(ISymbol symbol)
|
---|
18 | : base(symbol) {
|
---|
19 | }
|
---|
20 |
|
---|
21 | [StorableHook(HookType.AfterDeserialization)]
|
---|
22 | private void AfterDeserialization() {
|
---|
23 | }
|
---|
24 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
25 | return new EmptyTerminalTreeNode(this, cloner);
|
---|
26 | }
|
---|
27 | }
|
---|
28 | [StorableClass]
|
---|
29 | public sealed class MeanConstTreeNode : SymbolicExpressionTreeTerminalNode {
|
---|
30 | public new MeanConst Symbol { get { return (MeanConst)base.Symbol; } }
|
---|
31 |
|
---|
32 | public override bool HasLocalParameters {
|
---|
33 | get { return true; }
|
---|
34 | }
|
---|
35 |
|
---|
36 | private double value;
|
---|
37 | [Storable]
|
---|
38 | public double Value { get { return value; } private set { this.value = value; } }
|
---|
39 |
|
---|
40 | [StorableConstructor]
|
---|
41 | private MeanConstTreeNode(bool deserializing) : base(deserializing) { }
|
---|
42 | private MeanConstTreeNode(MeanConstTreeNode original, Cloner cloner)
|
---|
43 | : base(original, cloner) {
|
---|
44 | this.value = original.value;
|
---|
45 | }
|
---|
46 |
|
---|
47 | public MeanConstTreeNode() : base(new MeanConst()) { }
|
---|
48 |
|
---|
49 | [StorableHook(HookType.AfterDeserialization)]
|
---|
50 | private void AfterDeserialization() {
|
---|
51 | }
|
---|
52 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
53 | return new MeanConstTreeNode(this, cloner);
|
---|
54 | }
|
---|
55 | public override void ResetLocalParameters(IRandom random) {
|
---|
56 | value = Symbol.MinValue + random.NextDouble() * (Symbol.MaxValue - Symbol.MinValue);
|
---|
57 | }
|
---|
58 | public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
|
---|
59 | var normRandom = new NormalDistributedRandom(random, Symbol.ValueShakingMu, Symbol.ValueShakingSigma);
|
---|
60 | value = Math.Max(Symbol.MinValue, Math.Min(Symbol.MaxValue, value + normRandom.NextDouble() * shakingFactor));
|
---|
61 | }
|
---|
62 | }
|
---|
63 | [StorableClass]
|
---|
64 | public sealed class MeanLinearTreeNode : SymbolicExpressionTreeTerminalNode {
|
---|
65 | public new MeanLinear Symbol { get { return (MeanLinear)base.Symbol; } }
|
---|
66 |
|
---|
67 | public override bool HasLocalParameters {
|
---|
68 | get { return true; }
|
---|
69 | }
|
---|
70 |
|
---|
71 | [Storable]
|
---|
72 | public double[] Alpha { get; set; }
|
---|
73 |
|
---|
74 | [StorableConstructor]
|
---|
75 | private MeanLinearTreeNode(bool deserializing) : base(deserializing) { }
|
---|
76 | private MeanLinearTreeNode(MeanLinearTreeNode original, Cloner cloner)
|
---|
77 | : base(original, cloner) {
|
---|
78 | Alpha = new double[original.Alpha.Length];
|
---|
79 | Array.Copy(original.Alpha, Alpha, Alpha.Length);
|
---|
80 | }
|
---|
81 |
|
---|
82 | public MeanLinearTreeNode(MeanLinear symbol)
|
---|
83 | : base(symbol) {
|
---|
84 | Alpha = new double[symbol.Dimension];
|
---|
85 | }
|
---|
86 |
|
---|
87 | [StorableHook(HookType.AfterDeserialization)]
|
---|
88 | private void AfterDeserialization() {
|
---|
89 | }
|
---|
90 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
91 | return new MeanLinearTreeNode(this, cloner);
|
---|
92 | }
|
---|
93 | public override void ResetLocalParameters(IRandom random) {
|
---|
94 | var normRandom = new NormalDistributedRandom(random, Symbol.AlphaMu, Symbol.AlphaSigma);
|
---|
95 | for (int i = 0; i < Alpha.Length; i++)
|
---|
96 | Alpha[i] = normRandom.NextDouble();
|
---|
97 | }
|
---|
98 | public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
|
---|
99 | var normRandom = new NormalDistributedRandom(random, Symbol.AlphaShakingMu, Symbol.AlphaShakingSigma);
|
---|
100 | int index = random.Next(Alpha.Length);
|
---|
101 | Alpha[index] += shakingFactor * normRandom.NextDouble();
|
---|
102 | }
|
---|
103 | }
|
---|
104 |
|
---|
105 |
|
---|
106 | [StorableClass]
|
---|
107 | public sealed class MeanScaleTreeNode : SymbolicExpressionTreeNode {
|
---|
108 | public new MeanScale Symbol { get { return (MeanScale)base.Symbol; } }
|
---|
109 |
|
---|
110 | public override bool HasLocalParameters {
|
---|
111 | get { return true; }
|
---|
112 | }
|
---|
113 |
|
---|
114 | private double alpha;
|
---|
115 | [Storable]
|
---|
116 | public double Alpha { get { return alpha; } private set { this.alpha = value; } }
|
---|
117 |
|
---|
118 | [StorableConstructor]
|
---|
119 | private MeanScaleTreeNode(bool deserializing) : base(deserializing) { }
|
---|
120 | private MeanScaleTreeNode(MeanScaleTreeNode original, Cloner cloner)
|
---|
121 | : base(original, cloner) {
|
---|
122 | this.alpha = original.alpha;
|
---|
123 | }
|
---|
124 |
|
---|
125 | public MeanScaleTreeNode() : base(new MeanScale()) { }
|
---|
126 |
|
---|
127 | [StorableHook(HookType.AfterDeserialization)]
|
---|
128 | private void AfterDeserialization() {
|
---|
129 | }
|
---|
130 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
131 | return new MeanScaleTreeNode(this, cloner);
|
---|
132 | }
|
---|
133 | public override void ResetLocalParameters(IRandom random) {
|
---|
134 | var normRandom = new NormalDistributedRandom(random, Symbol.AlphaMu, Symbol.AlphaSigma);
|
---|
135 | alpha = normRandom.NextDouble();
|
---|
136 | }
|
---|
137 | public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
|
---|
138 | var normRandom = new NormalDistributedRandom(random, Symbol.AlphaShakingMu, Symbol.AlphaShakingSigma);
|
---|
139 | alpha += shakingFactor * normRandom.NextDouble();
|
---|
140 | }
|
---|
141 | }
|
---|
142 | [StorableClass]
|
---|
143 | public sealed class MeanMaskTreeNode : SymbolicExpressionTreeNode {
|
---|
144 | public new MeanMask Symbol { get { return (MeanMask)base.Symbol; } }
|
---|
145 |
|
---|
146 | public override bool HasLocalParameters {
|
---|
147 | get { return true; }
|
---|
148 | }
|
---|
149 |
|
---|
150 | [Storable]
|
---|
151 | public bool[] Mask { get; set; }
|
---|
152 |
|
---|
153 | [StorableConstructor]
|
---|
154 | private MeanMaskTreeNode(bool deserializing) : base(deserializing) { }
|
---|
155 | private MeanMaskTreeNode(MeanMaskTreeNode original, Cloner cloner)
|
---|
156 | : base(original, cloner) {
|
---|
157 | Mask = new bool[original.Mask.Length];
|
---|
158 | Array.Copy(original.Mask, Mask, Mask.Length);
|
---|
159 | }
|
---|
160 |
|
---|
161 | public MeanMaskTreeNode(MeanMask symbol)
|
---|
162 | : base(symbol) {
|
---|
163 | Mask = new bool[symbol.Dimension];
|
---|
164 | }
|
---|
165 |
|
---|
166 | [StorableHook(HookType.AfterDeserialization)]
|
---|
167 | private void AfterDeserialization() {
|
---|
168 | }
|
---|
169 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
170 | return new MeanMaskTreeNode(this, cloner);
|
---|
171 | }
|
---|
172 | public override void ResetLocalParameters(IRandom random) {
|
---|
173 | for (int i = 0; i < Mask.Length; i++)
|
---|
174 | Mask[i] = random.NextDouble() < Symbol.MaskingProbability;
|
---|
175 | }
|
---|
176 | public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
|
---|
177 | // one point bit flip
|
---|
178 | int i = random.Next(Mask.Length);
|
---|
179 | Mask[i] = !Mask[i];
|
---|
180 | }
|
---|
181 | }
|
---|
182 | [StorableClass]
|
---|
183 | public sealed class CovConstTreeNode : SymbolicExpressionTreeTerminalNode {
|
---|
184 | public new CovConst Symbol { get { return (CovConst)base.Symbol; } }
|
---|
185 |
|
---|
186 | public override bool HasLocalParameters {
|
---|
187 | get { return true; }
|
---|
188 | }
|
---|
189 |
|
---|
190 | private double sigma;
|
---|
191 | [Storable]
|
---|
192 | public double Sigma { get { return sigma; } private set { this.sigma = value; } }
|
---|
193 |
|
---|
194 | [StorableConstructor]
|
---|
195 | private CovConstTreeNode(bool deserializing) : base(deserializing) { }
|
---|
196 | private CovConstTreeNode(CovConstTreeNode original, Cloner cloner)
|
---|
197 | : base(original, cloner) {
|
---|
198 | this.sigma = original.sigma;
|
---|
199 | }
|
---|
200 |
|
---|
201 | public CovConstTreeNode() : base(new CovConst()) { }
|
---|
202 |
|
---|
203 | [StorableHook(HookType.AfterDeserialization)]
|
---|
204 | private void AfterDeserialization() {
|
---|
205 | }
|
---|
206 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
207 | return new CovConstTreeNode(this, cloner);
|
---|
208 | }
|
---|
209 | public override void ResetLocalParameters(IRandom random) {
|
---|
210 | sigma = random.Next((int)Symbol.MinSigma, (int)Symbol.MaxSigma);
|
---|
211 | }
|
---|
212 | public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
|
---|
213 | var normRandom = new NormalDistributedRandom(random, Symbol.SigmaShakingMu, Symbol.SigmaShakingSigma);
|
---|
214 | sigma = Math.Max(Symbol.MinSigma, Math.Min(Symbol.MaxSigma, sigma + normRandom.NextDouble() * shakingFactor));
|
---|
215 | }
|
---|
216 | }
|
---|
217 | [StorableClass]
|
---|
218 | public sealed class CovNoiseTreeNode : SymbolicExpressionTreeTerminalNode {
|
---|
219 | public new CovNoise Symbol { get { return (CovNoise)base.Symbol; } }
|
---|
220 |
|
---|
221 | public override bool HasLocalParameters {
|
---|
222 | get { return true; }
|
---|
223 | }
|
---|
224 |
|
---|
225 | private double sigma;
|
---|
226 | [Storable]
|
---|
227 | public double Sigma { get { return sigma; } private set { this.sigma = value; } }
|
---|
228 |
|
---|
229 | [StorableConstructor]
|
---|
230 | private CovNoiseTreeNode(bool deserializing) : base(deserializing) { }
|
---|
231 | private CovNoiseTreeNode(CovNoiseTreeNode original, Cloner cloner)
|
---|
232 | : base(original, cloner) {
|
---|
233 | this.sigma = original.sigma;
|
---|
234 | }
|
---|
235 |
|
---|
236 | public CovNoiseTreeNode() : base(new CovNoise()) { }
|
---|
237 |
|
---|
238 | [StorableHook(HookType.AfterDeserialization)]
|
---|
239 | private void AfterDeserialization() {
|
---|
240 | }
|
---|
241 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
242 | return new CovNoiseTreeNode(this, cloner);
|
---|
243 | }
|
---|
244 | public override void ResetLocalParameters(IRandom random) {
|
---|
245 | sigma = random.Next((int)Symbol.MinSigma, (int)Symbol.MaxSigma);
|
---|
246 | }
|
---|
247 | public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
|
---|
248 | var normRandom = new NormalDistributedRandom(random, Symbol.SigmaShakingMu, Symbol.SigmaShakingSigma);
|
---|
249 | sigma = Math.Max(Symbol.MinSigma, Math.Min(Symbol.MaxSigma, sigma + normRandom.NextDouble() * shakingFactor));
|
---|
250 | }
|
---|
251 | }
|
---|
252 | [StorableClass]
|
---|
253 | public sealed class CovLinArdTreeNode : SymbolicExpressionTreeTerminalNode {
|
---|
254 | public new CovLinArd Symbol { get { return (CovLinArd)base.Symbol; } }
|
---|
255 |
|
---|
256 | public override bool HasLocalParameters {
|
---|
257 | get { return true; }
|
---|
258 | }
|
---|
259 |
|
---|
260 | [Storable]
|
---|
261 | public double[] Lambda { get; set; }
|
---|
262 |
|
---|
263 | [StorableConstructor]
|
---|
264 | private CovLinArdTreeNode(bool deserializing) : base(deserializing) { }
|
---|
265 | private CovLinArdTreeNode(CovLinArdTreeNode original, Cloner cloner)
|
---|
266 | : base(original, cloner) {
|
---|
267 | Lambda = new double[original.Lambda.Length];
|
---|
268 | Array.Copy(original.Lambda, Lambda, Lambda.Length);
|
---|
269 | }
|
---|
270 |
|
---|
271 | public CovLinArdTreeNode(CovLinArd symbol)
|
---|
272 | : base(symbol) {
|
---|
273 | Lambda = new double[symbol.Dimension];
|
---|
274 | }
|
---|
275 |
|
---|
276 | [StorableHook(HookType.AfterDeserialization)]
|
---|
277 | private void AfterDeserialization() {
|
---|
278 | }
|
---|
279 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
280 | return new CovLinArdTreeNode(this, cloner);
|
---|
281 | }
|
---|
282 | public override void ResetLocalParameters(IRandom random) {
|
---|
283 | var normRandom = new NormalDistributedRandom(random, Symbol.LambdaMu, Symbol.LambdaSigma);
|
---|
284 | for (int i = 0; i < Lambda.Length; i++)
|
---|
285 | Lambda[i] = normRandom.NextDouble();
|
---|
286 | }
|
---|
287 | public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
|
---|
288 | int index = random.Next(Lambda.Length);
|
---|
289 | var normRandom = new NormalDistributedRandom(random, Symbol.LambdaShakingMu, Symbol.LambdaShakingSigma);
|
---|
290 | Lambda[index] += shakingFactor * normRandom.NextDouble();
|
---|
291 | }
|
---|
292 | }
|
---|
293 | [StorableClass]
|
---|
294 | public sealed class CovSeArdTreeNode : SymbolicExpressionTreeTerminalNode {
|
---|
295 | public new CovSeArd Symbol { get { return (CovSeArd)base.Symbol; } }
|
---|
296 |
|
---|
297 | public override bool HasLocalParameters {
|
---|
298 | get { return true; }
|
---|
299 | }
|
---|
300 |
|
---|
301 | [Storable]
|
---|
302 | public double[] Lambda { get; set; }
|
---|
303 |
|
---|
304 | [Storable]
|
---|
305 | public double Sigma { get; set; }
|
---|
306 |
|
---|
307 | [StorableConstructor]
|
---|
308 | private CovSeArdTreeNode(bool deserializing) : base(deserializing) { }
|
---|
309 | private CovSeArdTreeNode(CovSeArdTreeNode original, Cloner cloner)
|
---|
310 | : base(original, cloner) {
|
---|
311 | Lambda = new double[original.Lambda.Length];
|
---|
312 | Array.Copy(original.Lambda, Lambda, Lambda.Length);
|
---|
313 | Sigma = original.Sigma;
|
---|
314 | }
|
---|
315 |
|
---|
316 | public CovSeArdTreeNode(CovSeArd symbol)
|
---|
317 | : base(symbol) {
|
---|
318 | Lambda = new double[symbol.Dimension];
|
---|
319 | }
|
---|
320 |
|
---|
321 | [StorableHook(HookType.AfterDeserialization)]
|
---|
322 | private void AfterDeserialization() {
|
---|
323 | }
|
---|
324 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
325 | return new CovSeArdTreeNode(this, cloner);
|
---|
326 | }
|
---|
327 | public override void ResetLocalParameters(IRandom random) {
|
---|
328 | var normRandom = new NormalDistributedRandom(random, Symbol.LambdaMu, Symbol.LambdaSigma);
|
---|
329 | for (int i = 0; i < Lambda.Length; i++)
|
---|
330 | Lambda[i] = normRandom.NextDouble();
|
---|
331 |
|
---|
332 | Sigma = Symbol.MinSigma + random.NextDouble() * (Symbol.MaxSigma - Symbol.MinSigma);
|
---|
333 | }
|
---|
334 | public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
|
---|
335 | int index = random.Next(Lambda.Length);
|
---|
336 | var normRandom = new NormalDistributedRandom(random, Symbol.LambdaShakingMu, Symbol.LambdaShakingSigma);
|
---|
337 | Lambda[index] += shakingFactor * normRandom.NextDouble();
|
---|
338 |
|
---|
339 | var sigmaRandom = new NormalDistributedRandom(random, Symbol.SigmaShakingMu, Symbol.SigmaShakingSigma);
|
---|
340 | Sigma = Math.Max(Symbol.MinSigma, Math.Min(Symbol.MaxSigma, Sigma + shakingFactor * sigmaRandom.NextDouble()));
|
---|
341 | }
|
---|
342 | }
|
---|
343 | [StorableClass]
|
---|
344 | public sealed class CovSeIsoTreeNode : SymbolicExpressionTreeTerminalNode {
|
---|
345 | public new CovSeIso Symbol { get { return (CovSeIso)base.Symbol; } }
|
---|
346 |
|
---|
347 | public override bool HasLocalParameters {
|
---|
348 | get { return true; }
|
---|
349 | }
|
---|
350 |
|
---|
351 | [Storable]
|
---|
352 | public double L { get; set; }
|
---|
353 |
|
---|
354 | [Storable]
|
---|
355 | public double Sigma { get; set; }
|
---|
356 |
|
---|
357 | [StorableConstructor]
|
---|
358 | private CovSeIsoTreeNode(bool deserializing) : base(deserializing) { }
|
---|
359 | private CovSeIsoTreeNode(CovSeIsoTreeNode original, Cloner cloner)
|
---|
360 | : base(original, cloner) {
|
---|
361 | L = original.L;
|
---|
362 | Sigma = original.Sigma;
|
---|
363 | }
|
---|
364 |
|
---|
365 | public CovSeIsoTreeNode(CovSeIso symbol)
|
---|
366 | : base(symbol) {
|
---|
367 | }
|
---|
368 |
|
---|
369 | [StorableHook(HookType.AfterDeserialization)]
|
---|
370 | private void AfterDeserialization() {
|
---|
371 | }
|
---|
372 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
373 | return new CovSeIsoTreeNode(this, cloner);
|
---|
374 | }
|
---|
375 | public override void ResetLocalParameters(IRandom random) {
|
---|
376 | Sigma = Symbol.MinSigma + random.NextDouble() * (Symbol.MaxSigma - Symbol.MinSigma);
|
---|
377 | L = Symbol.MinL + random.NextDouble() * (Symbol.MaxL - Symbol.MinL);
|
---|
378 | }
|
---|
379 | public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
|
---|
380 | var sigmaRandom = new NormalDistributedRandom(random, Symbol.SigmaShakingMu, Symbol.SigmaShakingSigma);
|
---|
381 | Sigma = Math.Max(Symbol.MinSigma, Math.Min(Symbol.MaxSigma, Sigma + shakingFactor * sigmaRandom.NextDouble()));
|
---|
382 |
|
---|
383 | var lRandom = new NormalDistributedRandom(random, Symbol.LShakingMu, Symbol.LShakingSigma);
|
---|
384 | L = Math.Max(Symbol.MinL, Math.Min(Symbol.MaxL, L + shakingFactor * lRandom.NextDouble()));
|
---|
385 | }
|
---|
386 | }
|
---|
387 | [StorableClass]
|
---|
388 | public sealed class CovMaternTreeNode : SymbolicExpressionTreeTerminalNode {
|
---|
389 | public new CovMatern Symbol { get { return (CovMatern)base.Symbol; } }
|
---|
390 |
|
---|
391 | public override bool HasLocalParameters {
|
---|
392 | get { return true; }
|
---|
393 | }
|
---|
394 |
|
---|
395 | [Storable]
|
---|
396 | public double L { get; set; }
|
---|
397 |
|
---|
398 | [Storable]
|
---|
399 | public double Sigma { get; set; }
|
---|
400 |
|
---|
401 | [StorableConstructor]
|
---|
402 | private CovMaternTreeNode(bool deserializing) : base(deserializing) { }
|
---|
403 | private CovMaternTreeNode(CovMaternTreeNode original, Cloner cloner)
|
---|
404 | : base(original, cloner) {
|
---|
405 | L = original.L;
|
---|
406 | Sigma = original.Sigma;
|
---|
407 | }
|
---|
408 |
|
---|
409 | public CovMaternTreeNode(CovMatern symbol)
|
---|
410 | : base(symbol) {
|
---|
411 | }
|
---|
412 |
|
---|
413 | [StorableHook(HookType.AfterDeserialization)]
|
---|
414 | private void AfterDeserialization() {
|
---|
415 | }
|
---|
416 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
417 | return new CovMaternTreeNode(this, cloner);
|
---|
418 | }
|
---|
419 | public override void ResetLocalParameters(IRandom random) {
|
---|
420 | Sigma = Symbol.MinSigma + random.NextDouble() * (Symbol.MaxSigma - Symbol.MinSigma);
|
---|
421 | L = Symbol.MinL + random.NextDouble() * (Symbol.MaxL - Symbol.MinL);
|
---|
422 | }
|
---|
423 | public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
|
---|
424 | var sigmaRandom = new NormalDistributedRandom(random, Symbol.SigmaShakingMu, Symbol.SigmaShakingSigma);
|
---|
425 | Sigma = Math.Max(Symbol.MinSigma, Math.Min(Symbol.MaxSigma, Sigma + shakingFactor * sigmaRandom.NextDouble()));
|
---|
426 |
|
---|
427 | var lRandom = new NormalDistributedRandom(random, Symbol.LShakingMu, Symbol.LShakingSigma);
|
---|
428 | L = Math.Max(Symbol.MinL, Math.Min(Symbol.MaxL, L + shakingFactor * lRandom.NextDouble()));
|
---|
429 | }
|
---|
430 | }
|
---|
431 | [StorableClass]
|
---|
432 | public sealed class CovPeriodicTreeNode : SymbolicExpressionTreeTerminalNode {
|
---|
433 | public new CovPeriodic Symbol { get { return (CovPeriodic)base.Symbol; } }
|
---|
434 |
|
---|
435 | public override bool HasLocalParameters {
|
---|
436 | get { return true; }
|
---|
437 | }
|
---|
438 |
|
---|
439 | [Storable]
|
---|
440 | public double L { get; set; }
|
---|
441 |
|
---|
442 | [Storable]
|
---|
443 | public double Sigma { get; set; }
|
---|
444 |
|
---|
445 | [Storable]
|
---|
446 | public double Period { get; set; }
|
---|
447 |
|
---|
448 | [StorableConstructor]
|
---|
449 | private CovPeriodicTreeNode(bool deserializing) : base(deserializing) { }
|
---|
450 | private CovPeriodicTreeNode(CovPeriodicTreeNode original, Cloner cloner)
|
---|
451 | : base(original, cloner) {
|
---|
452 | L = original.L;
|
---|
453 | Sigma = original.Sigma;
|
---|
454 | Period = original.Period;
|
---|
455 | }
|
---|
456 |
|
---|
457 | public CovPeriodicTreeNode(CovPeriodic symbol)
|
---|
458 | : base(symbol) {
|
---|
459 | }
|
---|
460 |
|
---|
461 | [StorableHook(HookType.AfterDeserialization)]
|
---|
462 | private void AfterDeserialization() {
|
---|
463 | }
|
---|
464 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
465 | return new CovPeriodicTreeNode(this, cloner);
|
---|
466 | }
|
---|
467 | public override void ResetLocalParameters(IRandom random) {
|
---|
468 | Sigma = Symbol.MinSigma + random.NextDouble() * (Symbol.MaxSigma - Symbol.MinSigma);
|
---|
469 | L = Symbol.MinL + random.NextDouble() * (Symbol.MaxL - Symbol.MinL);
|
---|
470 | Period = Symbol.MinPeriod + random.NextDouble() * (Symbol.MaxPeriod - Symbol.MinPeriod);
|
---|
471 | }
|
---|
472 | public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
|
---|
473 | var sigmaRandom = new NormalDistributedRandom(random, Symbol.SigmaShakingMu, Symbol.SigmaShakingSigma);
|
---|
474 | Sigma = Math.Max(Symbol.MinSigma, Math.Min(Symbol.MaxSigma, Sigma + shakingFactor * sigmaRandom.NextDouble()));
|
---|
475 |
|
---|
476 | var lRandom = new NormalDistributedRandom(random, Symbol.LShakingMu, Symbol.LShakingSigma);
|
---|
477 | L = Math.Max(Symbol.MinL, Math.Min(Symbol.MaxL, L + shakingFactor * lRandom.NextDouble()));
|
---|
478 |
|
---|
479 | var pRandom = new NormalDistributedRandom(random, Symbol.PeriodShakingMu, Symbol.PeriodShakingSigma);
|
---|
480 | Period = Math.Max(Symbol.MinPeriod, Math.Min(Symbol.MaxPeriod, Period + shakingFactor * pRandom.NextDouble()));
|
---|
481 | }
|
---|
482 | }
|
---|
483 |
|
---|
484 | [StorableClass]
|
---|
485 | public sealed class CovRQArdTreeNode : SymbolicExpressionTreeTerminalNode {
|
---|
486 | public new CovRQArd Symbol { get { return (CovRQArd)base.Symbol; } }
|
---|
487 |
|
---|
488 | public override bool HasLocalParameters {
|
---|
489 | get { return true; }
|
---|
490 | }
|
---|
491 |
|
---|
492 | [Storable]
|
---|
493 | public double[] Lambda { get; set; }
|
---|
494 |
|
---|
495 | [Storable]
|
---|
496 | public double Sigma { get; set; }
|
---|
497 |
|
---|
498 | [Storable]
|
---|
499 | public double Shape { get; set; }
|
---|
500 |
|
---|
501 | [StorableConstructor]
|
---|
502 | private CovRQArdTreeNode(bool deserializing) : base(deserializing) { }
|
---|
503 | private CovRQArdTreeNode(CovRQArdTreeNode original, Cloner cloner)
|
---|
504 | : base(original, cloner) {
|
---|
505 | Lambda = new double[original.Lambda.Length];
|
---|
506 | Array.Copy(original.Lambda, Lambda, Lambda.Length);
|
---|
507 | Sigma = original.Sigma;
|
---|
508 | Shape = original.Shape;
|
---|
509 | }
|
---|
510 |
|
---|
511 | public CovRQArdTreeNode(CovRQArd symbol)
|
---|
512 | : base(symbol) {
|
---|
513 | Lambda = new double[symbol.Dimension];
|
---|
514 | }
|
---|
515 |
|
---|
516 | [StorableHook(HookType.AfterDeserialization)]
|
---|
517 | private void AfterDeserialization() {
|
---|
518 | }
|
---|
519 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
520 | return new CovRQArdTreeNode(this, cloner);
|
---|
521 | }
|
---|
522 | public override void ResetLocalParameters(IRandom random) {
|
---|
523 | var normRandom = new NormalDistributedRandom(random, Symbol.LambdaMu, Symbol.LambdaSigma);
|
---|
524 | for (int i = 0; i < Lambda.Length; i++)
|
---|
525 | Lambda[i] = normRandom.NextDouble();
|
---|
526 |
|
---|
527 | Sigma = Symbol.MinSigma + random.NextDouble() * (Symbol.MaxSigma - Symbol.MinSigma);
|
---|
528 | Shape = Symbol.MinShape + random.NextDouble() * (Symbol.MaxShape - Symbol.MinShape);
|
---|
529 | }
|
---|
530 | public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
|
---|
531 | int index = random.Next(Lambda.Length);
|
---|
532 | var normRandom = new NormalDistributedRandom(random, Symbol.LambdaShakingMu, Symbol.LambdaShakingSigma);
|
---|
533 | Lambda[index] += shakingFactor * normRandom.NextDouble();
|
---|
534 |
|
---|
535 | var sigmaRandom = new NormalDistributedRandom(random, Symbol.SigmaShakingMu, Symbol.SigmaShakingSigma);
|
---|
536 | Sigma = Math.Max(Symbol.MinSigma, Math.Min(Symbol.MaxSigma, Sigma + shakingFactor * sigmaRandom.NextDouble()));
|
---|
537 |
|
---|
538 | var shapeRandom = new NormalDistributedRandom(random, Symbol.ShapeShakingMu, Symbol.ShapeShakingSigma);
|
---|
539 | Sigma = Math.Max(Symbol.MinShape, Math.Min(Symbol.MaxShape, Shape + shakingFactor * shapeRandom.NextDouble()));
|
---|
540 | }
|
---|
541 | }
|
---|
542 |
|
---|
543 | [StorableClass]
|
---|
544 | public sealed class CovRQisoTreeNode : SymbolicExpressionTreeTerminalNode {
|
---|
545 | public new CovRQIso Symbol { get { return (CovRQIso)base.Symbol; } }
|
---|
546 |
|
---|
547 | public override bool HasLocalParameters {
|
---|
548 | get { return true; }
|
---|
549 | }
|
---|
550 |
|
---|
551 | [Storable]
|
---|
552 | public double L { get; set; }
|
---|
553 |
|
---|
554 | [Storable]
|
---|
555 | public double Sigma { get; set; }
|
---|
556 |
|
---|
557 | [Storable]
|
---|
558 | public double Shape { get; set; }
|
---|
559 |
|
---|
560 | [StorableConstructor]
|
---|
561 | private CovRQisoTreeNode(bool deserializing) : base(deserializing) { }
|
---|
562 | private CovRQisoTreeNode(CovRQisoTreeNode original, Cloner cloner)
|
---|
563 | : base(original, cloner) {
|
---|
564 | L = original.L;
|
---|
565 | Sigma = original.Sigma;
|
---|
566 | Shape = original.Shape;
|
---|
567 | }
|
---|
568 |
|
---|
569 | public CovRQisoTreeNode(CovRQIso symbol)
|
---|
570 | : base(symbol) {
|
---|
571 | }
|
---|
572 |
|
---|
573 | [StorableHook(HookType.AfterDeserialization)]
|
---|
574 | private void AfterDeserialization() {
|
---|
575 | }
|
---|
576 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
577 | return new CovRQisoTreeNode(this, cloner);
|
---|
578 | }
|
---|
579 | public override void ResetLocalParameters(IRandom random) {
|
---|
580 | Sigma = Symbol.MinSigma + random.NextDouble() * (Symbol.MaxSigma - Symbol.MinSigma);
|
---|
581 | L = Symbol.MinL + random.NextDouble() * (Symbol.MaxL - Symbol.MinL);
|
---|
582 | Shape = Symbol.MinShape + random.NextDouble() * (Symbol.MaxShape - Symbol.MinShape);
|
---|
583 | }
|
---|
584 | public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
|
---|
585 | var sigmaRandom = new NormalDistributedRandom(random, Symbol.SigmaShakingMu, Symbol.SigmaShakingSigma);
|
---|
586 | Sigma = Math.Max(Symbol.MinSigma, Math.Min(Symbol.MaxSigma, Sigma + shakingFactor * sigmaRandom.NextDouble()));
|
---|
587 |
|
---|
588 | var lRandom = new NormalDistributedRandom(random, Symbol.LShakingMu, Symbol.LShakingSigma);
|
---|
589 | L = Math.Max(Symbol.MinL, Math.Min(Symbol.MaxL, L + shakingFactor * lRandom.NextDouble()));
|
---|
590 |
|
---|
591 | var shapeRandom = new NormalDistributedRandom(random, Symbol.ShapeShakingMu, Symbol.ShapeShakingSigma);
|
---|
592 | Shape = Math.Max(Symbol.MinShape, Math.Min(Symbol.MaxShape, Shape + shakingFactor * shapeRandom.NextDouble()));
|
---|
593 | }
|
---|
594 | }
|
---|
595 | [StorableClass]
|
---|
596 | public sealed class CovScaleTreeNode : SymbolicExpressionTreeNode {
|
---|
597 | public new CovScale Symbol { get { return (CovScale)base.Symbol; } }
|
---|
598 |
|
---|
599 | public override bool HasLocalParameters {
|
---|
600 | get { return true; }
|
---|
601 | }
|
---|
602 |
|
---|
603 | private double alpha;
|
---|
604 | [Storable]
|
---|
605 | public double Alpha { get { return alpha; } private set { this.alpha = value; } }
|
---|
606 |
|
---|
607 | [StorableConstructor]
|
---|
608 | private CovScaleTreeNode(bool deserializing) : base(deserializing) { }
|
---|
609 | private CovScaleTreeNode(CovScaleTreeNode original, Cloner cloner)
|
---|
610 | : base(original, cloner) {
|
---|
611 | this.alpha = original.alpha;
|
---|
612 | }
|
---|
613 |
|
---|
614 | public CovScaleTreeNode(CovScale symbol) : base(symbol) { }
|
---|
615 |
|
---|
616 | [StorableHook(HookType.AfterDeserialization)]
|
---|
617 | private void AfterDeserialization() {
|
---|
618 | }
|
---|
619 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
620 | return new CovScaleTreeNode(this, cloner);
|
---|
621 | }
|
---|
622 | public override void ResetLocalParameters(IRandom random) {
|
---|
623 | var normRandom = new NormalDistributedRandom(random, Symbol.AlphaMu, Symbol.AlphaSigma);
|
---|
624 | alpha = normRandom.NextDouble();
|
---|
625 | }
|
---|
626 | public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
|
---|
627 | var normRandom = new NormalDistributedRandom(random, Symbol.AlphaShakingMu, Symbol.AlphaShakingSigma);
|
---|
628 | alpha += shakingFactor * normRandom.NextDouble();
|
---|
629 | }
|
---|
630 | }
|
---|
631 | [StorableClass]
|
---|
632 | public sealed class CovMaskTreeNode : SymbolicExpressionTreeNode {
|
---|
633 | public new CovMask Symbol { get { return (CovMask)base.Symbol; } }
|
---|
634 |
|
---|
635 | public override bool HasLocalParameters {
|
---|
636 | get { return true; }
|
---|
637 | }
|
---|
638 |
|
---|
639 | [Storable]
|
---|
640 | public bool[] Mask { get; set; }
|
---|
641 |
|
---|
642 | [StorableConstructor]
|
---|
643 | private CovMaskTreeNode(bool deserializing) : base(deserializing) { }
|
---|
644 | private CovMaskTreeNode(CovMaskTreeNode original, Cloner cloner)
|
---|
645 | : base(original, cloner) {
|
---|
646 | Mask = new bool[original.Mask.Length];
|
---|
647 | Array.Copy(original.Mask, Mask, Mask.Length);
|
---|
648 | }
|
---|
649 |
|
---|
650 | public CovMaskTreeNode(CovMask symbol)
|
---|
651 | : base(symbol) {
|
---|
652 | Mask = new bool[symbol.Dimension];
|
---|
653 | }
|
---|
654 |
|
---|
655 | [StorableHook(HookType.AfterDeserialization)]
|
---|
656 | private void AfterDeserialization() {
|
---|
657 | }
|
---|
658 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
659 | return new CovMaskTreeNode(this, cloner);
|
---|
660 | }
|
---|
661 | public override void ResetLocalParameters(IRandom random) {
|
---|
662 | for (int i = 0; i < Mask.Length; i++)
|
---|
663 | Mask[i] = random.NextDouble() < Symbol.MaskingProbability;
|
---|
664 | }
|
---|
665 | public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
|
---|
666 | // one point bit flip
|
---|
667 | int i = random.Next(Mask.Length);
|
---|
668 | Mask[i] = !Mask[i];
|
---|
669 | }
|
---|
670 | }
|
---|
671 |
|
---|
672 | [StorableClass]
|
---|
673 | public sealed class LikGaussTreeNode : SymbolicExpressionTreeTerminalNode {
|
---|
674 | public new LikGauss Symbol { get { return (LikGauss)base.Symbol; } }
|
---|
675 |
|
---|
676 | public override bool HasLocalParameters {
|
---|
677 | get { return true; }
|
---|
678 | }
|
---|
679 |
|
---|
680 | private double sigma;
|
---|
681 | [Storable]
|
---|
682 | public double Sigma { get { return sigma; } private set { this.sigma = value; } }
|
---|
683 |
|
---|
684 | [StorableConstructor]
|
---|
685 | private LikGaussTreeNode(bool deserializing) : base(deserializing) { }
|
---|
686 | private LikGaussTreeNode(LikGaussTreeNode original, Cloner cloner)
|
---|
687 | : base(original, cloner) {
|
---|
688 | this.sigma = original.sigma;
|
---|
689 | }
|
---|
690 |
|
---|
691 | public LikGaussTreeNode(LikGauss symbol) : base(symbol) { }
|
---|
692 |
|
---|
693 | [StorableHook(HookType.AfterDeserialization)]
|
---|
694 | private void AfterDeserialization() {
|
---|
695 | }
|
---|
696 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
697 | return new LikGaussTreeNode(this, cloner);
|
---|
698 | }
|
---|
699 | public override void ResetLocalParameters(IRandom random) {
|
---|
700 | sigma = random.Next((int)Symbol.MinSigma, (int)Symbol.MaxSigma);
|
---|
701 | }
|
---|
702 | public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
|
---|
703 | var normRandom = new NormalDistributedRandom(random, Symbol.SigmaShakingMu, Symbol.SigmaShakingSigma);
|
---|
704 | sigma = Math.Max(Symbol.MinSigma, Math.Min(Symbol.MaxSigma, sigma + normRandom.NextDouble() * shakingFactor));
|
---|
705 | }
|
---|
706 | }
|
---|
707 | }
|
---|