1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2014 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.Persistence.Default.CompositeSerializers.Storable;
|
---|
27 | namespace 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 | 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 | }
|
---|
99 | #endregion
|
---|
100 |
|
---|
101 | [StorableConstructor]
|
---|
102 | private Constant(bool deserializing) : base(deserializing) { }
|
---|
103 | private Constant(Constant original, Cloner cloner)
|
---|
104 | : base(original, cloner) {
|
---|
105 | minValue = original.minValue;
|
---|
106 | maxValue = original.maxValue;
|
---|
107 | manipulatorMu = original.manipulatorMu;
|
---|
108 | manipulatorSigma = original.manipulatorSigma;
|
---|
109 | multiplicativeManipulatorSigma = original.multiplicativeManipulatorSigma;
|
---|
110 | }
|
---|
111 | public Constant()
|
---|
112 | : base("Constant", "Represents a constant value.") {
|
---|
113 | manipulatorMu = 0.0;
|
---|
114 | manipulatorSigma = 1.0;
|
---|
115 | multiplicativeManipulatorSigma = 0.03;
|
---|
116 | minValue = -20.0;
|
---|
117 | maxValue = 20.0;
|
---|
118 | }
|
---|
119 |
|
---|
120 | public override ISymbolicExpressionTreeNode CreateTreeNode() {
|
---|
121 | return new ConstantTreeNode(this);
|
---|
122 | }
|
---|
123 |
|
---|
124 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
125 | return new Constant(this, cloner);
|
---|
126 | }
|
---|
127 | }
|
---|
128 | }
|
---|