1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2010 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 |
|
---|
22 | using System;
|
---|
23 | using HeuristicLab.Common;
|
---|
24 | using HeuristicLab.Core;
|
---|
25 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
26 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
|
---|
27 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
28 | namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols {
|
---|
29 | [StorableClass]
|
---|
30 | [Item("Constant", "Represents a constant value.")]
|
---|
31 | public sealed class Constant : Symbol {
|
---|
32 | #region Properties
|
---|
33 | [Storable]
|
---|
34 | private double minValue;
|
---|
35 | public double MinValue {
|
---|
36 | get { return minValue; }
|
---|
37 | set {
|
---|
38 | if (value != minValue) {
|
---|
39 | minValue = value;
|
---|
40 | OnChanged(EventArgs.Empty);
|
---|
41 | }
|
---|
42 | }
|
---|
43 | }
|
---|
44 | [Storable]
|
---|
45 | private double maxValue;
|
---|
46 | public double MaxValue {
|
---|
47 | get { return maxValue; }
|
---|
48 | set {
|
---|
49 | if (value != maxValue) {
|
---|
50 | maxValue = value;
|
---|
51 | OnChanged(EventArgs.Empty);
|
---|
52 | }
|
---|
53 | }
|
---|
54 | }
|
---|
55 | [Storable]
|
---|
56 | private double manipulatorMu;
|
---|
57 | public double ManipulatorMu {
|
---|
58 | get { return manipulatorMu; }
|
---|
59 | set {
|
---|
60 | if (value != manipulatorMu) {
|
---|
61 | manipulatorMu = value;
|
---|
62 | OnChanged(EventArgs.Empty);
|
---|
63 | }
|
---|
64 | }
|
---|
65 | }
|
---|
66 | [Storable]
|
---|
67 | private double manipulatorSigma;
|
---|
68 | public double ManipulatorSigma {
|
---|
69 | get { return manipulatorSigma; }
|
---|
70 | set {
|
---|
71 | if (value < 0) throw new ArgumentException();
|
---|
72 | if (value != manipulatorSigma) {
|
---|
73 | manipulatorSigma = value;
|
---|
74 | OnChanged(EventArgs.Empty);
|
---|
75 | }
|
---|
76 | }
|
---|
77 | }
|
---|
78 | [Storable(DefaultValue = 0.0)]
|
---|
79 | private double multiplicativeManipulatorSigma;
|
---|
80 | public double MultiplicativeManipulatorSigma {
|
---|
81 | get { return multiplicativeManipulatorSigma; }
|
---|
82 | set {
|
---|
83 | if (value < 0) throw new ArgumentException();
|
---|
84 | if (value != multiplicativeManipulatorSigma) {
|
---|
85 | multiplicativeManipulatorSigma = value;
|
---|
86 | OnChanged(EventArgs.Empty);
|
---|
87 | }
|
---|
88 | }
|
---|
89 | }
|
---|
90 |
|
---|
91 | #endregion
|
---|
92 | [StorableConstructor]
|
---|
93 | private Constant(bool deserializing) : base(deserializing) { }
|
---|
94 | private Constant(Constant original, Cloner cloner)
|
---|
95 | : base(original, cloner) {
|
---|
96 | minValue = original.minValue;
|
---|
97 | maxValue = original.maxValue;
|
---|
98 | manipulatorMu = original.manipulatorMu;
|
---|
99 | manipulatorSigma = original.manipulatorSigma;
|
---|
100 | multiplicativeManipulatorSigma = original.multiplicativeManipulatorSigma;
|
---|
101 | }
|
---|
102 | public Constant()
|
---|
103 | : base("Constant", "Represents a constant value.") {
|
---|
104 | manipulatorMu = 0.0;
|
---|
105 | manipulatorSigma = 1.0;
|
---|
106 | multiplicativeManipulatorSigma = 0.03;
|
---|
107 | minValue = -20.0;
|
---|
108 | maxValue = 20.0;
|
---|
109 | }
|
---|
110 |
|
---|
111 | public override SymbolicExpressionTreeNode CreateTreeNode() {
|
---|
112 | return new ConstantTreeNode(this);
|
---|
113 | }
|
---|
114 |
|
---|
115 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
116 | return new Constant(this, cloner);
|
---|
117 | }
|
---|
118 | }
|
---|
119 | }
|
---|