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 System.Collections.Generic;
|
---|
24 | using HeuristicLab.Common;
|
---|
25 | using HeuristicLab.Core;
|
---|
26 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
27 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
|
---|
28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
29 | namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols {
|
---|
30 | [StorableClass]
|
---|
31 | [Item("Variable", "Represents a variable value.")]
|
---|
32 | public class Variable : Symbol {
|
---|
33 | #region Properties
|
---|
34 | [Storable]
|
---|
35 | private double weightNu;
|
---|
36 | public double WeightNu {
|
---|
37 | get { return weightNu; }
|
---|
38 | set {
|
---|
39 | if (value != weightNu) {
|
---|
40 | weightNu = value;
|
---|
41 | OnChanged(EventArgs.Empty);
|
---|
42 | }
|
---|
43 | }
|
---|
44 | }
|
---|
45 | [Storable]
|
---|
46 | private double weightSigma;
|
---|
47 | public double WeightSigma {
|
---|
48 | get { return weightSigma; }
|
---|
49 | set {
|
---|
50 | if (weightSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
|
---|
51 | if (value != weightSigma) {
|
---|
52 | weightSigma = value;
|
---|
53 | OnChanged(EventArgs.Empty);
|
---|
54 | }
|
---|
55 | }
|
---|
56 | }
|
---|
57 | [Storable]
|
---|
58 | private double weightManipulatorNu;
|
---|
59 | public double WeightManipulatorNu {
|
---|
60 | get { return weightManipulatorNu; }
|
---|
61 | set {
|
---|
62 | if (value != weightManipulatorNu) {
|
---|
63 | weightManipulatorNu = value;
|
---|
64 | OnChanged(EventArgs.Empty);
|
---|
65 | }
|
---|
66 | }
|
---|
67 | }
|
---|
68 | [Storable]
|
---|
69 | private double weightManipulatorSigma;
|
---|
70 | public double WeightManipulatorSigma {
|
---|
71 | get { return weightManipulatorSigma; }
|
---|
72 | set {
|
---|
73 | if (weightManipulatorSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
|
---|
74 | if (value != weightManipulatorSigma) {
|
---|
75 | weightManipulatorSigma = value;
|
---|
76 | OnChanged(EventArgs.Empty);
|
---|
77 | }
|
---|
78 | }
|
---|
79 | }
|
---|
80 | private List<string> variableNames;
|
---|
81 | [Storable]
|
---|
82 | public IEnumerable<string> VariableNames {
|
---|
83 | get { return variableNames; }
|
---|
84 | set {
|
---|
85 | if (value == null) throw new ArgumentNullException();
|
---|
86 | variableNames.Clear();
|
---|
87 | variableNames.AddRange(value);
|
---|
88 | OnChanged(EventArgs.Empty);
|
---|
89 | }
|
---|
90 | }
|
---|
91 | #endregion
|
---|
92 | public Variable() : this("Variable", "Represents a variable value.") { }
|
---|
93 | public Variable(string name, string description)
|
---|
94 | : base(name, description) {
|
---|
95 | weightNu = 1.0;
|
---|
96 | weightSigma = 1.0;
|
---|
97 | weightManipulatorNu = 0.0;
|
---|
98 | weightManipulatorSigma = 1.0;
|
---|
99 | variableNames = new List<string>();
|
---|
100 | }
|
---|
101 |
|
---|
102 | public override SymbolicExpressionTreeNode CreateTreeNode() {
|
---|
103 | return new VariableTreeNode(this);
|
---|
104 | }
|
---|
105 |
|
---|
106 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
107 | Variable clone = (Variable)base.Clone(cloner);
|
---|
108 | clone.weightNu = weightNu;
|
---|
109 | clone.weightSigma = weightSigma;
|
---|
110 | clone.variableNames = new List<string>(variableNames);
|
---|
111 | clone.weightManipulatorNu = weightManipulatorNu;
|
---|
112 | clone.weightManipulatorSigma = weightManipulatorSigma;
|
---|
113 | return clone;
|
---|
114 | }
|
---|
115 | }
|
---|
116 | }
|
---|