[3253] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[17181] | 3 | * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[3253] | 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 |
|
---|
[5026] | 22 | using System;
|
---|
[4722] | 23 | using HeuristicLab.Common;
|
---|
[4068] | 24 | using HeuristicLab.Core;
|
---|
[3253] | 25 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
[17097] | 26 | using HEAL.Attic;
|
---|
[5532] | 27 | namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
|
---|
[17097] | 28 | [StorableType("B5DF4207-7FDD-478D-B2FD-E52D8B7CD709")]
|
---|
[5026] | 29 | public class LaggedTreeNode : SymbolicExpressionTreeNode, ILaggedTreeNode {
|
---|
| 30 | public new LaggedSymbol Symbol {
|
---|
| 31 | get { return (LaggedSymbol)base.Symbol; }
|
---|
[3269] | 32 | }
|
---|
[3485] | 33 | [Storable]
|
---|
[5026] | 34 | private int lag;
|
---|
| 35 | public int Lag {
|
---|
| 36 | get { return lag; }
|
---|
| 37 | set { lag = value; }
|
---|
[3253] | 38 | }
|
---|
| 39 |
|
---|
[4722] | 40 | [StorableConstructor]
|
---|
[17097] | 41 | protected LaggedTreeNode(StorableConstructorFlag _) : base(_) { }
|
---|
[5026] | 42 | protected LaggedTreeNode(LaggedTreeNode original, Cloner cloner)
|
---|
[4722] | 43 | : base(original, cloner) {
|
---|
[5026] | 44 | lag = original.lag;
|
---|
[3253] | 45 | }
|
---|
[5026] | 46 | public LaggedTreeNode(LaggedSymbol timeLagSymbol) : base(timeLagSymbol) { }
|
---|
[3253] | 47 |
|
---|
[3442] | 48 | public override bool HasLocalParameters {
|
---|
[5026] | 49 | get { return true; }
|
---|
[3442] | 50 | }
|
---|
| 51 |
|
---|
[3269] | 52 | public override void ResetLocalParameters(IRandom random) {
|
---|
| 53 | base.ResetLocalParameters(random);
|
---|
[5026] | 54 | lag = random.Next(Symbol.MinLag, Symbol.MaxLag + 1);
|
---|
[3269] | 55 | }
|
---|
| 56 |
|
---|
[3512] | 57 | public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
|
---|
| 58 | base.ShakeLocalParameters(random, shakingFactor);
|
---|
[5026] | 59 | lag = Math.Min(Symbol.MaxLag, Math.Max(Symbol.MinLag, lag + random.Next(-1, 2)));
|
---|
[3512] | 60 | }
|
---|
| 61 |
|
---|
[4722] | 62 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
[5026] | 63 | return new LaggedTreeNode(this, cloner);
|
---|
[3253] | 64 | }
|
---|
[3442] | 65 |
|
---|
| 66 | public override string ToString() {
|
---|
[5026] | 67 | return base.ToString() + " " + lag.ToString();
|
---|
[3442] | 68 | }
|
---|
[3253] | 69 | }
|
---|
| 70 | }
|
---|