[4113] | 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 HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
| 23 | using System;
|
---|
| 24 | using System.Collections.Generic;
|
---|
| 25 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 26 | using HeuristicLab.Common;
|
---|
| 27 | using HeuristicLab.Core;
|
---|
| 28 | using HeuristicLab.Data;
|
---|
| 29 | using HeuristicLab.Random;
|
---|
| 30 | using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols;
|
---|
| 31 | namespace 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() { }
|
---|
[5275] | 52 | [StorableConstructor]
|
---|
| 53 | protected IntegratedVariableTreeNode(bool deserializing) : base(deserializing) { }
|
---|
| 54 | protected IntegratedVariableTreeNode(IntegratedVariableTreeNode original, Cloner cloner)
|
---|
| 55 | : base(original, cloner) {
|
---|
[4113] | 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 | }
|
---|
[5275] | 79 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 80 | return new IntegratedVariableTreeNode(this, cloner);
|
---|
[4113] | 81 | }
|
---|
| 82 | public override string ToString() {
|
---|
| 83 | return Weight.ToString("E4") + " I(" + VariableName +
|
---|
| 84 | ", " + minTimeOffset + ", " + maxTimeOffset + ")";
|
---|
| 85 | }
|
---|
| 86 | }
|
---|
| 87 | }
|
---|