Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Constant.cs @ 16605

Last change on this file since 16605 was 16565, checked in by gkronber, 6 years ago

#2520: merged changes from PersistenceOverhaul branch (r16451:16564) into trunk

File size: 3.9 KB
RevLine 
[3253]1#region License Information
2/* HeuristicLab
[16565]3 * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[3253]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
[4068]22using System;
[3376]23using HeuristicLab.Common;
[3269]24using HeuristicLab.Core;
[4068]25using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
[16565]26using HEAL.Attic;
[5532]27namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
[16565]28  [StorableType("5CD355EA-36E4-4E43-B8C4-9E9CF4CBC860")]
[3269]29  [Item("Constant", "Represents a constant value.")]
[3253]30  public sealed class Constant : Symbol {
[5326]31    #region Properties
[3485]32    [Storable]
[3294]33    private double minValue;
34    public double MinValue {
35      get { return minValue; }
[3824]36      set {
37        if (value != minValue) {
38          minValue = value;
39          OnChanged(EventArgs.Empty);
40        }
41      }
[3269]42    }
[3485]43    [Storable]
[3294]44    private double maxValue;
45    public double MaxValue {
46      get { return maxValue; }
[3824]47      set {
48        if (value != maxValue) {
49          maxValue = value;
50          OnChanged(EventArgs.Empty);
51        }
52      }
[3269]53    }
[3512]54    [Storable]
[4989]55    private double manipulatorMu;
56    public double ManipulatorMu {
57      get { return manipulatorMu; }
[3824]58      set {
[4989]59        if (value != manipulatorMu) {
60          manipulatorMu = value;
[3824]61          OnChanged(EventArgs.Empty);
62        }
63      }
[3512]64    }
65    [Storable]
66    private double manipulatorSigma;
67    public double ManipulatorSigma {
68      get { return manipulatorSigma; }
69      set {
70        if (value < 0) throw new ArgumentException();
[3824]71        if (value != manipulatorSigma) {
72          manipulatorSigma = value;
73          OnChanged(EventArgs.Empty);
74        }
[3512]75      }
76    }
[5326]77    [Storable(DefaultValue = 0.0)]
78    private double multiplicativeManipulatorSigma;
79    public double MultiplicativeManipulatorSigma {
80      get { return multiplicativeManipulatorSigma; }
81      set {
82        if (value < 0) throw new ArgumentException();
83        if (value != multiplicativeManipulatorSigma) {
84          multiplicativeManipulatorSigma = value;
85          OnChanged(EventArgs.Empty);
86        }
87      }
88    }
89
[6803]90    private const int minimumArity = 0;
91    private const int maximumArity = 0;
92
93    public override int MinimumArity {
94      get { return minimumArity; }
95    }
96    public override int MaximumArity {
97      get { return maximumArity; }
98    }
[3269]99    #endregion
[6803]100
[4722]101    [StorableConstructor]
[16565]102    private Constant(StorableConstructorFlag _) : base(_) { }
[4722]103    private Constant(Constant original, Cloner cloner)
104      : base(original, cloner) {
105      minValue = original.minValue;
106      maxValue = original.maxValue;
[4989]107      manipulatorMu = original.manipulatorMu;
[4722]108      manipulatorSigma = original.manipulatorSigma;
[5326]109      multiplicativeManipulatorSigma = original.multiplicativeManipulatorSigma;
[4722]110    }
[3269]111    public Constant()
[3993]112      : base("Constant", "Represents a constant value.") {
[4989]113      manipulatorMu = 0.0;
[3512]114      manipulatorSigma = 1.0;
[5326]115      multiplicativeManipulatorSigma = 0.03;
[3512]116      minValue = -20.0;
117      maxValue = 20.0;
[3269]118    }
119
[5532]120    public override ISymbolicExpressionTreeNode CreateTreeNode() {
[3253]121      return new ConstantTreeNode(this);
122    }
[3485]123
124    public override IDeepCloneable Clone(Cloner cloner) {
[4722]125      return new Constant(this, cloner);
[3485]126    }
[3253]127  }
128}
Note: See TracBrowser for help on using the repository browser.