source: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/LaggedVariable.cs @ 3993

Last change on this file since 3993 was 3993, checked in by mkommend, 11 years ago

changed symbols and grammars to be more efficient in respect to cloning, construction and deserialization (ticket #1073)

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("LaggedVariable", "Represents a variable value with a time offset.")]
36  public sealed class LaggedVariable : Symbol {
37    #region Properties
38    [Storable]
39    private double weightNu;
40    public double WeightNu {
41      get { return weightNu; }
42      set { weightNu = value; }
43    }
44    [Storable]
45    private double weightSigma;
46    public double WeightSigma {
47      get { return weightSigma; }
48      set {
49        if (weightSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
50        weightSigma = value;
51      }
52    }
53    [Storable]
54    private double weightManipulatorNu;
55    public double WeightManipulatorNu {
56      get { return weightManipulatorNu; }
57      set { weightManipulatorNu = value; }
58    }
59    [Storable]
60    private double weightManipulatorSigma;
61    public double WeightManipulatorSigma {
62      get { return weightManipulatorSigma; }
63      set {
64        if (weightManipulatorSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
65        weightManipulatorSigma = value;
66      }
67    }
68    private List<string> variableNames;
69    [Storable]
70    public IEnumerable<string> VariableNames {
71      get { return variableNames; }
72      set {
73        if (value == null) throw new ArgumentNullException();
74        variableNames.Clear();
75        variableNames.AddRange(value);
76      }
77    }
78    [Storable]
79    private int minLag;
80    public int MinLag {
81      get { return minLag; }
82      set { minLag = value; }
83    }
84    [Storable]
85    private int maxLag;
86    public int MaxLag {
87      get { return maxLag; }
88      set { maxLag = value; }
89    }
90    #endregion
91    public LaggedVariable()
92      : base("LaggedVariable", "Represents a variable value with a time offset.") {
93      weightNu = 1.0;
94      weightSigma = 1.0;
95      weightManipulatorNu = 0.0;
96      weightManipulatorSigma = 1.0;
97      variableNames = new List<string>();
98      minLag = 0; maxLag = 0;
99    }
100
101    public override SymbolicExpressionTreeNode CreateTreeNode() {
102      return new LaggedVariableTreeNode(this);
103    }
104
105    public override IDeepCloneable Clone(Cloner cloner) {
106      LaggedVariable clone = (LaggedVariable)base.Clone(cloner);
107      clone.weightNu = weightNu;
108      clone.weightSigma = weightSigma;
109      clone.variableNames = new List<string>(variableNames);
110      clone.weightManipulatorNu = weightManipulatorNu;
111      clone.weightManipulatorSigma = weightManipulatorSigma;
112      clone.minLag = minLag;
113      clone.maxLag = maxLag;
114      return clone;
115    }
116  }
117}
Note: See TracBrowser for help on using the repository browser.