Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.ExternalEvaluation.GP/3.3/Symbols/Constant.cs @ 6363

Last change on this file since 6363 was 5445, checked in by swagner, 14 years ago

Updated year of copyrights (#1406)

File size: 3.2 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.Encodings.SymbolicExpressionTreeEncoding.Symbols;
27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28
29namespace HeuristicLab.Problems.ExternalEvaluation.GP {
30  [StorableClass]
31  [Item("Constant", "Represents a constant value.")]
32  public sealed class Constant : Symbol {
33    #region Propeties
34    [Storable]
35    private double minValue;
36    public double MinValue {
37      get { return minValue; }
38      set {
39        if (value != minValue) {
40          minValue = value;
41          OnChanged(EventArgs.Empty);
42        }
43      }
44    }
45    [Storable]
46    private double maxValue;
47    public double MaxValue {
48      get { return maxValue; }
49      set {
50        if (value != maxValue) {
51          maxValue = value;
52          OnChanged(EventArgs.Empty);
53        }
54      }
55    }
56    [Storable]
57    private double manipulatorNu;
58    public double ManipulatorNu {
59      get { return manipulatorNu; }
60      set {
61        if (value != manipulatorNu) {
62          manipulatorNu = value;
63          OnChanged(EventArgs.Empty);
64        }
65      }
66    }
67    [Storable]
68    private double manipulatorSigma;
69    public double ManipulatorSigma {
70      get { return manipulatorSigma; }
71      set {
72        if (value < 0) throw new ArgumentException();
73        if (value != manipulatorSigma) {
74          manipulatorSigma = value;
75          OnChanged(EventArgs.Empty);
76        }
77      }
78    }
79    #endregion
80
81    [StorableConstructor]
82    private Constant(bool deserializing) : base(deserializing) { }
83    private Constant(Constant original, Cloner cloner)
84      : base(original, cloner) {
85      minValue = original.minValue;
86      maxValue = original.maxValue;
87      manipulatorNu = original.manipulatorNu;
88      manipulatorSigma = original.manipulatorSigma;
89    }
90    public override IDeepCloneable Clone(Cloner cloner) {
91      return new Constant(this, cloner);
92    }
93    public Constant()
94      : base("Constant", "Represents a constant value.") {
95      manipulatorNu = 0.0;
96      manipulatorSigma = 1.0;
97      minValue = -20.0;
98      maxValue = 20.0;
99    }
100
101    public override SymbolicExpressionTreeNode CreateTreeNode() {
102      return new ConstantTreeNode(this);
103    }
104  }
105}
Note: See TracBrowser for help on using the repository browser.