Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis/3.3/Symbolic/Symbols/IntegratedVariableTreeNode.cs @ 5275

Last change on this file since 5275 was 5275, checked in by gkronber, 13 years ago

Merged changes from trunk to data analysis exploration branch and added fractional distance metric evaluator. #1142

File size: 3.3 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    [StorableConstructor]
53    protected IntegratedVariableTreeNode(bool deserializing) : base(deserializing) { }
54    protected IntegratedVariableTreeNode(IntegratedVariableTreeNode original, Cloner cloner)
55      : base(original, cloner) {
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    public override IDeepCloneable Clone(Cloner cloner) {
80      return new IntegratedVariableTreeNode(this, cloner);
81    }
82    public override string ToString() {
83      return Weight.ToString("E4") + " I(" + VariableName +
84        ", " + minTimeOffset + ", " + maxTimeOffset + ")";
85    }
86  }
87}
Note: See TracBrowser for help on using the repository browser.