source: branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SlidingWindow/SlidingWindowData.cs @ 9162

Last change on this file since 9162 was 9162, checked in by mkommend, 8 years ago

#1837: Refactored sliding window analyzers and updated the provided algorithm.

File size: 2.8 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      targetValues = new List<double>(original.targetValues);
64    }
65    public override IDeepCloneable Clone(Cloner cloner) {
66      return new SlidingWindowData(this, cloner);
67    }
68
69    public SlidingWindowData(IntRange slidingWindowPosition, IEnumerable<double> targetValues)
70      : base() {
71      this.slidingWindowPosition = slidingWindowPosition;
72      this.targetValues = targetValues.ToArray();
73    }
74
75    public event EventHandler EstimatedValuesChanged;
76    private void OnEstimatedValuesChanged() {
77      var handler = EstimatedValuesChanged;
78      if (handler != null) EstimatedValuesChanged(this, EventArgs.Empty);
79    }
80  }
81}
Note: See TracBrowser for help on using the repository browser.