Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Variable.cs @ 4026

Last change on this file since 4026 was 4022, checked in by gkronber, 14 years ago

Worked on symbolic regression classes to prepare for time series prognosis plugin. #1081

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