Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 5922 was 5809, checked in by mkommend, 14 years ago

#1418: Reintegrated branch into trunk.

File size: 3.7 KB
RevLine 
[3253]1#region License Information
2/* HeuristicLab
[5445]3 * Copyright (C) 2002-2011 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;
[3269]26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
[5532]27namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
[3269]28  [StorableClass]
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
[3269]90    #endregion
[4722]91    [StorableConstructor]
92    private Constant(bool deserializing) : base(deserializing) { }
93    private Constant(Constant original, Cloner cloner)
94      : base(original, cloner) {
95      minValue = original.minValue;
96      maxValue = original.maxValue;
[4989]97      manipulatorMu = original.manipulatorMu;
[4722]98      manipulatorSigma = original.manipulatorSigma;
[5326]99      multiplicativeManipulatorSigma = original.multiplicativeManipulatorSigma;
[4722]100    }
[3269]101    public Constant()
[3993]102      : base("Constant", "Represents a constant value.") {
[4989]103      manipulatorMu = 0.0;
[3512]104      manipulatorSigma = 1.0;
[5326]105      multiplicativeManipulatorSigma = 0.03;
[3512]106      minValue = -20.0;
107      maxValue = 20.0;
[3269]108    }
109
[5532]110    public override ISymbolicExpressionTreeNode CreateTreeNode() {
[3253]111      return new ConstantTreeNode(this);
112    }
[3485]113
114    public override IDeepCloneable Clone(Cloner cloner) {
[4722]115      return new Constant(this, cloner);
[3485]116    }
[3253]117  }
118}
Note: See TracBrowser for help on using the repository browser.