Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/CurvedInsVariableTreeNode.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
RevLine 
[13865]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 CurvedInsVariableTreeNode : SymbolicExpressionTreeTerminalNode {
31    public new CurvedInsVariableSymbol Symbol {
32      get { return (CurvedInsVariableSymbol)base.Symbol; }
33    }
[13867]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
49    [Storable]
50    private double weight;
51    public double Weight {
52      get { return weight; }
53      set { weight = value; }
54    }
[13865]55    [StorableConstructor]
56    protected CurvedInsVariableTreeNode(bool deserializing) : base(deserializing) { }
57    protected CurvedInsVariableTreeNode(CurvedInsVariableTreeNode original, Cloner cloner)
58      : base(original, cloner) {
[13867]59      this.alpha = original.alpha;
60      this.beta = original.beta;
61      this.weight = original.weight;
[13865]62    }
63    protected CurvedInsVariableTreeNode() { }
64    public CurvedInsVariableTreeNode(CurvedInsVariableSymbol variableSymbol) : base(variableSymbol) { }
65
66    public override bool HasLocalParameters {
[13867]67      get { return true; }
[13865]68    }
69
70    public override void ResetLocalParameters(IRandom random) {
71      base.ResetLocalParameters(random);
[13867]72      alpha = UniformDistributedRandom.NextDouble(random, Symbol.MinAlpha, Symbol.MaxAlpha);
73      beta = UniformDistributedRandom.NextDouble(random, Symbol.MinBeta, Symbol.MaxBeta);
74      weight = NormalDistributedRandom.NextDouble(random, 0, 10);
[13865]75    }
76
77    public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
78      base.ShakeLocalParameters(random, shakingFactor);
[13867]79      weight += NormalDistributedRandom.NextDouble(random, 0, 1.0 * shakingFactor);
[14310]80      alpha += NormalDistributedRandom.NextDouble(random, 0, 0.1 * shakingFactor);
81      beta += NormalDistributedRandom.NextDouble(random, 0, 0.1 * shakingFactor);
[13867]82     
83      alpha = Math.Min(Symbol.MaxAlpha, Math.Max(Symbol.MinAlpha, alpha));
84      beta = Math.Min(Symbol.MinBeta, Math.Max(Symbol.MinBeta, beta));
[13865]85    }
86
87    public override IDeepCloneable Clone(Cloner cloner) {
88      return new CurvedInsVariableTreeNode(this, cloner);
89    }
90
91    public override string ToString() {
[13867]92      return string.Format("{0:N3}*curvedIns(alpha: {1:N3}, beta: {2:N3})", weight, alpha, beta);
[13865]93    }
94  }
95}
Note: See TracBrowser for help on using the repository browser.