Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis/3.3/Symbolic/Symbols/IntegratedVariableTreeNode.cs @ 4113

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

Added plugin for time series prognosis. #1081

File size: 3.1 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 System;
24using System.Collections.Generic;
25using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
26using HeuristicLab.Common;
27using HeuristicLab.Core;
28using HeuristicLab.Data;
29using HeuristicLab.Random;
30using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols;
31namespace HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis.Symbolic.Symbols {
32  [StorableClass]
33  public sealed class IntegratedVariableTreeNode : VariableTreeNode {
34    public new IntegratedVariable Symbol {
35      get { return (IntegratedVariable)base.Symbol; }
36    }
37    [Storable]
38    private int minTimeOffset;
39    public int MinTimeOffset {
40      get { return minTimeOffset; }
41      set { minTimeOffset = value; }
42    }
43
44    [Storable]
45    private int maxTimeOffset;
46    public int MaxTimeOffset {
47      get { return maxTimeOffset; }
48      set { maxTimeOffset = value; }
49    }
50
51    private IntegratedVariableTreeNode() { }
52
53    // copy constructor
54    private IntegratedVariableTreeNode(IntegratedVariableTreeNode original)
55      : base(original) {
56      minTimeOffset = original.minTimeOffset;
57      maxTimeOffset = original.maxTimeOffset;
58    }
59
60    public IntegratedVariableTreeNode(IntegratedVariable integralVarSymbol) : base(integralVarSymbol) { }
61
62    public override bool HasLocalParameters {
63      get {
64        return true;
65      }
66    }
67
68    public override void ResetLocalParameters(IRandom random) {
69      base.ResetLocalParameters(random);
70      minTimeOffset = random.Next(Symbol.MinLag, Symbol.MaxLag + 1);
71      maxTimeOffset = random.Next(minTimeOffset, Symbol.MaxLag + 1);
72    }
73
74    public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
75      base.ShakeLocalParameters(random, shakingFactor);
76      minTimeOffset = Math.Min(Symbol.MaxLag, Math.Max(Symbol.MinLag, minTimeOffset + random.Next(-1, 2)));
77      maxTimeOffset = Math.Min(Symbol.MaxLag, Math.Max(minTimeOffset, maxTimeOffset + random.Next(-1, 2)));
78    }
79
80
81    public override object Clone() {
82      return new IntegratedVariableTreeNode(this);
83    }
84
85    public override string ToString() {
86      return Weight.ToString("E4") + " I(" + VariableName +
87        ", " + minTimeOffset + ", " + maxTimeOffset + ")";
88    }
89  }
90}
Note: See TracBrowser for help on using the repository browser.