Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/CurvedChVariableTreeNode.cs @ 16654

Last change on this file since 16654 was 14310, checked in by gkronber, 8 years ago

changed interpreter and grammar to smooth ch and ins uptake using a compartement model

File size: 3.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27using HeuristicLab.Random;
28namespace HeuristicLab.Problems.GeneticProgramming.GlucosePrediction {
29  [StorableClass]
30  public class CurvedChVariableTreeNode : SymbolicExpressionTreeTerminalNode {
31    public new CurvedChVariableSymbol Symbol {
32      get { return (CurvedChVariableSymbol)base.Symbol; }
33    }
34
35    [Storable]
36    private double alpha;
37    public double Alpha {
38      get { return alpha; }
39      set { alpha = value; }
40    }
41
42    [Storable]
43    private double beta;
44    public double Beta {
45      get { return beta; }
46      set { beta = value; }
47    }
48    [Storable]
49    private double weight;
50    public double Weight {
51      get { return weight; }
52      set { weight = value; }
53    }
54    [StorableConstructor]
55    protected CurvedChVariableTreeNode(bool deserializing) : base(deserializing) { }
56    protected CurvedChVariableTreeNode(CurvedChVariableTreeNode original, Cloner cloner)
57      : base(original, cloner) {
58      this.alpha = original.alpha;
59      this.beta = original.beta;
60      this.weight = original.weight;
61    }
62    protected CurvedChVariableTreeNode() { }
63    public CurvedChVariableTreeNode(CurvedChVariableSymbol variableSymbol) : base(variableSymbol) { }
64
65    public override bool HasLocalParameters {
66      get { return true; }
67    }
68
69    public override void ResetLocalParameters(IRandom random) {
70      base.ResetLocalParameters(random);
71      weight = NormalDistributedRandom.NextDouble(random, 0, 10);
72      alpha = UniformDistributedRandom.NextDouble(random, Symbol.MinAlpha, Symbol.MaxAlpha);
73      beta = UniformDistributedRandom.NextDouble(random, Symbol.MinBeta, Symbol.MaxBeta);
74    }
75
76    public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
77      base.ShakeLocalParameters(random, shakingFactor);
78      weight += NormalDistributedRandom.NextDouble(random, 0, 1.0 * shakingFactor);
79      alpha += NormalDistributedRandom.NextDouble(random, 0, 0.1 * shakingFactor);
80      beta += NormalDistributedRandom.NextDouble(random, 0, 0.1 * shakingFactor);
81
82      alpha = Math.Min(Symbol.MaxAlpha, Math.Max(Symbol.MinAlpha, alpha));
83      beta = Math.Min(Symbol.MinBeta, Math.Max(Symbol.MinBeta, beta));
84    }
85
86    public override IDeepCloneable Clone(Cloner cloner) {
87      return new CurvedChVariableTreeNode(this, cloner);
88    }
89
90    public override string ToString() {
91      return string.Format("{0:N3}*curvedCh(alpha: {1:N3}, beta: {2:N3})", weight, alpha, beta);
92    }
93  }
94}
Note: See TracBrowser for help on using the repository browser.