[3253] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[14186] | 3 | * Copyright (C) 2002-2016 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] | 22 | using System;
|
---|
[3376] | 23 | using HeuristicLab.Common;
|
---|
[3269] | 24 | using HeuristicLab.Core;
|
---|
[4068] | 25 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
[3269] | 26 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
[5532] | 27 | namespace 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 |
|
---|
[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]
|
---|
| 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;
|
---|
[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 | }
|
---|