Free cookie consent management tool by TermsFeed Policy Generator

source: branches/CloningRefactoring/HeuristicLab.Problems.ExternalEvaluation.GP/3.3/Symbols/Constant.cs @ 4656

Last change on this file since 4656 was 4089, checked in by abeham, 14 years ago

#1041

  • Added project with operators to convert expression trees to protocol buffer messages
File size: 3.0 KB
Line 
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
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    public Constant()
81      : base("Constant", "Represents a constant value.") {
82      manipulatorNu = 0.0;
83      manipulatorSigma = 1.0;
84      minValue = -20.0;
85      maxValue = 20.0;
86    }
87
88    public override SymbolicExpressionTreeNode CreateTreeNode() {
89      return new ConstantTreeNode(this);
90    }
91
92    public override IDeepCloneable Clone(Cloner cloner) {
93      Constant clone = (Constant)base.Clone(cloner);
94      clone.minValue = minValue;
95      clone.maxValue = maxValue;
96      clone.manipulatorNu = manipulatorNu;
97      clone.manipulatorSigma = manipulatorSigma;
98      return clone;
99    }
100  }
101}
Note: See TracBrowser for help on using the repository browser.