Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SlidingWindow/SlidingWindowData.cs @ 9963

Last change on this file since 9963 was 9963, checked in by bburlacu, 11 years ago

#1772: Merged changes from the trunk and other branches. Added new ExtendedSymbolicExpressionTreeCanvas control for the visual exploration of tree genealogies. Reorganized some files and folders.

File size: 2.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 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 System;
23using System.Collections.Generic;
24using System.Linq;
25using HeuristicLab.Common;
26using HeuristicLab.Core;
27using HeuristicLab.Data;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29
30namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
31  [StorableClass]
32  [Item("Sliding Window Position", "")]
33  public sealed class SlidingWindowData : Item {
34
35    [Storable]
36    private IntRange slidingWindowPosition;
37    public IntRange SlidingWindowPosition {
38      get { return slidingWindowPosition; }
39    }
40
41    [Storable]
42    private IEnumerable<double> targetValues;
43    public IEnumerable<double> TargetValues {
44      get { return targetValues; }
45    }
46
47    [Storable]
48    private IEnumerable<double> estimatedValues;
49    public IEnumerable<double> EstimatedValues {
50      get { return estimatedValues; }
51      set {
52        if (value == null) throw new ArgumentNullException();
53        estimatedValues = value.ToArray();
54        OnEstimatedValuesChanged();
55      }
56    }
57
58    [StorableConstructor]
59    private SlidingWindowData(bool deserializing) : base(deserializing) { }
60    private SlidingWindowData(SlidingWindowData original, Cloner cloner)
61      : base(original, cloner) {
62      slidingWindowPosition = cloner.Clone(original.slidingWindowPosition);
63      if (original.targetValues != null)
64        targetValues = new List<double>(original.targetValues);
65      if (original.estimatedValues != null)
66        estimatedValues = new List<double>(original.estimatedValues);
67    }
68    public override IDeepCloneable Clone(Cloner cloner) {
69      return new SlidingWindowData(this, cloner);
70    }
71
72    public SlidingWindowData(IntRange slidingWindowPosition, IEnumerable<double> targetValues)
73      : base() {
74      this.slidingWindowPosition = slidingWindowPosition;
75      this.targetValues = targetValues.ToArray();
76    }
77
78    public event EventHandler EstimatedValuesChanged;
79    private void OnEstimatedValuesChanged() {
80      var handler = EstimatedValuesChanged;
81      if (handler != null) EstimatedValuesChanged(this, EventArgs.Empty);
82    }
83  }
84}
Note: See TracBrowser for help on using the repository browser.