Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/LaggedTreeNode.cs @ 13482

Last change on this file since 13482 was 12155, checked in by bburlacu, 10 years ago

#1772: Merged trunk changes.

File size: 2.4 KB
RevLine 
[3253]1#region License Information
2/* HeuristicLab
[12155]3 * Copyright (C) 2002-2015 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]22using System;
[4722]23using HeuristicLab.Common;
[4068]24using HeuristicLab.Core;
[3253]25using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
[5532]27namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
[3253]28  [StorableClass]
[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]
[5026]41    protected LaggedTreeNode(bool deserializing) : base(deserializing) { }
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}
Note: See TracBrowser for help on using the repository browser.