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
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 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;
27namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
28  [StorableClass]
29  [Item("Constant", "Represents a constant value.")]
30  public sealed class Constant : Symbol {
31    #region Properties
32    [Storable]
33    private double minValue;
34    public double MinValue {
35      get { return minValue; }
36      set {
37        if (value != minValue) {
38          minValue = value;
39          OnChanged(EventArgs.Empty);
40        }
41      }
42    }
43    [Storable]
44    private double maxValue;
45    public double MaxValue {
46      get { return maxValue; }
47      set {
48        if (value != maxValue) {
49          maxValue = value;
50          OnChanged(EventArgs.Empty);
51        }
52      }
53    }
54    [Storable]
55    private double manipulatorMu;
56    public double ManipulatorMu {
57      get { return manipulatorMu; }
58      set {
59        if (value != manipulatorMu) {
60          manipulatorMu = value;
61          OnChanged(EventArgs.Empty);
62        }
63      }
64    }
65    [Storable]
66    private double manipulatorSigma;
67    public double ManipulatorSigma {
68      get { return manipulatorSigma; }
69      set {
70        if (value < 0) throw new ArgumentException();
71        if (value != manipulatorSigma) {
72          manipulatorSigma = value;
73          OnChanged(EventArgs.Empty);
74        }
75      }
76    }
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
90    #endregion
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;
97      manipulatorMu = original.manipulatorMu;
98      manipulatorSigma = original.manipulatorSigma;
99      multiplicativeManipulatorSigma = original.multiplicativeManipulatorSigma;
100    }
101    public Constant()
102      : base("Constant", "Represents a constant value.") {
103      manipulatorMu = 0.0;
104      manipulatorSigma = 1.0;
105      multiplicativeManipulatorSigma = 0.03;
106      minValue = -20.0;
107      maxValue = 20.0;
108    }
109
110    public override ISymbolicExpressionTreeNode CreateTreeNode() {
111      return new ConstantTreeNode(this);
112    }
113
114    public override IDeepCloneable Clone(Cloner cloner) {
115      return new Constant(this, cloner);
116    }
117  }
118}
Note: See TracBrowser for help on using the repository browser.